SunFounder PiDog Kit, Release 1.0
(continued from previous page)
print(f"legs buffer length (5s): {len(my_dog.legs_action_buffer)}")
# stop action & show buffer length
my_dog.stop_and_lie()
print(f"legs buffer length (stop): {len(my_dog.legs_action_buffer)}")
except KeyboardInterrupt:
pass
except Exception as e:
print(f"\033[31mERROR: {e}\033[m")
finally:
print("closing ...")
my_dog.close() # close all the servo threads
2.3.6 Do Preset Action
Some commonly used actions have been pre-written in PiDog’s library. You can call the following function to make
PiDog do these actions directly.
Pidog.do_action(action_name, step_count=1, speed=50)
• action_name : Action name, the following strings can be written.
– "sit"
– "half_sit"
– "stand"
– "lie"
– "lie_with_hands_out"
– "forward"
– "backward"
– "turn_left"
– "turn_right"
– "trot"
– "stretch"
– "pushup"
– "doze_off"
– "nod_lethargy"
– "shake_head"
– "tilting_head_left"
– "tilting_head_right"
– "tilting_head"
– "head_bark"
– "head_up_down"
2.3. Easy Coding 81