Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/*
3 changes: 3 additions & 0 deletions DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PiSloth
=======================
Library for PiSloth
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include DESCRIPTION.rst

# Include the test suite (FIXME: does not work yet)
# recursive-include tests *

# If using Python 3.5 or less, then have to include package data, even though
# it's already declared in setup.py
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
89 changes: 89 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
alabaster==0.7.12
altgraph==0.17
argh==0.26.2
awscli==1.18.124
Babel==2.7.0
beautifulsoup4==4.9.3
bitstring==3.1.7
boto3==1.14.34
botocore==1.17.47
certifi==2019.3.9
cffi==1.14.5
chardet==3.0.4
click==7.1.2
colorama==0.4.1
commonmark==0.9.1
cryptography==3.4.7
Django==2.2.7
docutils==0.15.2
ecdsa==0.16.1
esptool==3.0
furo==2021.4.11b34
future==0.18.2
idna==2.8
imagesize==1.1.0
importlib-metadata==2.0.0
Jinja2==2.10.3
jmespath==0.10.0
joblib==0.17.0
karma-sphinx-theme==0.0.8
livereload==2.6.1
lunr==0.5.8
Markdown==3.3.3
MarkupSafe==1.1.1
mkdocs==1.1.2
mysql-connector==2.2.9
nltk==3.5
numpy==1.19.1
opencv-python==4.4.0.40
packaging==19.2
pandas==1.1.1
pathtools==0.1.2
pefile==2019.4.18
Pillow==7.2.0
port-for==0.3.1
pyasn1==0.4.8
pycparser==2.20
pygame==1.9.6
Pygments==2.4.2
PyInstaller==3.6
PyMySQL==0.9.3
pyparsing==2.4.2
PyQt5==5.10.1
PyQt5-sip==12.8.1
pyserial==3.5
python-dateutil==2.8.0
python-magic==0.4.15
pytz==2019.3
pywin32-ctypes==0.2.0
PyYAML==5.1.2
recommonmark==0.6.0
reedsolo==1.5.4
regex==2020.10.23
requests==2.21.0
rsa==4.7
s3cmd==2.0.2
s3transfer==0.3.3
sip==4.19.8
six==1.12.0
snowballstemmer==2.0.0
soupsieve==2.2.1
Sphinx==3.5.4
sphinx-autobuild==0.7.1
sphinx-intl==2.0.1
sphinx-notfound-page==0.6
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
spi==0.2.0
sqlparse==0.3.0
tornado==6.0.3
tqdm==4.51.0
urllib3==1.24.2
watchdog==0.9.0
you-get==0.4.1475
zipp==3.4.0
20 changes: 20 additions & 0 deletions docs/source/about_robot_hat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
About Robot HAT
-----------------------------

.. image:: img/picar_x_pic7.png

**RST Button**
* Short pressing RST Button causes program resetting.
* Long press RST Button till the LED lights up then release, and you will disconnect the Bluetooth.

**USR Button**
* The functions of USR Button can be set by your programming. (Pressing down leads to a input “0”; releasing produces a input “1”. )

**LED**
* Set by your program. (Outputting 1 turns the LED on; Outputting 0 turns it off.)

**Battery Indicator**
* The voltage ranging above 7.8V, two LEDs light up; ranging 6.7V~7.8V, one LED turns on; ranging below 6.7V, all LEDs turn off.

**Bluetooth Indicator**
* The Bluetooth indicator keeps turning on at a well Bluetooth connection, blink at a Bluetooth disconnection, blink fast at a signal transmission.
62 changes: 62 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import sphinx_rtd_theme

html_theme = 'sphinx_rtd_theme'
# -- Project information -----------------------------------------------------

project = 'pisloth'
copyright = '2021, sunfounder'
author = 'sunfounder'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]


# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_js_files = [
'https://ezblock.cc/readDocFile/topHead.js',
]
html_css_files = [
'https://ezblock.cc/readDocFile/topHead.css',
]
90 changes: 90 additions & 0 deletions docs/source/dance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Dance
=========

In this project, we will play a piece of music and let Pisloth dance to the rhythm of the music.

You can open ``dancing.py`` in the folder of the ``example`` with command ``sudo pyrhon3 dancing.py`` or directly copy the following code to the Python IDE to run.

**Code**

.. code:: python

from pisloth import Sloth
from robot_hat import Music
from robot_hat import Ultrasonic
from robot_hat import Pin
import time
import os

music = Music()

sloth = Sloth([1,2,3,4])
sloth.set_offset([0,0,0,0])

def main():

music.background_music('./musics/india-Arulo.mp3')
music.music_set_volume(20)
sloth.do_action('stomp left',3,bpm=129)
sloth.do_action('stomp rihgt',3,bpm=129)
sloth.do_action('moon walk left',3,bpm=129)
sloth.do_action('moon walk right',3,bpm=129)
for i in range(3):
sloth.do_action('swing',1,bpm=129)
sloth.do_action('stand',1,bpm=129)
for i in range(3):
sloth.do_action('close',1,bpm=129)
sloth.do_action('stand',1,bpm=129)
sloth.do_action('open',1,bpm=129)
sloth.do_action('stand',1,bpm=129)
sloth.do_action('tiptoe left',2,bpm=129)
sloth.do_action('tiptoe right',2,bpm=129)

sloth.do_action('stomp left',3,bpm=129)
sloth.do_action('stomp rihgt',3,bpm=129)
sloth.do_action('moon walk left',3,bpm=129)
sloth.do_action('moon walk right',3,bpm=129)
for i in range(3):
sloth.do_action('hook',1,bpm=129)
sloth.do_action('stand',1,bpm=129)
for i in range(4):
sloth.do_action('swing',1,bpm=129)
sloth.do_action('big swing',1,bpm=129)
sloth.do_action('swing',1,bpm=129)
sloth.do_action('stand',1,bpm=129)

sloth.do_action('tiptoe right',2,bpm=129)
sloth.do_action('stand',2,bpm=129)



music.music_stop()
time.sleep(10)



if __name__ == "__main__":
while True:
main()

**How it works?**

You can make Pisloth play music by importing the following library.

.. code:: python

from robot_hat import TTS, Music

Play the background music in the music directory and set the volume to 20.

.. code:: python

music.background_music('./musics/india-Arulo.mp3')
music.music_set_volume(20)

Execute the function ``sloth.do_action(motion_name,step=1,speed=None,bpm=None)`` to let Pisloth perform the actions we set.
The bpm parameter here will affect the interval time between Pisloth's actions, the larger the value, the shorter the interval time.
When we learn about the bpm of a piece of music through some methods, you can freely match the movement of the Pisloth according to the bpm of this music to make it dance with different styles of music.

For music bmp, if you want to know more, you can refer to:
https://en.wikipedia.org/wiki/Tempo
41 changes: 41 additions & 0 deletions docs/source/diy_action.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
DIY Action
===============

Through the previous courses, do you have a deeper understanding of Pisloth? And next let’s try to design the movement of Pisloth by ourselves.

**Code**

.. code:: python

from pisloth import Sloth
import time

sloth = Sloth([1,2,3,4])
sloth.add_action("my_action", [
[ 45,0 ,0, 0],
[0, 0, 0, 0]
])

def main():
sloth.do_action("my_action", 1, 80)
time.sleep(1)

if __name__ == "__main__":
while True:
main()

**How it works?**

You can customize the action of Pisloth through the ``add_action`` function, the first parameter is the name of the action,
The second parameter is a two-dimensional array. The four parameters in the array are used to control the four servos of the Pisloth leg.
For how to choose the value we will introduce it in detail in the next lesson.

.. code:: python

sloth = Sloth([1,2,3,4])
sloth.add_action("my_action", [
[ 45,0 ,0, 0],
[0, 0, 0, 0]
])

Then use the ``do_action'' function to make pisloth do the action to see the actual effect.
Loading