Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. output of below code
  2.  
  3. current position in degrees: 319
  4. move this many talon units: 484, to get to 130 degrees
  5. checking new position is at 130, 130
  6.  
  7.  
  8. -----------------------
  9.  
  10. def get_position_degrees(talon_units):
  11. # will handle 0 to 1023 or more
  12. degrees = ((talon_units % 1023) * 360) / 1023
  13. return degrees
  14.  
  15.  
  16. def move_talon_units(degrees, current_talon_units):
  17. new_position = degrees * 1023 / 360
  18. # you only use these next two lines if talon_units exceed 1023 otherwise you return new_units
  19. current_position = current_talon_units % 1023
  20. units = (1023 - current_position) + new_position
  21. return units
  22.  
  23.  
  24. talon_units = 5000
  25. print("current position in degrees: %d" % get_position_degrees(talon_units))
  26.  
  27. new_position_in_degrees = 130
  28. additional_talon_units = move_talon_units(new_position_in_degrees, talon_units)
  29.  
  30. print("move this many talon units: %d, to get to %d degrees" %
  31. (
  32. additional_talon_units,
  33. new_position_in_degrees
  34. ))
  35.  
  36.  
  37. new_talon_units = talon_units + additional_talon_units
  38.  
  39. print("checking new position is at %d, %d"%
  40. (
  41. new_position_in_degrees,
  42. get_position_degrees(new_talon_units)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement