SunFounder PiDog Kit, Release 1.0
#!/usr/bin/env python3
from
time
import
sleep
from
pidog
import
Pidog
import
readchar
from
preset_actions
import
*
import
os
my_dog
=
Pidog()
sleep(
0.5
)
usage
=
'''
Keyboard Control Ctrl + C to Exit
...
'''
SIT_HEAD_PITCH
= -
40
STAND_HEAD_PITCH
=
0
STATUS_STAND
=
0
STATUS_SIT
=
1
STATUS_LIE
=
2
HEAD_SPEED
=
80
HEAD_ANGLE
=
20
head_yrp
=
[
0
,
0
,
0
]
head_pitch_init
=
0
command
=
None
current_status
=
STATUS_LIE
def
set_head
(roll
=
None
, pitch
=
None
, yaw
=
None
):
global
head_yrp
if
roll
is not
None
:
head_yrp[
1
]
=
roll
if
pitch
is not
None
:
head_yrp[
2
]
=
pitch
if
yaw
is not
None
:
head_yrp[
0
]
=
yaw
my_dog
.
head_move([head_yrp], immediately
=
True
, speed
=
HEAD_SPEED)
COMMANDS
=
{
"forward"
: {
"commands"
: [
"forward"
],
"function"
:
lambda
: my_dog
.
do_action(
'forward'
, wait
=
False
, speed
=
98
),
"status"
: STATUS_STAND,
"head_pitch"
: STAND_HEAD_PITCH,
},
"backward"
: {
"commands"
: [
"backward"
],
"function"
:
lambda
: my_dog
.
do_action(
'backward'
, wait
=
False
, speed
=
98
),
"status"
: STATUS_STAND,
"head_pitch"
: STAND_HEAD_PITCH,
},
"turn left"
: {
"commands"
: [
"turn left"
],
"function"
:
lambda
: my_dog
.
do_action(
'turn_left'
, wait
=
False
, speed
=
98
),
(continues on next page)
2.2. Funny Project
65
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 ...