EasyManua.ls Logo

SunFounder PiDog - Page 66

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
#!/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

Related product manuals