EasyManua.ls Logo

SunFounder PiCrawler Kit - Emotional Robot

Default Icon
137 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder PiCrawler Kit
def twist(speed):
## [right front],[left front],[left rear],[right rear]
new_step=[[50, 50, -80], [50, 50, -80],[50, 50, -80], [50, 50, -80]]
for i in range(4):
for inc in range(30,60,5):
rise = [50,50,(-80+inc
*
0.5)]
drop = [50,50,(-80-inc)]
new_step[i]=rise
new_step[(i+2)%4] = drop
new_step[(i+1)%4] = rise
new_step[(i-1)%4] = drop
crawler.do_step(new_step,speed)
Simply put, it uses two layers of for loops to make the new_step array produce continuous and regular changes, and
at the same time, crawler.do_step() executes the posture to form a continuous action.
You can intuitively get the coordinate value array corresponding to each pose from Adjust Posture.
In addition, the example also played background music. The implementation method is as follows.
Play music by importing the following libraries.
from robot_hat import Music
Declare a Music object.
music = Music()
Play the background music in the picrawler/examples/musics directory and set the volume to 20. You can
also add music to the musics folder via Filezilla Software.
music.background_music('./musics/sports-Ahjay_Stelino.mp3')
music.music_set_volume(20)
Note: You can add different sound effects or music to musics or sounds folder via Filezilla Software.
3.15 Emotional Robot
This example shows several interesting custom actions of PiCrawler.
Run the Code
cd /home/pi/picrawler/examples
sudo python3 emotional_robot.py
Code
Note: You can Modify/Reset/Copy/Run/Stop the code below. But before that, you need to go to source code path
like picrawler\examples. After modifying the code, you can run it directly to see the effect.
3.15. Emotional Robot 81

Other manuals for SunFounder PiCrawler Kit

Related product manuals