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