Class WheelForceCalculator
java.lang.Object
com.ctre.phoenix6.swerve.utility.WheelForceCalculator
Calculates wheel force feedforwards for a
SwerveDrivetrain.
Wheel force feedforwards can be used to improve accuracy of path
following in regions of acceleration.
Many path planning libraries (such as PathPlanner and Choreo) already provide per-module force feedforwards, which should be preferred over this class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWheel force feedforwards to apply to a swerve drivetrain. -
Constructor Summary
ConstructorsConstructorDescriptionWheelForceCalculator(Translation2d[] moduleLocations, double mass_kg, double moi_kg_m_sq) Constructs a new wheel force feedforward calculator for the given drivetrain characteristics.WheelForceCalculator(Translation2d[] moduleLocations, Mass mass, MomentOfInertia moi) Constructs a new wheel force feedforward calculator for the given drivetrain characteristics. -
Method Summary
Modifier and TypeMethodDescriptioncalculate(double dt, ChassisVelocities prev, ChassisVelocities current) Calculates wheel force feedforwards for the desired change in velocity.calculate(double dt, ChassisVelocities prev, ChassisVelocities current, Translation2d centerOfRotation) Calculates wheel force feedforwards for the desired change in velocity.calculate(ChassisAccelerations acceleration) Calculates wheel force feedforwards for the desired robot acceleration.calculate(ChassisAccelerations acceleration, Translation2d centerOfRotation) Calculates wheel force feedforwards for the desired robot acceleration.
-
Constructor Details
-
WheelForceCalculator
Constructs a new wheel force feedforward calculator for the given drivetrain characteristics.- Parameters:
moduleLocations- The drivetrain swerve module locationsmass_kg- The mass of the robot in kgmoi_kg_m_sq- The moment of inertia of the robot in kg m^2
-
WheelForceCalculator
Constructs a new wheel force feedforward calculator for the given drivetrain characteristics.- Parameters:
moduleLocations- The drivetrain swerve module locationsmass- The mass of the robotmoi- The moment of inertia of the robot
-
-
Method Details
-
calculate
Calculates wheel force feedforwards for the desired robot acceleration. This can be used with either robot-centric or field-centric accelerations; the returned force feedforwards will match in being robot-/field-centric.- Parameters:
acceleration- Acceleration of the robot- Returns:
- Wheel force feedforwards to apply
-
calculate
public final WheelForceCalculator.Feedforwards calculate(ChassisAccelerations acceleration, Translation2d centerOfRotation) Calculates wheel force feedforwards for the desired robot acceleration. This can be used with either robot-centric or field-centric accelerations; the returned force feedforwards will match in being robot-/field-centric.- Parameters:
acceleration- Acceleration of the robotcenterOfRotation- Center of rotation- Returns:
- Wheel force feedforwards to apply
-
calculate
public final WheelForceCalculator.Feedforwards calculate(double dt, ChassisVelocities prev, ChassisVelocities current) Calculates wheel force feedforwards for the desired change in velocity. This can be used with either robot-centric or field-centric velocities; the returned force feedforwards will match in being robot-/field-centric.- Parameters:
dt- The change in time between the path setpointsprev- The previous ChassisVelocities setpoint of the pathcurrent- The new ChassisVelocities setpoint of the path- Returns:
- Wheel force feedforwards to apply
-
calculate
public final WheelForceCalculator.Feedforwards calculate(double dt, ChassisVelocities prev, ChassisVelocities current, Translation2d centerOfRotation) Calculates wheel force feedforwards for the desired change in velocity. This can be used with either robot-centric or field-centric velocities; the returned force feedforwards will match in being robot-/field-centric.- Parameters:
dt- The change in time between the path setpointsprev- The previous ChassisVelocities setpoint of the pathcurrent- The new ChassisVelocities setpoint of the pathcenterOfRotation- Center of rotation- Returns:
- Wheel force feedforwards to apply
-