Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. from Robot import *
  2. from Path import *
  3. from math import *
  4. import json
  5.  
  6. robot = Robot()
  7.  
  8. # move the robot
  9. robot.setMotion(0.5, 0.5)
  10.  
  11. for i in range(10):
  12.     time.sleep(1)
  13.  
  14.  
  15. # load a path file
  16. #p = Path("Path-around-table.json")
  17. #path = p.getPath()
  18.  
  19. #Räkna ut robotens vinkel
  20. robotAngle = robot.getHeading(pose)
  21.  
  22. #koordinats position, lista av dictionaries
  23. coordinate_x = path[0]['X']
  24. coordinate_y = path[0]['Y']
  25.  
  26. #robotens position, returnerar två värden
  27. robot_x = robot.getPosition[0]
  28. robot_y = robot.getPosition[1]
  29.  
  30.  
  31. dx = robot_x - coordinate_x
  32. dy = robot_y - coordinate_y
  33. angle = atan2(dy, dx)
  34.  
  35. #räkna ut angle - getHeading (vinkel)
  36. angle-robotAngle
  37.  
  38.  
  39. for i in range(10):
  40.     time.sleep(0.5)
  41.     print("pos, heading")
  42.     print(robot.getPosition())
  43.     print(robot.getHeading())
  44.  
  45. echoes = robot.getLaser()
  46. print(echoes)
  47.  
  48. robot.setMotion(0.2, 0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement