add commands to digital buttons in OI and create/edit necessary commands
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / OI.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
54c588d9 3import org.usfirst.frc.team3501.robot.commands.auton.CompactRobot;
6b06b2bc
CZ
4import org.usfirst.frc.team3501.robot.commands.auton.PassChevalDeFrise;
5import org.usfirst.frc.team3501.robot.commands.auton.PassDrawBridge;
8a3090b5 6import org.usfirst.frc.team3501.robot.commands.auton.PassPortcullis;
6b06b2bc 7import org.usfirst.frc.team3501.robot.commands.auton.PassSallyPort;
54c588d9 8import org.usfirst.frc.team3501.robot.commands.driving.Turn180;
6b06b2bc 9import org.usfirst.frc.team3501.robot.commands.intakearm.IntakeBall;
54c588d9 10import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArmToAngle;
6b06b2bc
CZ
11import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift;
12import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift;
1bfa24f2
CZ
13import org.usfirst.frc.team3501.robot.commands.scaler.RunWinchContinuous;
14import org.usfirst.frc.team3501.robot.commands.scaler.StopWinch;
6b06b2bc
CZ
15import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
16import org.usfirst.frc.team3501.robot.commands.shooter.runShooter;
54c588d9 17import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
37e5a121 18
6b06b2bc 19import edu.wpi.first.wpilibj.DigitalInput;
38a404b3 20import edu.wpi.first.wpilibj.Joystick;
cb3389eb
E
21import edu.wpi.first.wpilibj.buttons.Button;
22import edu.wpi.first.wpilibj.buttons.JoystickButton;
6b06b2bc 23import edu.wpi.first.wpilibj.command.Scheduler;
38a404b3
KZ
24
25public class OI {
6b06b2bc
CZ
26 public static boolean isScalingMode = false;
27 public static boolean isCompactRobot = false;
28
38a404b3
KZ
29 public static Joystick leftJoystick;
30 public static Joystick rightJoystick;
6b06b2bc
CZ
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 toggleScalingMode;
38a404b3
KZ
58
59 public OI() {
60 leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT);
61 rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT);
62
6b06b2bc
CZ
63 passPortcullis = new DigitalButton(
64 new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT));
65 passChevalDeFrise = new DigitalButton(
66 new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT));
67 passDrawbridge = new DigitalButton(
68 new DigitalInput(Constants.OI.PASS_DRAWBRIDGE));
69 passSallyPort = new DigitalButton(
70 new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT));
71
72 lowerChevalDeFrise = new DigitalButton(
73 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT));
74 moveToIntakeBoulder = new DigitalButton(
75 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT));
76 poiseAboveChevalDeFrise = new DigitalButton(
77 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT));
78 moveIntakeArmInsideRobot = new DigitalButton(
79 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT));
80
81 toggleShooter = new JoystickButton(leftJoystick,
82 Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
83 SpinRobot180_1 = new JoystickButton(leftJoystick,
84 Constants.OI.LEFT_JOYSTICK_TOP_LEFT_PORT);
85 SpinRobot180_2 = new JoystickButton(leftJoystick,
86 Constants.OI.LEFT_JOYSTICK_TOP_RIGHT_PORT);
87 compactRobot_1 = new JoystickButton(leftJoystick,
88 Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
89 compactRobot_2 = new JoystickButton(leftJoystick,
90 Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
91
92 intakeBoulder = new JoystickButton(rightJoystick,
93 Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT);
94 shootBoulder = new JoystickButton(rightJoystick,
95 Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
96
97 toggleScalingMode = new DigitalButton(
98 new DigitalInput(Constants.OI.SCALING_BUTTON_PORT));
99
100 passPortcullis.whenPressed(new PassPortcullis());
101 passChevalDeFrise.whenPressed(new PassChevalDeFrise());
102 passDrawbridge.whenPressed(new PassDrawBridge());
103 passSallyPort.whenPressed(new PassSallyPort());
104
54c588d9
CZ
105 lowerChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
106 IntakeArm.potAngles[0], IntakeArm.moveIntakeArmSpeed));
107 moveToIntakeBoulder.whenPressed(new MoveIntakeArmToAngle(
108 IntakeArm.potAngles[1], IntakeArm.moveIntakeArmSpeed));
109 poiseAboveChevalDeFrise.whenPressed(new MoveIntakeArmToAngle(
110 IntakeArm.potAngles[2], IntakeArm.moveIntakeArmSpeed));
111 moveIntakeArmInsideRobot.whenPressed(new MoveIntakeArmToAngle(
112 IntakeArm.potAngles[3], IntakeArm.moveIntakeArmSpeed));
6b06b2bc
CZ
113
114 if (toggleScalingMode.get()) {
115 if (!isScalingMode) {
116 isScalingMode = true;
117 if (!isCompactRobot) {
118 Scheduler.getInstance().add(new CompactRobot());
119 isCompactRobot = true;
120 }
121 } else if (isScalingMode) {
122 isScalingMode = false;
123 Scheduler.getInstance().add(new CompactRobot());
124 }
125 }
126
127 if (!isScalingMode) {
128 toggleShooter.toggleWhenPressed(new runShooter());
129 compactRobot_1.whenPressed(new CompactRobot());
54c588d9 130 compactRobot_2.whenPressed(new CompactRobot());
6b06b2bc
CZ
131
132 intakeBoulder.whenPressed(new IntakeBall());
133 shootBoulder.whenPressed(new Shoot());
cb3389eb 134
6b06b2bc 135 } else if (isScalingMode) {
1bfa24f2
CZ
136 toggleShooter.whenPressed(new RunWinchContinuous(
137 Constants.Scaler.WINCH_IN_SPEED));
6b06b2bc 138 compactRobot_1.whenPressed(new RetractLift());
54c588d9 139 compactRobot_2.whenPressed(new RetractLift());
7a949394 140
1bfa24f2 141 intakeBoulder.whenReleased(new StopWinch());
6b06b2bc
CZ
142 shootBoulder.whenPressed(new ExtendLift());
143 }
8a394843 144
54c588d9
CZ
145 SpinRobot180_1.whenPressed(new Turn180());
146 SpinRobot180_2.whenPressed(new Turn180());
38a404b3
KZ
147 }
148}