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