create commandGroup passportcullis (that will use both liftPortcullis and drive forwa...
[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.PassChevalDeFrise;
4 import org.usfirst.frc.team3501.robot.commands.auton.PassDrawBridge;
5 import org.usfirst.frc.team3501.robot.commands.auton.PassPortcullis;
6 import org.usfirst.frc.team3501.robot.commands.auton.PassSallyPort;
7 import org.usfirst.frc.team3501.robot.commands.intakearm.IntakeBall;
8 import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift;
9 import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift;
10 import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
11 import org.usfirst.frc.team3501.robot.commands.shooter.runShooter;
12
13 import edu.wpi.first.wpilibj.DigitalInput;
14 import edu.wpi.first.wpilibj.Joystick;
15 import edu.wpi.first.wpilibj.buttons.Button;
16 import edu.wpi.first.wpilibj.buttons.JoystickButton;
17 import edu.wpi.first.wpilibj.command.Scheduler;
18
19 public class OI {
20 public static boolean isScalingMode = false;
21 public static boolean isCompactRobot = false;
22
23 public static Joystick leftJoystick;
24 public static Joystick rightJoystick;
25
26 // first column of arcade buttons - getting past defenses
27 public static DigitalButton passPortcullis;
28 public static DigitalButton passChevalDeFrise;
29 public static DigitalButton passDrawbridge;
30 public static DigitalButton passSallyPort;
31
32 // second column of arcade buttons - different angles for intake arm
33 // TO DO: change position numbers to angle values (?)
34 public static DigitalButton lowerChevalDeFrise;
35 public static DigitalButton moveToIntakeBoulder;
36 public static DigitalButton poiseAboveChevalDeFrise;
37 public static DigitalButton moveIntakeArmInsideRobot;
38
39 // left joystick buttons
40 public static Button toggleShooter;
41 public static Button SpinRobot180_1; // both do the same thing, just two
42 public static Button SpinRobot180_2; // different buttons
43 public static Button compactRobot_1;
44 public static Button compactRobot_2;
45
46 // right joystick buttons
47 public static Button intakeBoulder;
48 public static Button shootBoulder;
49
50 // button to change robot to the scaling mode
51 public static DigitalButton toggleScalingMode;
52
53 public OI() {
54 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
55 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
56
57 passPortcullis = new DigitalButton(
58 new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
59 passChevalDeFrise = new DigitalButton(
60 new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT));
61 passDrawbridge = new DigitalButton(
62 new DigitalInput(Constants.OI.PASS_DRAWBRIDGE));
63 passSallyPort = new DigitalButton(
64 new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT));
65
66 lowerChevalDeFrise = new DigitalButton(
67 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT));
68 moveToIntakeBoulder = new DigitalButton(
69 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT));
70 poiseAboveChevalDeFrise = new DigitalButton(
71 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT));
72 moveIntakeArmInsideRobot = new DigitalButton(
73 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT));
74
75 toggleShooter = new JoystickButton(leftJoystick,
76 Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
77 SpinRobot180_1 = new JoystickButton(leftJoystick,
78 Constants.OI.LEFT_JOYSTICK_TOP_LEFT_PORT);
79 SpinRobot180_2 = new JoystickButton(leftJoystick,
80 Constants.OI.LEFT_JOYSTICK_TOP_RIGHT_PORT);
81 compactRobot_1 = new JoystickButton(leftJoystick,
82 Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
83 compactRobot_2 = new JoystickButton(leftJoystick,
84 Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
85
86 intakeBoulder = new JoystickButton(rightJoystick,
87 Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT);
88 shootBoulder = new JoystickButton(rightJoystick,
89 Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
90
91 toggleScalingMode = new DigitalButton(
92 new DigitalInput(Constants.OI.SCALING_BUTTON_PORT));
93
94 passPortcullis.whenPressed(new PassPortcullis());
95 passChevalDeFrise.whenPressed(new PassChevalDeFrise());
96 passDrawbridge.whenPressed(new PassDrawBridge());
97 passSallyPort.whenPressed(new PassSallyPort());
98
99 lowerChevalDeFrise
100 .whenPressed(/* TO DO: define this, and fill in commands */);
101
102 if (toggleScalingMode.get()) {
103 if (!isScalingMode) {
104 isScalingMode = true;
105 if (!isCompactRobot) {
106 Scheduler.getInstance().add(new CompactRobot());
107 isCompactRobot = true;
108 }
109 } else if (isScalingMode) {
110 isScalingMode = false;
111 Scheduler.getInstance().add(new CompactRobot());
112 }
113 }
114
115 if (!isScalingMode) {
116 toggleShooter.toggleWhenPressed(new runShooter());
117 compactRobot_1.whenPressed(new CompactRobot());
118
119 intakeBoulder.whenPressed(new IntakeBall());
120 shootBoulder.whenPressed(new Shoot());
121
122 } else if (isScalingMode) {
123 toggleShooter.toggleWhenPressed(new WinchIn());
124 compactRobot_1.whenPressed(new RetractLift());
125
126 intakeBoulder.toggleWhenPressed(new WinchOut());
127 shootBoulder.whenPressed(new ExtendLift());
128 }
129
130 SpinRobot180_1
131 .whenPressed(/* rotate robot 180, reorient joystick controls */);
132
133 }
134 }