SunFounder PiDog Kit, Release 1.0
Pidog.wait_head_done()
Wait for all the head actions in the buffer to be executed
Pidog.head_stop()
Clear all the head actions of leg in the buffer, to make head servos stop
Here are some common use cases:
1. Nod five times.
from pidog import Pidog
import time
my_dog = Pidog()
for _ in range(5):
my_dog.head_move([[0, 0, 30],[0, 0, -30]], speed=80)
my_dog.wait_head_done()
time.sleep(0.5)
2. Shake your head for 10 seconds.
from pidog import Pidog
import time
my_dog = Pidog()
for _ in range(99):
my_dog.head_move([[30, 0, 0],[-30, 0, 0]], immediately=False, speed=30)
# keep 10s
time.sleep(10)
my_dog.head_move([[0, 0, 0]], immediately=True, speed=80)
3. Whether sitting or half standing, PiDog keeps its head level when shaking its head.
from pidog import Pidog
import time
my_dog = Pidog()
# action list
shake_head = [[30, 0, 0],[-30, 0, 0]]
half_stand_leg = [[45, 10, -45, -10, 45, 10, -45, -10]]
sit_leg = [[30, 60, -30, -60, 80, -45, -80, 45]]
while True:
# shake head in half stand
my_dog.legs_move(half_stand_leg, speed=30)
for _ in range(5):
my_dog.head_move(shake_head, pitch_comp=0, speed=50)
my_dog.wait_head_done()
time.sleep(0.5)
# shake head in sit
(continues on next page)
78 Chapter 2. Play with Python