
SunFounder PiDog Kit, Release 1.0
(continued from previous page)
current_coords
=
backward_coords
elif
key
==
'a'
:
current_coords
=
turn_left_coords
elif
key
==
'd'
:
current_coords
=
turn_right_coords
elif
key
==
'e'
:
current_coords
=
stand_coords
elif
key
==
'r'
:
current_pose[
'z'
]
+=
1
if
current_pose[
'z'
]
>
90
:
current_pose[
'z'
]
=
90
elif
key
==
'f'
:
current_pose[
'z'
]
-=
1
if
current_pose[
'z'
]
<
30
:
current_pose[
'z'
]
=
30
if
__name__
==
"__main__"
:
try
:
main()
except
KeyboardInterrupt
:
pass
finally
:
t
.
join()
my_dog
.
close()
2.2.12 Play PiDog with Keyboard
In this example, we will use the keyboard to control PiDog. You can press these keys in the terminal to make it act.
Keys
Function
Keys
Function
w
forward
s
backward
a
turn left
d
turn right
z
lie down
x
stand up
c
sit
q
bark
Q
bark harder
e
pant
r
wag tail
t
shake head
v
stretch
1
doze off
2
push-up
3
howling
4
twist body
5
scratch
t
handshake
g
high five
Run the Code
cd
/
home
/
pi
/
pidog
/
examples
sudo python3 py_11_keyboard_control
.
py
After the program runs, you will see a printed keyboard on the terminal. Now you can control PiDog with keyboard
in terminal.
Code
64
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 ...