Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
👉 Ready to explore and create with us? Click [here] and join today!
2. Leg Move
PiDog’s leg movements are implemented by the following functions.
Pidog.legs_move(target_angles, immediately=True, speed=50)
target_angles: It is a two-dimensional array composed of an array of 8 servo angles (referred to as angle group) as elements. These angle groups will be used to control the angles of the 8 foot servos. If multiple angle groups are written, the unexecuted angle groups will be stored in the cache.immediately: When calling the function, set this parameter toTrue, the cache will be cleared immediately to execute the newly written angle group; if the parameter is set toFalse, the newly written The incoming angular group is added to the execution queue.speed: The speed at which the angular group is executed.
Some common usages are listed below:
Take action immediately.
from pidog import Pidog
import time
my_dog = Pidog()
# half stand
my_dog.legs_move([[45, 10, -45, -10, 45, 10, -45, -10]], speed=50)
Add some angular groups to the execution queue.
from pidog import Pidog
import time
my_dog = Pidog()
# half stand
my_dog.legs_move([[45, 10, -45, -10, 45, 10, -45, -10]], speed=50)
# multiple actions
my_dog.legs_move([[45, 35, -45, -35, 80, 70, -80, -70],
[90, -30, -90, 30, 80, 70, -80, -70],
[45, 35, -45, -35, 80, 70, -80, -70]], immediately=False, speed=30)
Perform repetitions within 10 seconds.
from pidog import Pidog
import time
my_dog = Pidog()
# half stand
my_dog.legs_move([[45, 10, -45, -10, 45, 10, -45, -10]], speed=50)
# pushup preparation
my_dog.legs_move([[45, 35, -45, -35, 80, 70, -80, -70]], immediately=False, speed=20)
# pushup
for _ in range(99):
my_dog.legs_move([[90, -30, -90, 30, 80, 70, -80, -70],
[45, 35, -45, -35, 80, 70, -80, -70]], immediately=False, speed=30)
# keep 10s
time.sleep(10)
# stop and half stand
my_dog.legs_move([[45, 10, -45, -10, 45, 10, -45, -10]], immediately=True, speed=50)
PiDog’s leg control also has the following functions that can be used together:
Pidog.is_legs_done()
This function is used to determine whether the angle group in the cache has been executed. If yes, return True; otherwise, return False.
Pidog.wait_legs_done()
Suspends the program until the angle groups in the cache have been executed.
Pidog.legs_stop()
Empty the angular group in the cache.