88package org .usfirst .frc .team199 .Robot2018 ;
99
1010import org .usfirst .frc .team199 .Robot2018 .commands .CloseIntake ;
11+ import org .usfirst .frc .team199 .Robot2018 .commands .FindTurnTimeConstant ;
1112import org .usfirst .frc .team199 .Robot2018 .commands .IntakeCube ;
1213import org .usfirst .frc .team199 .Robot2018 .commands .OpenIntake ;
13- import org .usfirst .frc .team199 .Robot2018 .commands .OutakeCube ;
14+ import org .usfirst .frc .team199 .Robot2018 .commands .OuttakeCube ;
1415import org .usfirst .frc .team199 .Robot2018 .commands .PIDMove ;
1516import org .usfirst .frc .team199 .Robot2018 .commands .PIDTurn ;
1617import org .usfirst .frc .team199 .Robot2018 .commands .ResetEncoders ;
@@ -38,26 +39,28 @@ public class OI {
3839 */
3940
4041 public Joystick leftJoy ;
42+ public Joystick rightJoy ;
4143 private JoystickButton shiftLowGearButton ;
4244 private JoystickButton shiftHighGearButton ;
4345 private JoystickButton shiftDriveTypeButton ;
44- private JoystickButton PIDMoveButton ;
45- private JoystickButton PIDTurnButton ;
46+ private JoystickButton pIDMoveButton ;
47+ private JoystickButton pIDTurnButton ;
4648 private JoystickButton resetEncButton ;
47- private JoystickButton MoveLiftUpButton ;
48- private JoystickButton MoveLiftDownButton ;
49- public Joystick rightJoy ;
49+ private JoystickButton moveLiftUpButton ;
50+ private JoystickButton moveLiftDownButton ;
51+ private JoystickButton findTurnTimeConstantButton ;
5052 private JoystickButton updatePIDConstantsButton ;
5153 private JoystickButton updateEncoderDPPButton ;
54+
5255 public Joystick manipulator ;
53- private JoystickButton closeIntake ;
54- private JoystickButton openIntake ;
55- private JoystickButton raiseIntake ;
56- private JoystickButton lowerIntake ;
57- private JoystickButton intake ;
58- private JoystickButton outake ;
59- private JoystickButton toggleLeftIntake ;
60- private JoystickButton toggleRightIntake ;
56+ private JoystickButton closeIntakeButton ;
57+ private JoystickButton openIntakeButton ;
58+ private JoystickButton raiseIntakeButton ;
59+ private JoystickButton lowerIntakeButton ;
60+ private JoystickButton intakeCubeButton ;
61+ private JoystickButton outakeCubeButton ;
62+ private JoystickButton toggleLeftIntakeButton ;
63+ private JoystickButton toggleRightIntakeButton ;
6164
6265 public int getButton (String key , int def ) {
6366 if (!SmartDashboard .containsKey ("Button/" + key )) {
@@ -69,20 +72,24 @@ public int getButton(String key, int def) {
6972 return (int ) SmartDashboard .getNumber ("Button/" + key , def );
7073 }
7174
72- public OI () {
75+ public OI (Robot robot ) {
7376 leftJoy = new Joystick (0 );
7477 shiftDriveTypeButton = new JoystickButton (leftJoy , getButton ("Shift Drive Type" , 2 ));
7578 shiftDriveTypeButton .whenPressed (new ShiftDriveType ());
76- PIDMoveButton = new JoystickButton (leftJoy , getButton ("PID Move" , 7 ));
77- PIDMoveButton
79+ pIDMoveButton = new JoystickButton (leftJoy , getButton ("PID Move" , 7 ));
80+ pIDMoveButton
7881 .whenPressed (new PIDMove (Robot .sd .getConst ("Move Targ" , 24 ), Robot .dt , Robot .sd , RobotMap .distEncAvg ));
79- PIDTurnButton = new JoystickButton (leftJoy , getButton ("PID Turn" , 8 ));
82+ pIDTurnButton = new JoystickButton (leftJoy , getButton ("PID Turn" , 8 ));
8083 // PIDTurnButton.whenPressed(new PIDTurn(Robot.getConst("Turn Targ", 90),
8184 // Robot.dt, Robot.sd RobotMap.fancyGyro));
82- PIDTurnButton
85+ pIDTurnButton
8386 .whenReleased (new PIDTurn (Robot .getConst ("Turn Targ" , 90 ), Robot .dt , Robot .sd , RobotMap .fancyGyro ));
8487 resetEncButton = new JoystickButton (leftJoy , getButton ("Reset Dist Enc" , 10 ));
8588 resetEncButton .whenPressed (new ResetEncoders ());
89+ findTurnTimeConstantButton = new JoystickButton (leftJoy , getButton ("Find Turn Time Constant" , 11 ));
90+ // the command will only run in test mode
91+ findTurnTimeConstantButton
92+ .whenPressed (new FindTurnTimeConstant (robot , Robot .dt , Robot .rmap .fancyGyro , Robot .sd ));
8693
8794 rightJoy = new Joystick (1 );
8895 shiftHighGearButton = new JoystickButton (rightJoy , getButton ("Shift High Gear" , 3 ));
@@ -93,30 +100,34 @@ public OI() {
93100 updatePIDConstantsButton .whenPressed (new UpdatePIDConstants ());
94101 updateEncoderDPPButton = new JoystickButton (rightJoy , getButton ("Get Encoder Dist Per Pulse" , 9 ));
95102 updateEncoderDPPButton .whenPressed (new SetDistancePerPulse ());
96- MoveLiftUpButton = new JoystickButton (rightJoy , getButton ("Run Lift Motor Up" , 10 ));
97- MoveLiftDownButton = new JoystickButton (rightJoy , getButton ("Run Lift Motor Down" , 11 ));
98- MoveLiftUpButton .whileHeld (new RunLift (Robot .lift , true ));
99- MoveLiftDownButton .whileHeld (new RunLift (Robot .lift , false ));
103+ moveLiftUpButton = new JoystickButton (rightJoy , getButton ("Run Lift Motor Up" , 10 ));
104+ moveLiftDownButton = new JoystickButton (rightJoy , getButton ("Run Lift Motor Down" , 11 ));
105+ moveLiftUpButton .whileHeld (new RunLift (Robot .lift , true ));
106+ moveLiftDownButton .whileHeld (new RunLift (Robot .lift , false ));
100107
101108 manipulator = new Joystick (2 );
102- closeIntake = new JoystickButton (manipulator , getButton ("Close Intake Button" , 1 ));
103- closeIntake .whenPressed (new CloseIntake ());
104- openIntake = new JoystickButton (manipulator , getButton ("Open Intake Button" , 2 ));
105- openIntake .whenPressed (new OpenIntake ());
106- // raiseIntake = new JoystickButton(manipulator, getButton("Raise Intake
107- // Button", 3));
108- // raiseIntake.whenPressed(new RaiseIntake());
109- // lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake
110- // Button", 4));
111- // lowerIntake.whenPressed(new LowerIntake());
112- intake = new JoystickButton (manipulator , getButton ("Intake Button" , 5 ));
113- intake .whenPressed (new IntakeCube ());
114- outake = new JoystickButton (manipulator , getButton ("Outake Button" , 6 ));
115- outake .whenPressed (new OutakeCube ());
116- toggleLeftIntake = new JoystickButton (manipulator , getButton ("Toggle Left Intake Button" , 3 ));
117- toggleLeftIntake .whenPressed (new ToggleLeftIntake ());
118- toggleRightIntake = new JoystickButton (manipulator , getButton ("Toggle Right Intake Button" , 4 ));
119- toggleRightIntake .whenPressed (new ToggleRightIntake ());
109+ if (manipulator .getButtonCount () == 0 ) {
110+ System .out .println ("Manipulator not plugged in!" );
111+ } else {
112+ closeIntakeButton = new JoystickButton (manipulator , getButton ("Close Intake Button" , 1 ));
113+ closeIntakeButton .whenPressed (new CloseIntake ());
114+ openIntakeButton = new JoystickButton (manipulator , getButton ("Open Intake Button" , 2 ));
115+ openIntakeButton .whenPressed (new OpenIntake ());
116+ // raiseIntake = new JoystickButton(manipulator, getButton("Raise Intake
117+ // Button", 3));
118+ // raiseIntake.whenPressed(new RaiseIntake());
119+ // lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake
120+ // Button", 4));
121+ // lowerIntake.whenPressed(new LowerIntake());
122+ intakeCubeButton = new JoystickButton (manipulator , getButton ("Intake Button" , 5 ));
123+ intakeCubeButton .whenPressed (new IntakeCube ());
124+ outakeCubeButton = new JoystickButton (manipulator , getButton ("Outake Button" , 6 ));
125+ outakeCubeButton .whenPressed (new OuttakeCube ());
126+ toggleLeftIntakeButton = new JoystickButton (manipulator , getButton ("Toggle Left Intake Button" , 3 ));
127+ toggleLeftIntakeButton .whenPressed (new ToggleLeftIntake ());
128+ toggleRightIntakeButton = new JoystickButton (manipulator , getButton ("Toggle Right Intake Button" , 4 ));
129+ toggleRightIntakeButton .whenPressed (new ToggleRightIntake ());
130+ }
120131 }
121132
122133 // /**
0 commit comments