Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. from gopigo import * #Has the basic functions for controlling the GoPiGo Robot
  2. import sys
  3. print("Press:\n\tw: Move GoPiGo Robot forward\n\ta: Turn GoPiGo Robot left\n\td: Turn GoPiGo Robot right\n\ts: Move GoPiGo Robot backward\n\tt: Increase speed\n\tg: Decrease speed\n\tx: Stop GoPiGo Robot\n\tz: Exit\n")
  4. # A loop for taking user commands and peform the action. Continue the same until user press z letter
  5. while True:
  6. print ("Enter the Command to perform the Action")
  7. a=raw_input() # Fetch the input from the terminal
  8. if a=='w':
  9. print("Moving forward")
  10. fwd() # Move forward
  11. elif a=='a':
  12. print("Turing Left")
  13. left() # Turn left
  14. elif a=='d':
  15. print("Turning Right")
  16. right() # Turn Right
  17. elif a=='s':
  18. print("Moving Back")
  19. bwd() # Move back
  20. elif a=='x':
  21. print("Stopping")
  22. stop() # Stop
  23. elif a=='t':
  24. increase_speed() # Increase speed
  25. elif a=='g':
  26. decrease_speed() # Decrease speed
  27. elif a=='z':
  28. sys.exit()
  29. else:
  30. print("Soory. Wrong Command, Please Enter Again")
  31. time.sleep(.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement