mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Updated YAGSL to next-gen
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package swervelib.math;
|
||||
|
||||
import edu.wpi.first.math.controller.SimpleMotorFeedforward;
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
@@ -65,6 +66,27 @@ public class SwerveMath
|
||||
: value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the drive feedforward for swerve modules.
|
||||
*
|
||||
* @param optimalVoltage Optimal voltage to calculate kV (voltage/max Velocity)
|
||||
* @param maxSpeed Maximum velocity in meters per second to use for the feed forward, should be
|
||||
* as close to physical max as possible.
|
||||
* @param wheelGripCoefficientOfFriction Wheel grip coefficient of friction for kA (voltage/(cof*9.81))
|
||||
* @return Drive feedforward for drive motor on a swerve module.
|
||||
*/
|
||||
public static SimpleMotorFeedforward createDriveFeedforward(double optimalVoltage, double maxSpeed,
|
||||
double wheelGripCoefficientOfFriction)
|
||||
{
|
||||
double kv = optimalVoltage / maxSpeed;
|
||||
/// ^ Volt-seconds per meter (max voltage divided by max speed)
|
||||
double ka =
|
||||
optimalVoltage
|
||||
/ calculateMaxAcceleration(wheelGripCoefficientOfFriction);
|
||||
/// ^ Volt-seconds^2 per meter (max voltage divided by max accel)
|
||||
return new SimpleMotorFeedforward(0, kv, ka);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the degrees per steering rotation for the integrated encoder. Encoder conversion values. Drive converts
|
||||
* motor rotations to linear wheel distance and steering converts motor rotations to module azimuth.
|
||||
@@ -368,7 +390,7 @@ public class SwerveMath
|
||||
*
|
||||
* @param moduleState Current {@link SwerveModuleState} requested.
|
||||
* @param lastModuleState Previous {@link SwerveModuleState} used.
|
||||
* @param maxSpeed Maximum speed of the modules, should be in {@link SwerveDriveConfiguration#maxSpeed}.
|
||||
* @param maxSpeed Maximum speed of the modules.
|
||||
*/
|
||||
public static void antiJitter(SwerveModuleState moduleState, SwerveModuleState lastModuleState, double maxSpeed)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user