Class DriveTurnInputProcessor
java.lang.Object
com.stuypulse.robot.util.swerve.DriveTurnInputProcessor
DriveTurnInputProcessor
Class for processing driver turn input for the drivetrain. It's intended to replace StuyLib's IStream and Filters and use pure WPILib and Java.
This will be used to be as close as the original StuyLib implementation as possible It will be used for
- Applying deadbands
- Applying power curves
- Applying max angular velocity
- Applying a low pass filter
To use within a command, create an instance of this class and call the update()
method in the start of the Command.
To get the processed speed, call the get() method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.wpilib.command3.button.CommandGamepadprivate final doubleprivate final org.wpilib.math.filter.LinearFilterprivate final org.wpilib.units.measure.AngularVelocityThe max angular velocity in radians per secondprivate final doubleprivate doubleThe processed angular velocity after the full processing and filtering. -
Constructor Summary
ConstructorsConstructorDescriptionDriveTurnInputProcessor(org.wpilib.command3.button.CommandGamepad controller, double deadband, double power, org.wpilib.units.measure.AngularVelocity maxAngularVelocity, double rc) Constructor for the DriveInputProcessor -
Method Summary
Modifier and TypeMethodDescriptionprivate DriveTurnInputProcessorApplies a deadband to the currentprocessedAngularVelocityvalue.private DriveTurnInputProcessorApplies a low pass filter toprocessedAngularVelocityusing aLinearFilter.private DriveTurnInputProcessorApply a power curve to the currentprocessedAngularVelocityvalue.private DriveTurnInputProcessorScale theprocessedAngularVelocityvalue to the robot's maximum velocity.org.wpilib.units.measure.AngularVelocityget()Get the processed angular velocityprivate DriveTurnInputProcessorRead the raw joystick axis value for the right X axis and store it inprocessedAngularVelocityvoidupdate()Update method that processes all filters and updates the filtered angular velocity.
-
Field Details
-
controller
-
deadband
-
power
-
maxAngularVelocity
The max angular velocity in radians per second -
lowPassFilter
-
processedAngularVelocity
The processed angular velocity after the full processing and filtering.
-
-
Constructor Details
-
DriveTurnInputProcessor
public DriveTurnInputProcessor(org.wpilib.command3.button.CommandGamepad controller, double deadband, double power, org.wpilib.units.measure.AngularVelocity maxAngularVelocity, double rc) Constructor for the DriveInputProcessor
Creates a new DriveInputProcessor with the specified parameters processes the input periodically.
- Parameters:
controller- The CommandXboxController to get driver input fromdeadband- The deadband to apply to the input (0-1)power- The power to apply to the inputmaxAngularVelocity- The maximum angular velocity to scale the input to (radians/s)rc- The time constant for the low pass filter (seconds)
-
-
Method Details
-
getRightX
Read the raw joystick axis value for the right X axis and store it inprocessedAngularVelocity- Returns:
- This instance of the class
-
applyDeadband
Applies a deadband to the currentprocessedAngularVelocityvalue.- Returns:
- This instance of the class
-
applyPowerCurve
Apply a power curve to the currentprocessedAngularVelocityvalue.- Returns:
- This instance of the class
-
applyScalingToMaxAngularVelocity
Scale theprocessedAngularVelocityvalue to the robot's maximum velocity.- Returns:
- This instance of the class
-
applyLowPassFilter
Applies a low pass filter toprocessedAngularVelocityusing aLinearFilter. This smooths out the input and reduces noise.- Returns:
- This instance of the class
-
update
-
get
Get the processed angular velocity- Returns:
- The processed angular velocity
-