Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. package first;
  2.  
  3. import edu.wpi.first.wpilibj.*;
  4.  
  5. public class ShooterMotor extends Motor {
  6. Joystick conformationJoy;
  7. Gyro gyro;
  8.  
  9. final int manualOverrideButtons = 9;
  10. final int restButton = 8;
  11.  
  12. boolean isManual = false;
  13. boolean isResting = false;
  14.  
  15. final double sensitivityRange = .01;
  16. final double maxAngle = 80;
  17. final double minAngle = 0;
  18.  
  19. public ShooterMotor(Jaguar duper, Joystick driveJoy, Joystick overrideJoy, Gyro g) {
  20. super(duper);
  21. theJoy = driveJoy;
  22. conformationJoy = overrideJoy;
  23. gyro = g;
  24. }
  25.  
  26. @Override public void run() {
  27. while (true) {
  28. if (!isManual && joy.getRawButton(manualOverrideButtons) && conformationJoy.getRawButton(manualOverrideButtons))
  29. isManual = true;
  30. else if (joy.getRawButton(manualOverrideButtons) || conformationJoy.getRawButton(manualOverrideButtons))
  31. isManual = false;
  32.  
  33. if (joy.getRawButton(restButton))
  34. isResting = !isResting;
  35.  
  36. if (isManual) {
  37. if (Math.toRadians(gyro.getAngle()) - 15 > confirmationJoy.getY()*2*Math.PI+sensitivityRange && gyro.getAngle() >= minAngle)
  38. theJag.set(-.2);
  39. else if (Math.toRadians(gyro.getAngle())-15 < confirmationJoy.getY()*2*Math.PI-sensitivityRange && gyro.getAngle() <= maxAngle)
  40. theJag.set(.2);
  41. else
  42. theJag.set(0);
  43. }
  44.  
  45. else if (isResting) {
  46. if (Math.toRadians(gyro.getAngle()) - 15 > 0 + sensitivityRange && gyro.getAngle() >= minAngle)
  47. theJag.set(-.2);
  48. else
  49. theJag.set(0);
  50. }
  51.  
  52. else if (Math.toRadians(gyro.getAngle()) - 15 > datClass.getElevation() + sensitivityRange && gyro.getAngle() >= minAngle)
  53. theJag.set(-.2);
  54. else if (Math.toRadians(gyro.getAngle()) - 15 < datClass.getElevation() - sensitivityRange && gyro.getAngle() <= maxAngle)
  55. theJag.set(.2);
  56. else
  57. theJag.set(0);
  58. }
  59. }
  60. }
Add Comment
Please, Sign In to add comment