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
)
(
'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
Содержание PiDog
Страница 1: ...SunFounder PiDog Kit Release 1 0 sunfounder Jan 09 2023 ...
Страница 2: ......
Страница 4: ...ii ...
Страница 6: ...SunFounder PiDog Kit Release 1 0 Content 2 CONTENTS ...
Страница 8: ...SunFounder PiDog Kit Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...
Страница 15: ...SunFounder PiDog Kit Release 1 0 Step 7 Click the WRITE button 2 1 Quick Guide on Python 11 ...
Страница 92: ...SunFounder PiDog Kit Release 1 0 88 Chapter 2 Play with Python ...
Страница 108: ...SunFounder PiDog Kit Release 1 0 104 Chapter 4 Appendix ...