Package com.marslib.swerve
Class TeleopDriveMath
java.lang.Object
com.marslib.swerve.TeleopDriveMath
Pure-function joystick-to-ChassisSpeeds math for the teleop drive pipeline.
This class exists so the exact same math is used in RobotContainer and in tests. If
this is ever changed, the TeleopDrivePipelineTest will immediately catch regressions.
Pipeline stages:
- Deadband (10%) — filters stick drift
- Cubic scaling — provides fine control at small deflections
- Physical scaling — converts [-1,1] to m/s and rad/s
- WPILib sign convention — negates to convert stick-forward to +X
- Alliance flip — negates X and Y for Red alliance
Note: slew rate limiting and gyro-lock are stateful operations that remain in
RobotContainer since they depend on previous tick state.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault joystick deadband threshold. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcomputeFieldRelativeSpeeds(double rawLeftY, double rawLeftX, double rawOmega, double maxLinearSpeedMps, double maxAngularSpeedRadPerSec, boolean isRedAlliance, edu.wpi.first.math.kinematics.ChassisSpeeds outSpeeds) Computes field-relative ChassisSpeeds from raw joystick axes BEFORE slew rate limiting.
-
Field Details
-
DEADBAND
public static final double DEADBANDDefault joystick deadband threshold.- See Also:
-
-
Method Details
-
computeFieldRelativeSpeeds
public static void computeFieldRelativeSpeeds(double rawLeftY, double rawLeftX, double rawOmega, double maxLinearSpeedMps, double maxAngularSpeedRadPerSec, boolean isRedAlliance, edu.wpi.first.math.kinematics.ChassisSpeeds outSpeeds) Computes field-relative ChassisSpeeds from raw joystick axes BEFORE slew rate limiting. This is the pure-math portion of the teleop pipeline: deadband → cube → scale → negate → alliance-flip.- Parameters:
rawLeftY- Raw left stick Y axis (negative = forward per HID convention)rawLeftX- Raw left stick X axis (negative = left per HID convention)rawOmega- Raw right stick X axis (negative = CCW per HID convention)maxLinearSpeedMps- The maximum translation speed of the robot.maxAngularSpeedRadPerSec- The maximum rotation speed of the robot.isRedAlliance- Whether the robot is on the Red alliance (flips translation axes)outSpeeds- The pre-allocated ChassisSpeeds to populate with field-relative velocities. Omega is negated so that rightward stick (positive HID) produces negative (clockwise) rotation per WPILib ChassisSpeeds convention.
-