SunFounder PiDog Kit, Release 1.0
(continued from previous page)
my_dog
.
do_action(
'stand'
, wait
=
False
, speed
=
60
)
my_dog
.
head_move_raw([[
0
,
0
, head_pitch_adjust]],
immediately
=
True
, speed
=
60
)
my_dog
.
do_action(name, step_count
=
10
, wait
=
False
, speed
=
speed)
elif
index
<
len
(actions)
+
len
(sound_effects):
my_dog
.
speak(sound_effects[index
-
len
(actions)])
last_index
=
index
def
function_demonstration
():
global
index
global
exit_flag
show_info()
while
True
:
try
:
num
=
input
(
"Enter function number: "
)
if
int
(num)
>
len
(actions)
+
len
(sound_effects):
(
'Out of range'
)
continue
index
=
int
(num)
-
1
do_function(index)
show_info()
except
ValueError
:
(
'ValueError'
)
except
KeyboardInterrupt
:
my_dog
.
close()
sleep(
0.05
)
if
__name__
==
"__main__"
:
function_demonstration()
2.2.4 Patrol
In this project, PiDog makes a vivid behavior: patrolling.
PiDog will walk forward, if there is an obstacle in front of it, it will stop and bark.
Run the Code
cd
/
home
/
pi
/
pidog
/
examples
sudo python3
3
_patrol
.
py
After running this example, PiDog will wag its tail, scan left and right, and walk forward.
Code
Note:
You can
Modify/Reset/Copy/Run/Stop
the code below. But before that, you need to go to source code path
like
pidog\examples
. After modifying the code, you can run it directly to see the effect.
2.2. Funny Project
51
Содержание 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 ...