1313import edu .wpi .first .math .kinematics .DifferentialDriveOdometry ;
1414import edu .wpi .first .math .system .plant .DCMotor ;
1515import edu .wpi .first .math .util .Units ;
16- import edu .wpi .first .networktables .NetworkTableEntry ;
1716import edu .wpi .first .wpilibj .ADIS16448_IMU ;
1817import edu .wpi .first .wpilibj .AnalogGyro ;
1918import edu .wpi .first .wpilibj .Encoder ;
3433import frc .robot .common .hardware .MotorController ;
3534
3635public class DriveBaseSubsystem extends SubsystemBase {
36+ private double driveBaseSpeed ;
3737 private ShuffleboardTab driverTab = Shuffleboard .getTab ("Driver Teleop tab" );
38- private NetworkTableEntry teleopSpeed =
39- driverTab .add ("Speed percentage" , 100 ).withPosition (0 , 1 ).getEntry ();
40-
4138 private final Joystick m_driverJoystick ;
4239 private final MotorController [] m_motorControllers ;
4340 private final DifferentialDrive m_differentialDrive ;
@@ -64,7 +61,7 @@ public class DriveBaseSubsystem extends SubsystemBase {
6461 private boolean isReverse = false ;
6562
6663 public DriveBaseSubsystem (Joystick joystick , boolean usingExternal ) {
67-
64+ driveBaseSpeed = 1 ;
6865 m_driverJoystick = joystick ;
6966
7067 m_motorControllers = new MotorController [4 ];
@@ -106,6 +103,24 @@ public DriveBaseSubsystem(Joystick joystick, boolean usingExternal) {
106103 m_motorControllers [Constants .driveLeftFrontIndex ].setInverted (true );
107104 m_motorControllers [Constants .driveLeftRearIndex ].setInverted (true );
108105
106+ m_motorControllers [Constants .driveLeftRearIndex ].setOpenLoopRampRate (
107+ Constants .openLoopRampRate );
108+ m_motorControllers [Constants .driveLeftFrontIndex ].setOpenLoopRampRate (
109+ Constants .openLoopRampRate );
110+ m_motorControllers [Constants .driveRightRearIndex ].setOpenLoopRampRate (
111+ Constants .openLoopRampRate );
112+ m_motorControllers [Constants .driveRightFrontIndex ].setOpenLoopRampRate (
113+ Constants .openLoopRampRate );
114+
115+ m_motorControllers [Constants .driveLeftRearIndex ].setSmartCurrentLimit (
116+ Constants .driveBaseCurrentLimit );
117+ m_motorControllers [Constants .driveLeftFrontIndex ].setSmartCurrentLimit (
118+ Constants .driveBaseCurrentLimit );
119+ m_motorControllers [Constants .driveRightRearIndex ].setSmartCurrentLimit (
120+ Constants .driveBaseCurrentLimit );
121+ m_motorControllers [Constants .driveRightFrontIndex ].setSmartCurrentLimit (
122+ Constants .driveBaseCurrentLimit );
123+
109124 // Forces rear motors of each side to follow the first
110125 m_motorControllers [Constants .driveLeftRearIndex ].follow (
111126 m_motorControllers [Constants .driveLeftFrontIndex ]);
@@ -217,24 +232,24 @@ public void periodic() {
217232
218233 }
219234
220- public void setArcadedrivespeed (double input ) {
221- teleopSpeed . setDouble ( input ) ;
235+ public void setDriveBaseSpeed (double driveBaseSpeed ) {
236+ this . driveBaseSpeed = driveBaseSpeed ;
222237 }
223238
224239 // Normal Arcade Drive
225240 public void arcadeDrive () {
226241 // Note: -0.85 to accomodate comfort of driver (sensitivity)
227242 m_differentialDrive .arcadeDrive (
228- m_driverJoystick .getRawAxis (Constants .leftJoystickY ) * -( teleopSpeed . getDouble ( 100 ) / 100 ) ,
229- m_driverJoystick .getRawAxis (Constants .rightJoystickX ),
243+ m_driverJoystick .getRawAxis (Constants .leftJoystickY ) * -driveBaseSpeed ,
244+ m_driverJoystick .getRawAxis (Constants .rightJoystickX ) * Constants . driveBaseTurnRate ,
230245 true );
231246 // joystick has y-axis flipped so up is negative why down is positive
232247 }
233248
234249 // Arcade Drive where you can only move forwards and backwards for testing
235250 public void arcadeDrive (double rotation ) {
236251 m_differentialDrive .arcadeDrive (
237- - 0.85 * m_driverJoystick .getRawAxis (Constants .leftJoystickY ), rotation );
252+ m_driverJoystick .getRawAxis (Constants .leftJoystickY ) * - driveBaseSpeed , rotation );
238253 }
239254
240255 // TODO: Make a command to switch modes (extra)
0 commit comments