Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. while True:
  2. balls = bot.get_balls()
  3. position = bot.get_position()
  4. ball = balls[3]
  5.  
  6. #ball_angle = math.atan2(ball[1] - position[1], ball[0] - position[0])
  7. ball_angle = math.atan2(ball[1] - position[1], ball[0] - position[0])
  8. ball_angle = math.degrees(ball_angle)
  9. ball_angle = round(ball_angle, 1)
  10.  
  11.  
  12. angle = round(position[2], 1)
  13.  
  14. print("ball: ", ball_angle, "angle: ", angle)
  15. if angle != ball_angle and angle != ball_angle - 0.1 and angle != ball_angle + 0.1 and not found:
  16. #bot.set_motors(0.01, 0.01)
  17. bot.set_motors(0.01, -0.01)
  18. else:
  19. #print("==")
  20. found = True
  21. bot.set_motors(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement