SunFounder PiCrawler Kit
(continued from previous page)
show_info()
# quit
elif key == readchar.key.CTRL_C or key in readchar.key.ESCAPE_SEQUENCES:
print("\n Quit")
break
sleep(0.05)
if __name__ == "__main__":
main()
• current_step_all_leg_value() : Returns the coordinate values of all legs.
• do_single_leg(leg,coordinate,speed) : Modify the coordinate value of a certain leg individually.
3.13 Record New Step
We use the keyboard to control PiCrawler to make several poses in turn, and record these poses. Replay them later.
Run the Code
cd /home/pi/picrawler/examples
sudo python3 record_new_step_by_keyboard.py
After the code runs, please operate according to the prompt that pops up in the terminal.
• Press 1234 to select the feet separately, 1: right front foot, 2: left front foot, 3: left rear foot, 4: right rear foot
• Press w, a, s, d, r, and f to slowly control the PiCrawler’s coordinate values.
• Press space to print all coordinate values.
• Press p to have PiCrawler replay the recorded action.
• Press esc to exit.
Code
from picrawler import Picrawler
from time import sleep
import sys
import tty
import termios
import copy
crawler = Picrawler([10,11,12,4,5,6,1,2,3,7,8,9])
#crawler.set_offset([0,0,0,0,0,0,0,0,0,0,0,0])
speed = 80
def readchar():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
(continues on next page)
3.13. Record New Step 77