Package frc.robot.utils
Class SwerveUtils
java.lang.Object
frc.robot.utils.SwerveUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleAngleDifference(double angleA, double angleB) Finds the (unsigned) minimum difference between two angles including calculating across 0.static doubleStepTowards(double current, double target, double stepsize) Steps a value towards a target with a specified step size.static doubleStepTowardsCircular(double current, double target, double stepsize) Steps a value (angle) towards a target (angle) taking the shortest path with a specified step size.static doubleWrapAngle(double angle) Wraps an angle until it lies within the range from 0 to 2*PI (exclusive).
-
Constructor Details
-
SwerveUtils
public SwerveUtils()
-
-
Method Details
-
StepTowards
public static double StepTowards(double current, double target, double stepsize) Steps a value towards a target with a specified step size.- Parameters:
current- The current or starting value. Can be positive or negative.target- The target value the algorithm will step towards. Can be positive or negative.stepsize- The maximum step size that can be taken.- Returns:
- The new value for `current` after performing the specified step towards the specified target.
-
StepTowardsCircular
public static double StepTowardsCircular(double current, double target, double stepsize) Steps a value (angle) towards a target (angle) taking the shortest path with a specified step size.- Parameters:
current- The current or starting angle (in radians). Can lie outside the 0 to 2*PI range.target- The target angle (in radians) the algorithm will step towards. Can lie outside the 0 to 2*PI range.stepsize- The maximum step size that can be taken (in radians).- Returns:
- The new angle (in radians) for `current` after performing the specified step towards the specified target. This value will always lie in the range 0 to 2*PI (exclusive).
-
AngleDifference
public static double AngleDifference(double angleA, double angleB) Finds the (unsigned) minimum difference between two angles including calculating across 0.- Parameters:
angleA- An angle (in radians).angleB- An angle (in radians).- Returns:
- The (unsigned) minimum difference between the two angles (in radians).
-
WrapAngle
public static double WrapAngle(double angle) Wraps an angle until it lies within the range from 0 to 2*PI (exclusive).- Parameters:
angle- The angle (in radians) to wrap. Can be positive or negative and can lie multiple wraps outside the output range.- Returns:
- An angle (in radians) from 0 and 2*PI (exclusive).
-