SunFounder PiCrawler Kit
• Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
Ready to explore and create with us? Click [] and join today!
3.15 Emotional Robot
This example shows several interesting custom actions of PiCrawler.
Run the Code
cd ~/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.
from picrawler import Picrawler
from time import sleep
crawler = Picrawler()
def handwork(speed):
basic_step = []
basic_step = crawler.step_list.get("sit")
left_hand = crawler.mix_step(basic_step,0,[0,50,80])
right_hand = crawler.mix_step(basic_step,1,[0,50,80])
two_hand = crawler.mix_step(left_hand,1,[0,50,80])
crawler.do_step('sit',speed)
sleep(0.6)
crawler.do_step(left_hand,speed)
sleep(0.6)
crawler.do_step(two_hand,speed)
sleep(0.6)
crawler.do_step(right_hand,speed)
sleep(0.6)
crawler.do_step('sit',speed)
sleep(0.6)
def twist(speed):
new_step=[[50, 50, -75], [50, 50, -75],[50, 50, -75], [50, 50, -75]]
for i in range(4):
for inc in range(30,60,5):
rise = [50,50,(-75+inc*0.5)]
drop = [50,50,(-75-inc)]
(continues on next page)
80 Chapter 3. Play with Python