Package frc.team4373.swerve
Class SwerveInputTransform
- java.lang.Object
-
- frc.team4373.swerve.SwerveInputTransform
-
public class SwerveInputTransform extends java.lang.Object
A class to transform inputs into the proper swerve outputs.
-
-
Constructor Summary
Constructors Constructor Description SwerveInputTransform(double trackwidth, double wheelbase)
Constructs a new swerve input transform for given robot dimensions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WheelVector.VectorSet
calculateBrakeVectors(SwerveDrivetrain.BrakeMode brakeMode)
Calculates aWheelVector.VectorSet
for the given brake mode.WheelVector.VectorSet
processNorthUp(double rotation, double x, double y, double imuAngle)
Produces swerve velocity vectors relative to the field for the given input.WheelVector.VectorSet
processOwnShipUp(double rotation, double x, double y)
Produces swerve velocity vectors relative to the robot for the given inputs.WheelVector.VectorSet
processRotation(double rate)
Processes rotational input from the joystick to produce rotational-only movement vectors.WheelVector.VectorSet
processTranslation(double x, double y)
Processes x-y input from the joystick to produce translational-only movement vectors.
-
-
-
Constructor Detail
-
SwerveInputTransform
public SwerveInputTransform(double trackwidth, double wheelbase)
Constructs a new swerve input transform for given robot dimensions.- Parameters:
trackwidth
- the robot's trackwidth (unit-agnostic; units must match wheelbase).wheelbase
- the robot's wheelbase (unit-agnostic; units must match trackwidth).
-
-
Method Detail
-
processNorthUp
public WheelVector.VectorSet processNorthUp(double rotation, double x, double y, double imuAngle)
Produces swerve velocity vectors relative to the field for the given input.See https://www.chiefdelphi.com/t/107383
- Parameters:
rotation
- the rotation of the joystick (CW is positive)x
- the x coordinate of the joystick (right is positive)y
- the y coordinate of the joystick (forward is positive)imuAngle
- the current heading of the robot- Returns:
- a
WheelVector.VectorSet
of velocity vectors.
-
processOwnShipUp
public WheelVector.VectorSet processOwnShipUp(double rotation, double x, double y)
Produces swerve velocity vectors relative to the robot for the given inputs.- Parameters:
rotation
- the rotation of the joystick (CW is positive)x
- the x coordinate of the joystick (right is positive)y
- the y coordinate of the joystick (forward is positive)- Returns:
- a
WheelVector.VectorSet
of velocity vectors.
-
processTranslation
public WheelVector.VectorSet processTranslation(double x, double y)
Processes x-y input from the joystick to produce translational-only movement vectors.- Parameters:
x
- the x-coordinate of the joystick's position (right-positive).y
- the y-coordinate of the joystick's position (forward-positive).- Returns:
- a
WheelVector.VectorSet
of translational movement vectors.
-
processRotation
public WheelVector.VectorSet processRotation(double rate)
Processes rotational input from the joystick to produce rotational-only movement vectors.- Parameters:
rate
- the rate of rotation, [-1, 1].- Returns:
- a
WheelVector.VectorSet
of rotational movement vectors.
-
calculateBrakeVectors
public WheelVector.VectorSet calculateBrakeVectors(SwerveDrivetrain.BrakeMode brakeMode)
Calculates aWheelVector.VectorSet
for the given brake mode.- Parameters:
brakeMode
- the brake mode for which to calculate vectors.- Returns:
- the vectors for the specified brake mode using the configured robot dimensions.
-
-