Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package ca.mcgill.ecse211.project;
  2.  
  3. import static ca.mcgill.ecse211.project.Resources.*;
  4.  
  5. /**
  6. * This class is used to activate the launcher on the robot
  7. *
  8. * @author Alex Choi
  9. * @author Louca Dufault
  10. */
  11.  
  12. REEL_SPEED = slow;
  13. REEL_ACCELERATION = slow;
  14.  
  15. LOCK_SPEED = slow;
  16. LOCK_ACCELERATION = slow;
  17.  
  18. UNLOCK_SPEED = fast;
  19. UNLOCK_ACCELERATION = fast;
  20.  
  21.  
  22. public class Launcher {
  23.  
  24.  
  25. /**
  26. * Sets up the speeds and accelerations of the motors before beginning the launch
  27. */
  28. private static void setup() {
  29. reelMotor.setAcceleration(REEL_ACCELERATION);
  30. reelMotor.setSpeed(REEL_SPEED);
  31.  
  32. latchMotor.setAcceleration(LOCK_ACCELERATION);
  33. latchMotor.setSpeed(LOCK_SPEED);
  34.  
  35. //latchMotor.rotate(90, true); //rotate cw 90 deg, blocking unlock
  36. }
  37.  
  38. /**
  39. * Performs the launch maneuver of the launcher hardware.
  40. */
  41. public static void launch() {
  42. setup();
  43. reelMotor.rotate(180, false); //non-blocking
  44. Thread.sleep(500); //once it has sufficiently wound up
  45. latchMotor.rotate(-90, false); //lock
  46. latchMotor.stop(); // keep lock in place
  47.  
  48. reelMotor.rotate(-180, true); // unwind reel, blocking
  49.  
  50. latchMotor.setAcceleration(UNLOCK_ACCELERATION);
  51. latchMotor.setSpeed(UNLOCK_SPEED);
  52. latchMotor.rotate(90, true); //unlock, blocking
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement