Updated YAGSL to next-gen

This commit is contained in:
thenetworkgrinch
2023-11-09 17:32:48 -06:00
parent 0b02b3c504
commit 6aaf512b38
21 changed files with 573 additions and 517 deletions

View File

@@ -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)
{