88package org .usfirst .frc .team199 .Robot2018 ;
99
1010import org .usfirst .frc .team199 .Robot2018 .autonomous .PIDSourceAverage ;
11+ import org .usfirst .frc .team199 .Robot2018 .autonomous .TalonVelocityController ;
1112import org .usfirst .frc .team199 .Robot2018 .autonomous .VelocityPIDController ;
1213
1314import com .ctre .phoenix .motorcontrol .can .WPI_TalonSRX ;
@@ -44,6 +45,7 @@ public class RobotMap {
4445 public static WPI_VictorSPX dtLeftSlave ;
4546 public static SpeedControllerGroup dtLeft ;
4647 public static VelocityPIDController leftVelocityController ;
48+ public static TalonVelocityController leftTalVelController ;
4749
4850 public static DigitalSource rightEncPort1 ;
4951 public static DigitalSource rightEncPort2 ;
@@ -53,6 +55,7 @@ public class RobotMap {
5355 public static WPI_VictorSPX dtRightSlave ;
5456 public static SpeedControllerGroup dtRight ;
5557 public static VelocityPIDController rightVelocityController ;
58+ public static TalonVelocityController rightTalVelController ;
5659
5760 public static DifferentialDrive robotDrive ;
5861 public static PIDSourceAverage distEncAvg ;
@@ -121,15 +124,17 @@ public RobotMap() {
121124 configSPX (dtLeftSlave );
122125 dtLeft = new SpeedControllerGroup (dtLeftMaster , dtLeftSlave );
123126
124- leftVelocityController = new VelocityPIDController (Robot .getConst ("VelocityLeftkP" , 1 ),
125- Robot .getConst ("VelocityLeftkI" , 0 ), Robot .getConst ("VelocityLeftkD" , 0 ),
126- 1 / Robot .getConst ("Max Low Speed" , 84 ), leftEncRate , dtLeft );
127- leftVelocityController .enable ();
128- leftVelocityController .setInputRange (-Robot .getConst ("Max High Speed" , 204 ),
129- Robot .getConst ("Max High Speed" , 204 ));
130- leftVelocityController .setOutputRange (-1.0 , 1.0 );
131- leftVelocityController .setContinuous (false );
132- leftVelocityController .setAbsoluteTolerance (Robot .getConst ("VelocityToleranceLeft" , 2 ));
127+ // leftVelocityController = new
128+ // VelocityPIDController(Robot.getConst("VelocityLeftkP", 1),
129+ // Robot.getConst("VelocityLeftkI", 0), Robot.getConst("VelocityLeftkD", 0),
130+ // 1 / Robot.getConst("Max Low Speed", 84), leftEncRate, dtLeft);
131+ // leftVelocityController.enable();
132+ // leftVelocityController.setInputRange(-Robot.getConst("Max High Speed", 204),
133+ // Robot.getConst("Max High Speed", 204));
134+ // leftVelocityController.setOutputRange(-1.0, 1.0);
135+ // leftVelocityController.setContinuous(false);
136+ // leftVelocityController.setAbsoluteTolerance(Robot.getConst("VelocityToleranceLeft",
137+ // 2));
133138
134139 rightEncPort1 = new DigitalInput (getPort ("1RightEnc" , 2 ));
135140 rightEncPort2 = new DigitalInput (getPort ("2RightEnc" , 3 ));
@@ -143,17 +148,54 @@ public RobotMap() {
143148 configSPX (dtRightSlave );
144149 dtRight = new SpeedControllerGroup (dtRightMaster , dtRightSlave );
145150
146- rightVelocityController = new VelocityPIDController (Robot .getConst ("VelocityRightkP" , 1 ),
147- Robot .getConst ("VelocityRightkI" , 0 ), Robot .getConst ("VelocityRightkD" , 0 ),
148- 1 / Robot .getConst ("Max Low Speed" , 84 ), rightEncRate , dtRight );
149- rightVelocityController .enable ();
150- rightVelocityController .setInputRange (-Robot .getConst ("Max High Speed" , 204 ),
151- Robot .getConst ("Max High Speed" , 204 ));
152- rightVelocityController .setOutputRange (-1.0 , 1.0 );
153- rightVelocityController .setContinuous (false );
154- rightVelocityController .setAbsoluteTolerance (Robot .getConst ("VelocityToleranceRight" , 2 ));
155-
156- robotDrive = new DifferentialDrive (leftVelocityController , rightVelocityController );
151+ // rightVelocityController = new
152+ // VelocityPIDController(Robot.getConst("VelocityRightkP", 1),
153+ // Robot.getConst("VelocityRightkI", 0), Robot.getConst("VelocityRightkD", 0),
154+ // 1 / Robot.getConst("Max Low Speed", 84), rightEncRate, dtRight);
155+ // rightVelocityController.enable();
156+ // rightVelocityController.setInputRange(-Robot.getConst("Max High Speed", 204),
157+ // Robot.getConst("Max High Speed", 204));
158+ // rightVelocityController.setOutputRange(-1.0, 1.0);
159+ // rightVelocityController.setContinuous(false);
160+ // rightVelocityController.setAbsoluteTolerance(Robot.getConst("VelocityToleranceRight",
161+ // 2));
162+ //
163+ // robotDrive = new DifferentialDrive(leftVelocityController,
164+ // rightVelocityController);
165+ // robotDrive.setMaxOutput(Robot.getConst("Max High Speed", 204));
166+
167+ if (!Robot .getBool ("Talon PID" , false )) {
168+ leftVelocityController = new VelocityPIDController (Robot .getConst ("VelocityLeftkI" , 0 ),
169+ /* Robot.getConst("VelocityLeftkD", 0) */ 0 , Robot .getConst ("VelocityLeftkP" , 0 ),
170+ 1 / Robot .getConst ("Max Low Speed" , 84 ), leftEncRate , dtLeft );
171+ leftVelocityController .setInputRange (-Robot .getConst ("Max High Speed" , 204 ),
172+ Robot .getConst ("Max High Speed" , 204 ));
173+ leftVelocityController .setOutputRange (-1.0 , 1.0 );
174+ leftVelocityController .setContinuous (false );
175+ leftVelocityController .setAbsoluteTolerance (Robot .getConst ("VelocityToleranceLeft" , 2 ));
176+
177+ rightVelocityController = new VelocityPIDController (Robot .getConst ("VelocityRightkI" , 0 ),
178+ /* Robot.getConst("VelocityRightkD", 0) */ 0 , Robot .getConst ("VelocityRightkP" , 0 ),
179+ 1 / Robot .getConst ("Max Low Speed" , 84 ), rightEncRate , dtRight );
180+ rightVelocityController .setInputRange (-Robot .getConst ("Max High Speed" , 204 ),
181+ Robot .getConst ("Max High Speed" , 204 ));
182+ rightVelocityController .setOutputRange (-1.0 , 1.0 );
183+ rightVelocityController .setContinuous (false );
184+ rightVelocityController .setAbsoluteTolerance (Robot .getConst ("VelocityToleranceRight" , 2 ));
185+
186+ robotDrive = new DifferentialDrive (leftVelocityController , rightVelocityController );
187+ } else {
188+ leftTalVelController = new TalonVelocityController (Robot .getConst ("VelocityLeftkP" , 0 ),
189+ Robot .getConst ("VelocityLeftkI" , 0 ), Robot .getConst ("VelocityLeftkD" , 0 ),
190+ 1 / Robot .getConst ("Max Low Speed" , 84 ), leftEncRate , dtLeftMaster , 0 , 0 );
191+
192+ rightTalVelController = new TalonVelocityController (Robot .getConst ("VelocityRightkP" , 0 ),
193+ Robot .getConst ("VelocityRightkI" , 0 ), Robot .getConst ("VelocityRightkD" , 0 ),
194+ 1 / Robot .getConst ("Max Low Speed" , 84 ), rightEncRate , dtRightMaster , 0 , 0 );
195+
196+ robotDrive = new DifferentialDrive (leftTalVelController , rightTalVelController );
197+ }
198+
157199 robotDrive .setMaxOutput (Robot .getConst ("Max High Speed" , 204 ));
158200
159201 distEncAvg = new PIDSourceAverage (leftEncDist , rightEncDist );
0 commit comments