Files
YAGSL/swervelib/parser/SwerveControllerConfiguration.java

64 lines
2.5 KiB
Java
Raw Normal View History

2023-02-13 17:21:24 -06:00
package swervelib.parser;
2023-02-13 14:37:05 -06:00
2023-02-13 17:21:24 -06:00
import static swervelib.math.SwerveMath.calculateMaxAngularVelocity;
2023-02-13 14:37:05 -06:00
/**
2023-02-13 17:21:24 -06:00
* Swerve Controller configuration class which is used to configure {@link swervelib.SwerveController}.
2023-02-13 14:37:05 -06:00
*/
public class SwerveControllerConfiguration
{
/**
* PIDF for the heading of the robot.
*/
public final PIDFConfig headingPIDF;
/**
* hypotenuse deadband for the robot angle control joystick.
*/
public final double
angleJoyStickRadiusDeadband; // Deadband for the minimum hypot for the heading joystick.
2023-04-08 12:31:07 -05:00
/**
2024-12-09 23:26:04 +00:00
* Maximum chassis angular velocity in rad/s
2023-04-08 12:31:07 -05:00
*/
public double maxAngularVelocity;
2023-02-13 14:37:05 -06:00
/**
* Construct the swerve controller configuration. Assumes robot is square to fetch maximum angular velocity.
2023-02-13 14:37:05 -06:00
*
* @param driveCfg {@link SwerveDriveConfiguration} to fetch the first module X and Y used to
* calculate the maximum angular velocity.
2023-02-13 14:37:05 -06:00
* @param headingPIDF Heading PIDF configuration.
* @param angleJoyStickRadiusDeadband Deadband on radius of angle joystick.
2023-11-09 17:32:48 -06:00
* @param maxSpeedMPS Maximum speed in meters per second for angular velocity, remember if you have
* feet per second use {@link edu.wpi.first.math.util.Units#feetToMeters(double)}.
2023-02-13 14:37:05 -06:00
*/
public SwerveControllerConfiguration(
SwerveDriveConfiguration driveCfg,
PIDFConfig headingPIDF,
2023-11-09 17:32:48 -06:00
double angleJoyStickRadiusDeadband,
double maxSpeedMPS)
2023-02-13 14:37:05 -06:00
{
this.maxAngularVelocity =
calculateMaxAngularVelocity(
2023-11-09 17:32:48 -06:00
maxSpeedMPS,
Math.abs(driveCfg.moduleLocationsMeters[0].getX()),
Math.abs(driveCfg.moduleLocationsMeters[0].getY()));
2023-02-13 14:37:05 -06:00
this.headingPIDF = headingPIDF;
this.angleJoyStickRadiusDeadband = angleJoyStickRadiusDeadband;
}
/**
* Construct the swerve controller configuration. Assumes hypotenuse deadband of 0.5 (minimum radius for angle to be
* set on angle joystick is .5 of the controller).
*
* @param driveCfg Drive configuration.
* @param headingPIDF Heading PIDF configuration.
2023-11-09 17:32:48 -06:00
* @param maxSpeedMPS Maximum speed in meters per second for angular velocity, remember if you have feet per second
* use {@link edu.wpi.first.math.util.Units#feetToMeters(double)}.
2023-02-13 14:37:05 -06:00
*/
2023-11-09 17:32:48 -06:00
public SwerveControllerConfiguration(SwerveDriveConfiguration driveCfg, PIDFConfig headingPIDF, double maxSpeedMPS)
2023-02-13 14:37:05 -06:00
{
2023-11-09 17:32:48 -06:00
this(driveCfg, headingPIDF, 0.5, maxSpeedMPS);
2023-02-13 14:37:05 -06:00
}
}