Change shooter to function off of two pistons, remove punch, shooter motors, and...
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / OI.java
1 package org.usfirst.frc.team3501.robot;
2
3 import org.usfirst.frc.team3501.robot.commands.auton.CompactRobot;
4 import org.usfirst.frc.team3501.robot.commands.auton.PassChevalDeFrise;
5 import org.usfirst.frc.team3501.robot.commands.auton.PassDrawBridge;
6 import org.usfirst.frc.team3501.robot.commands.auton.PassPortcullis;
7 import org.usfirst.frc.team3501.robot.commands.auton.PassSallyPort;
8 import org.usfirst.frc.team3501.robot.commands.driving.Turn180;
9 import org.usfirst.frc.team3501.robot.commands.intakearm.IntakeBall;
10 import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArmToAngle;
11 import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift;
12 import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift;
13 import org.usfirst.frc.team3501.robot.commands.scaler.RunWinchContinuous;
14 import org.usfirst.frc.team3501.robot.commands.scaler.StopWinch;
15 import org.usfirst.frc.team3501.robot.commands.scaler.ToggleScaling;
16 import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
17 import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
18
19 import edu.wpi.first.wpilibj.DigitalInput;
20 import edu.wpi.first.wpilibj.Joystick;
21 import edu.wpi.first.wpilibj.buttons.Button;
22 import edu.wpi.first.wpilibj.buttons.JoystickButton;
23
24 public class OI {
25 public static Joystick leftJoystick;
26 public static Joystick rightJoystick;
27
28 // first column of arcade buttons - getting past defenses
29 public static DigitalButton passPortcullis;
30 public static DigitalButton passChevalDeFrise;
31 public static DigitalButton passDrawbridge;
32 public static DigitalButton passSallyPort;
33
34 // second column of arcade buttons - different angles for intake arm
35 // TO DO: change position numbers to angle values (?)
36 public static DigitalButton lowerChevalDeFrise;
37 public static DigitalButton moveToIntakeBoulder;
38 public static DigitalButton poiseAboveChevalDeFrise;
39 public static DigitalButton moveIntakeArmInsideRobot;
40
41 // left joystick buttons
42 public static Button toggleShooter;
43 public static Button SpinRobot180_1; // both do the same thing, just two
44 public static Button SpinRobot180_2; // different buttons
45 public static Button compactRobot_1;
46 public static Button compactRobot_2;
47
48 // right joystick buttons
49 public static Button intakeBoulder;
50 public static Button shootBoulder;
51
52 // button to change robot to the scaling mode
53 public static DigitalButton toggleScaling;
54
55 public OI() {
56 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
57 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
58
59 passPortcullis = new DigitalButton(new DigitalInput(
60 Constants.OI.PASS_PORTCULLIS_PORT));
61 passPortcullis.whenPressed(new PassPortcullis());
62
63 passChevalDeFrise = new DigitalButton(new DigitalInput(
64 Constants.OI.PASS_CHEVAL_DE_FRISE_PORT));
65 passChevalDeFrise.whenPressed(new PassChevalDeFrise());
66
67 passDrawbridge = new DigitalButton(new DigitalInput(
68 Constants.OI.PASS_DRAWBRIDGE_PORT));
69 passDrawbridge.whenPressed(new PassDrawBridge());
70
71 passSallyPort = new DigitalButton(new DigitalInput(
72 Constants.OI.PASS_SALLYPORT_PORT));
73 passSallyPort.whenPressed(new PassSallyPort());
74
75 lowerChevalDeFrise = new DigitalButton(new DigitalInput(
76 Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT));
77 lowerChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
78 IntakeArm.potAngles[0], IntakeArm.moveIntakeArmSpeed));
79
80 moveToIntakeBoulder = new DigitalButton(new DigitalInput(
81 Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT));
82 moveToIntakeBoulder.whenPressed(new MoveIntakeArmToAngle(
83 IntakeArm.potAngles[1], IntakeArm.moveIntakeArmSpeed));
84
85 poiseAboveChevalDeFrise = new DigitalButton(new DigitalInput(
86 Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT));
87 poiseAboveChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
88 IntakeArm.potAngles[2], IntakeArm.moveIntakeArmSpeed));
89
90 moveIntakeArmInsideRobot = new DigitalButton(new DigitalInput(
91 Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT));
92 moveIntakeArmInsideRobot.whenPressed(new MoveIntakeArmToAngle(
93 IntakeArm.potAngles[3], IntakeArm.moveIntakeArmSpeed));
94
95 toggleShooter = new JoystickButton(leftJoystick,
96 Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
97 SpinRobot180_1 = new JoystickButton(leftJoystick, Constants.OI.SPIN1_PORT);
98 SpinRobot180_1.whenPressed(new Turn180());
99
100 SpinRobot180_2 = new JoystickButton(leftJoystick, Constants.OI.SPIN2_PORT);
101 SpinRobot180_2.whenPressed(new Turn180());
102
103 compactRobot_1 = new JoystickButton(leftJoystick,
104 Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
105 compactRobot_2 = new JoystickButton(leftJoystick,
106 Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
107
108 intakeBoulder = new JoystickButton(rightJoystick,
109 Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT);
110 shootBoulder = new JoystickButton(rightJoystick,
111 Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
112
113 toggleScaling = new DigitalButton(new DigitalInput(
114 Constants.OI.TOGGLE_SCALING_PORT));
115 toggleScaling.whenPressed(new ToggleScaling());
116
117 if (!Constants.Scaler.SCALING) {
118 compactRobot_1.whenPressed(new CompactRobot());
119 compactRobot_2.whenPressed(new CompactRobot());
120
121 intakeBoulder.whenPressed(new IntakeBall());
122 shootBoulder.whenPressed(new Shoot());
123
124 } else {
125 // toggleShooter becomes winch
126 // compact robot button 1 and 2 retracts the lift
127 // intake button stops the winch
128 // shoot button extends the lift
129 toggleShooter.whenPressed(new RunWinchContinuous(
130 Constants.Scaler.SCALE_SPEED, Constants.Scaler.SECONDS_TO_SCALE));
131 compactRobot_1.whenPressed(new RetractLift());
132 compactRobot_2.whenPressed(new RetractLift());
133
134 intakeBoulder.whenReleased(new StopWinch());
135 shootBoulder.whenPressed(new ExtendLift());
136 }
137 }
138 }