EasyManua.ls Logo

SunFounder PiCrawler Kit - Page 83

Default Icon
137 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 PiCrawler Kit
(continued from previous page)
leg=0
coodinate=crawler.current_step_leg_value(leg)
elif '2' == key:
leg=1
coodinate=crawler.current_step_leg_value(leg)
elif '3' == key:
leg=2
coodinate=crawler.current_step_leg_value(leg)
elif '4' == key:
leg=3
coodinate=crawler.current_step_leg_value(leg)
elif chr(32) == key:
print("[[right front],[left front],[left rear],[right rear]]")
print("saved new step")
print(crawler.current_step_all_leg_value())
save_new_step()
elif 'p' == key:
play_all_new_step()
elif chr(27) == key:# 27 for ESC
break
sleep(0.05)
crawler.do_single_leg(leg,coodinate,speed)
print("\n q Quit")
if __name__ == "__main__":
main()
How it works?
This project was born out of Adjust Posture. Added recording and replay functions.
The recording function is implemented by the following code.
new_step=[]
def save_new_step():
new_step.append(copy.deepcopy(crawler.current_step_all_leg_value()))
print(new_step)
Note: The assignment here needs to use the Deep Copy function, otherwise the new_step will not get a new array
object when appending.
The replay function is implemented by the following code.
def play_all_new_step():
for step in new_step:
crawler.do_step(step,speed)
sleep(0.6)
3.13. Record New Step 79

Other manuals for SunFounder PiCrawler Kit

Related product manuals