make extend and retract intake arm piston methods and a command
[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.scaler.ExtendLift;
11 import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift;
12 import org.usfirst.frc.team3501.robot.commands.scaler.RunWinchContinuous;
13 import org.usfirst.frc.team3501.robot.commands.scaler.StopWinch;
14 import org.usfirst.frc.team3501.robot.commands.scaler.ToggleScaling;
15 import org.usfirst.frc.team3501.robot.commands.shooter.Shoot;
16
17 import edu.wpi.first.wpilibj.DigitalInput;
18 import edu.wpi.first.wpilibj.Joystick;
19 import edu.wpi.first.wpilibj.buttons.Button;
20 import edu.wpi.first.wpilibj.buttons.JoystickButton;
21
22 public class OI {
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 toggleScaling;
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 passPortcullis.whenPressed(new PassPortcullis());
60
61 passChevalDeFrise = new DigitalButton(
62 new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT));
63 passChevalDeFrise.whenPressed(new PassChevalDeFrise());
64
65 passDrawbridge = new DigitalButton(
66 new DigitalInput(Constants.OI.PASS_DRAWBRIDGE_PORT));
67 passDrawbridge.whenPressed(new PassDrawBridge());
68
69 passSallyPort = new DigitalButton(
70 new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT));
71 passSallyPort.whenPressed(new PassSallyPort());
72
73 moveToIntakeBoulder = new DigitalButton(
74 new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT));
75
76 toggleShooter = new JoystickButton(leftJoystick,
77 Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT);
78 SpinRobot180_1 = new JoystickButton(leftJoystick, Constants.OI.SPIN1_PORT);
79 SpinRobot180_1.whenPressed(new Turn180());
80
81 SpinRobot180_2 = new JoystickButton(leftJoystick, Constants.OI.SPIN2_PORT);
82 SpinRobot180_2.whenPressed(new Turn180());
83
84 compactRobot_1 = new JoystickButton(leftJoystick,
85 Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT);
86 compactRobot_2 = new JoystickButton(leftJoystick,
87 Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT);
88
89 intakeBoulder = new JoystickButton(rightJoystick,
90 Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT);
91 shootBoulder = new JoystickButton(rightJoystick,
92 Constants.OI.RIGHT_JOYSTICK_THUMB_PORT);
93
94 toggleScaling = new DigitalButton(
95 new DigitalInput(Constants.OI.TOGGLE_SCALING_PORT));
96 toggleScaling.whenPressed(new ToggleScaling());
97
98 if (!Constants.Scaler.SCALING) {
99 compactRobot_1.whenPressed(new CompactRobot());
100 compactRobot_2.whenPressed(new CompactRobot());
101
102 intakeBoulder.whenPressed(new IntakeBall());
103 shootBoulder.whenPressed(new Shoot());
104
105 } else {
106 // toggleShooter becomes winch
107 // compact robot button 1 and 2 retracts the lift
108 // intake button stops the winch
109 // shoot button extends the lift
110 toggleShooter.whenPressed(new RunWinchContinuous(
111 Constants.Scaler.SCALE_SPEED, Constants.Scaler.SECONDS_TO_SCALE));
112 compactRobot_1.whenPressed(new RetractLift());
113 compactRobot_2.whenPressed(new RetractLift());
114
115 intakeBoulder.whenReleased(new StopWinch());
116 shootBoulder.whenPressed(new ExtendLift());
117 }
118 }
119 }