Advertisement
Guest User

fasdf

a guest
Jan 22nd, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Forrit:
  2.  
  3. // z grows as it drives forward, y>>0 is wincon (platform), edges are x=+-width/2
  4. let origin = [0,0,0]
  5. let initVel = [0,0,0]
  6.  
  7. let location = [x, y, z] // z is forward, y is vertical, x is width
  8. let velocity = [Vx, Vy, Vz]
  9. let direction = [Dx, Dy] // coupled to velocity is not needed for high logic
  10. let acceleration = [Ax, Ay, Az]
  11.  
  12. def length:
  13. sqrt(x*x+y*y+z*z)
  14.  
  15.  
  16. def loop:
  17. case ($LOCATION, $DIRECTION) of
  18. stone? -> getLost // may not be needed
  19. isLost -> courseAdjustment
  20. button -> Stop >>= releaseTrigger >>= Continue
  21. funnel -> Stop >>= pourWater >>= Continue
  22. wincon -> Stop;
  23. _ -> Continue
  24.  
  25. update >>= loop
  26.  
  27. stone?
  28. makes the robot turn to try and avoid the big stone. This function would override isLost until courseAdjustment would be needed again.
  29.  
  30. getLost
  31. Turn left basically, also makes sure not to turn too much.
  32.  
  33. Stop
  34. Stops the car for $arg mseconds or untill instructed to Continue
  35.  
  36. isLost
  37. Condition: Direction is not parallell to z (tolerates some discrepancy bounded by deltaX and deltaY from where discrepancy started).
  38.  
  39. courseAdjustment
  40. Makes the car drive parallel to z (straight forward).
  41.  
  42. button
  43. The location where the stop command should be sent so that it hits the button
  44.  
  45. releaseTrigger
  46. Release trigger
  47. suspend(time) // Wait for Water
  48.  
  49. funnel
  50. The location where the stop command should be sent so the water lands in the funnel.
  51.  
  52. pourWater
  53. moveStraw
  54. releaseWater.
  55. suspend(time) // Wait for Water
  56.  
  57. wincon
  58. When direction is perpendicular to y and the robot is high enough e.g.
  59. (Vy = 0) and (platform >= y > stone)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement