SunFounder PiDog Kit, Release 1.0
(continued from previous page)
# style:"boom", color="cyan", brightness=0.1, delay=0.1
my_dog
.
rgb_strip
.
set_mode(style
=
"boom"
, color
=
"cyan"
, brightness
=
0.5
, delay
=
0.05
)
time
.
sleep(
3
)
# close
my_dog
.
rgb_strip
.
close()
time
.
sleep(
2
)
2.3.10 IMU Read
Through the 6-DOF IMU Module, PiDog can determine if it’s standing on a slope, or if it’s being picked up.
The 6-DOF IMU Module is equipped with a 3-axis accelerometer and a 3-axis gyroscope, allowing acceleration and
angular velocity to be measured in three directions.
Note:
Before using the module, make sure that it is correctly assembled. The label on the module will let you know
if it is reversed.
You can read their acceleration with:
ax, ay, az
=
Pidog
.
accData
With the PiDog placed horizontally, the acceleration on the x-axis (ie ax) should be close to the acceleration of gravity
(1g), with a value of -16384. The values of the y-axis and x-axis are close to 0.
Use the following way to read their angular velocity:
gx, gy, gz
=
my_dog
.
gyroData
In the case where PiDog is placed horizontally, all three values are close to 0.
Here are some examples of how 6-DOF Module is used:
1. Read real-time acceleration, angular velocity
from
pidog
import
Pidog
import
time
my_dog
=
Pidog()
my_dog
.
do_action(
"pushup"
, step_count
=
10
, speed
=
20
)
while
True
:
ax, ay, az
=
my_dog
.
accData
gx, gy, gz
=
my_dog
.
gyroData
(f
"accData: {ax/16384:.2f} g ,{ay/16384:.2f} g, {az/16384:.2f} g
˓
→
gyroData: {gx} °/s, {gy} °/s, {gz} °/s"
)
time
.
sleep(
0.2
)
if
my_dog
.
is_legs_done():
break
my_dog
.
stop_and_lie()
my_dog
.
close()
2.3. Easy Coding
85
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 ...