EasyManua.ls Logo

SunFounder PiDog - Page 60

Default Icon
109 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder PiDog Kit, Release 1.0
(continued from previous page)
sleep(0.2)
# Lay down again
my_dog.rgb_strip.set_mode('breath', 'pink')
my_dog.do_action('lie', wait=True, speed=50)
my_dog.wait_all_done()
sleep(0.2)
# Cleanup sound detection
is_sound()
sleep(1)
if __name__ == "__main__":
try:
rest()
except KeyboardInterrupt:
my_dog.close()
2.2.7 Be Picked Up
Try lifting your PiDog from the ground, PiDog will feel like it can fly, and it will cheer in a superman pose.
Run the Code
cd /home/pi/pidog/examples
sudo python3 6_be_picked_up.py
After the program runs, the 6-DOF IMU Module will always calculate the acceleration in the vertical direction. If
PiDog is calculated to be in a state of weightlessness, PiDog assumes a superman pose and cheers. Otherwise, consider
PiDog to be on flat ground and make a standing pose.
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.
#!/usr/bin/env python3
from pidog import Pidog
from time import sleep
my_dog = Pidog()
sleep(0.1)
def delay(time):
my_dog.wait_legs_done()
sleep(time)
def fly():
my_dog.rgb_strip.set_mode('boom', front_color='red', delay=0.01)
my_dog.legs.servo_move([45, -45, 90, -80, 90, 90, -90, -90], speed=60)
(continues on next page)
56 Chapter 2. Play with Python

Related product manuals