EasyManua.ls Logo

SunFounder PiDog - Page 63

Default Icon
109 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 PiDog Kit, Release 1.0
(continued from previous page)
from preset_actions import bark
my_dog = Pidog()
sleep(0.1)
def delay(time):
my_dog.wait_legs_done()
my_dog.wait_head_done()
sleep(time)
def face_track():
Vilib.camera_start(vflip=False, hflip=False)
Vilib.display(local=True, web=True)
Vilib.human_detect_switch(True)
sleep(0.2)
print('start')
yaw = 0
roll = 0
pitch = 0
flag = False
direction = 0
my_dog.do_action('sit', speed=50)
my_dog.head_move([[yaw, 0, pitch]], pitch_comp=-
40, immediately=True, speed=80)
delay(0.5)
if my_dog.ears.isdetected():
direction = my_dog.ears.read()
while True:
if flag == False:
my_dog.rgb_strip.set_mode('breath', 'pink', delay=0.1)
# If heard somthing, turn to face it
if my_dog.ears.isdetected():
flag = False
direction = my_dog.ears.read()
pitch = 0
if direction > 0 and direction < 100:
yaw = -direction
if yaw < -80:
yaw = -80
elif direction > 260 and direction < 360:
yaw = 360 - direction
if yaw > 80:
yaw = 80
my_dog.head_move([[yaw, 0, pitch]], pitch_comp=-
40, immediately=True, speed=80)
sleep(0.05)
ex = Vilib.detect_obj_parameter['human_x'] - 320
ey = Vilib.detect_obj_parameter['human_y'] - 240
people = Vilib.detect_obj_parameter['human_n']
# If see someone, bark at him/her
(continues on next page)
2.2. Funny Project 59

Related product manuals