Drive With Joysticks Command
This command, placed inside of coppercore's wpilib_interface library, has several advanced features to help make driving smoother. These include:
- enhanced sensitivity via squaring the magnitude of linear and rotational velocities
- adjustable deadbands
- adjustable max speeds (linear and rotational)
Using the Command
Importing Library
To import the command simply add this line to the robot code's build.gradle under dependencies similar to how other coppercore dependencies are added
Setting Up Drive Subsystem
In order to use this command, the drive subsystem must implement the DriveTemplate located in wpilib_interface library:
Note: by implementing DriveTemplate, you DO NOT have to extend SubsystemBase, this step is already included within the DriveTemplate.
Adding SetGoalSpeeds method
The DriveTemplate also requires that the driveSubsytem have a setGoalSpeeds method. This is how the DriveWithJoysticks command will tell drive what speeds are being commmanded. An example of adding this to the talonfx-swerve used in 2025 is shown below.
Furthermore, to keep things uniform throughout code, any other commands for running velocity should now be sent to setGoalSpeeds method. Braking could be done like so drive.setGoalSpeeds(new ChassisSpeeds(0));
Adjusting RunVelocity
finally, remove the parameter from runVelocity method like above, and add this runVelocity method to the end of the drivetrains periodic method. If you notice drive isn't moving, you likely forgot this step.
Note: This is needed because the DriveWithJoysticks command calls setGoalSpeeds every loop, however, without ever running runVelocity the robot would never move. Speeds would be updated but never sent to drive motors.
Adding Command to RobotContainer
This just involved setting the default command for drive to a new instance of the DriveWithJoysticks command. Linear and angular speeds should match the max of those set in drive subsystem.
Note: If joysticks behave with too much sensitivity (barely tapping causes movement) increase the deadband, maybe 0.05 -> 0.1