SunFounder PiDog Kit, Release 1.0
#!/usr/bin/env python3
from
pidog
import
Pidog
from
time
import
sleep
from
preset_actions
import
howling
my_dog
=
Pidog()
sleep(
0.5
)
def
main
():
my_dog
.
do_action(
'sit'
, speed
=
50
)
my_dog
.
head_move([[
0
,
0
,
0
]], pitch_comp
=-
40
, immediately
=
True
, speed
=
80
)
sleep(
0.5
)
while
True
:
howling(my_dog)
if
__name__
==
"__main__"
:
try
:
main()
except
KeyboardInterrupt
:
my_dog
.
close()
2.2.11 Balance
Because PiDog is equipped with a 6-DOF IMU module, it has a great sense of balance.
In this example, you can make PiDog walk smoothly on the table, even if you lift one side of the table, PiDog will
walk smoothly on the gentle slope.
Run the Code
cd
/
home
/
pi
/
pidog
/
examples
sudo python3
10
_balance
.
py
After the program is running, you will see a printed keyboard on the terminal. You can control PiDog to walk smoothly
on the ramp by typing the below keys.
Keys
Function
W
Forward
E
Stand
A
Turn Left
S
Backward
D
Turn Right
R
Up
F
Down
Code
#!/usr/bin/env python3
from
time
import
sleep
(continues on next page)
62
Chapter 2. Play with Python
Summary of Contents for PiDog
Page 1: ...SunFounder PiDog Kit Release 1 0 sunfounder Jan 09 2023 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder PiDog Kit Release 1 0 Content 2 CONTENTS ...
Page 8: ...SunFounder PiDog Kit Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...
Page 15: ...SunFounder PiDog Kit Release 1 0 Step 7 Click the WRITE button 2 1 Quick Guide on Python 11 ...
Page 92: ...SunFounder PiDog Kit Release 1 0 88 Chapter 2 Play with Python ...
Page 108: ...SunFounder PiDog Kit Release 1 0 104 Chapter 4 Appendix ...