mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-20 06:31:39 +00:00
Updated YAGSL
This commit is contained in:
@@ -7,73 +7,70 @@ import swervelib.imu.SwerveIMU;
|
||||
/**
|
||||
* Swerve drive configurations used during SwerveDrive construction.
|
||||
*/
|
||||
public class SwerveDriveConfiguration
|
||||
{
|
||||
public class SwerveDriveConfiguration {
|
||||
|
||||
/**
|
||||
* Swerve Module locations.
|
||||
*/
|
||||
public Translation2d[] moduleLocationsMeters;
|
||||
/**
|
||||
* Swerve IMU
|
||||
*/
|
||||
public SwerveIMU imu;
|
||||
/**
|
||||
* Invert the imu measurements.
|
||||
*/
|
||||
public boolean invertedIMU = false;
|
||||
/**
|
||||
* Max speed in meters per second.
|
||||
*/
|
||||
public double maxSpeed;
|
||||
/**
|
||||
* Number of modules on the robot.
|
||||
*/
|
||||
public int moduleCount;
|
||||
/**
|
||||
* Swerve Modules.
|
||||
*/
|
||||
public SwerveModule[] modules;
|
||||
/**
|
||||
* Swerve Module locations.
|
||||
*/
|
||||
public Translation2d[] moduleLocationsMeters;
|
||||
/**
|
||||
* Swerve IMU
|
||||
*/
|
||||
public SwerveIMU imu;
|
||||
/**
|
||||
* Invert the imu measurements.
|
||||
*/
|
||||
public boolean invertedIMU = false;
|
||||
/**
|
||||
* Max module speed in meters per second.
|
||||
*/
|
||||
public double maxSpeed, attainableMaxTranslationalSpeedMetersPerSecond, attainableMaxRotationalVelocityRadiansPerSecond;
|
||||
/**
|
||||
* Number of modules on the robot.
|
||||
*/
|
||||
public int moduleCount;
|
||||
/**
|
||||
* Swerve Modules.
|
||||
*/
|
||||
public SwerveModule[] modules;
|
||||
|
||||
/**
|
||||
* Create swerve drive configuration.
|
||||
*
|
||||
* @param moduleConfigs Module configuration.
|
||||
* @param swerveIMU Swerve IMU.
|
||||
* @param maxSpeed Max speed of the robot in meters per second.
|
||||
* @param invertedIMU Invert the IMU.
|
||||
*/
|
||||
public SwerveDriveConfiguration(
|
||||
SwerveModuleConfiguration[] moduleConfigs,
|
||||
SwerveIMU swerveIMU,
|
||||
double maxSpeed,
|
||||
boolean invertedIMU)
|
||||
{
|
||||
this.moduleCount = moduleConfigs.length;
|
||||
this.imu = swerveIMU;
|
||||
this.maxSpeed = maxSpeed;
|
||||
this.invertedIMU = invertedIMU;
|
||||
this.modules = createModules(moduleConfigs);
|
||||
this.moduleLocationsMeters = new Translation2d[moduleConfigs.length];
|
||||
for (SwerveModule module : modules)
|
||||
{
|
||||
this.moduleLocationsMeters[module.moduleNumber] = module.configuration.moduleLocation;
|
||||
/**
|
||||
* Create swerve drive configuration.
|
||||
*
|
||||
* @param moduleConfigs Module configuration.
|
||||
* @param swerveIMU Swerve IMU.
|
||||
* @param maxSpeed Max speed of the robot in meters per second.
|
||||
* @param invertedIMU Invert the IMU.
|
||||
*/
|
||||
public SwerveDriveConfiguration(
|
||||
SwerveModuleConfiguration[] moduleConfigs,
|
||||
SwerveIMU swerveIMU,
|
||||
double maxSpeed,
|
||||
boolean invertedIMU) {
|
||||
this.moduleCount = moduleConfigs.length;
|
||||
this.imu = swerveIMU;
|
||||
this.maxSpeed = maxSpeed;
|
||||
this.attainableMaxRotationalVelocityRadiansPerSecond = 0;
|
||||
this.attainableMaxTranslationalSpeedMetersPerSecond = 0;
|
||||
this.invertedIMU = invertedIMU;
|
||||
this.modules = createModules(moduleConfigs);
|
||||
this.moduleLocationsMeters = new Translation2d[moduleConfigs.length];
|
||||
for (SwerveModule module : modules) {
|
||||
this.moduleLocationsMeters[module.moduleNumber] = module.configuration.moduleLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create modules based off of the SwerveModuleConfiguration.
|
||||
*
|
||||
* @param swerves Swerve constants.
|
||||
* @return Swerve Modules.
|
||||
*/
|
||||
public SwerveModule[] createModules(SwerveModuleConfiguration[] swerves)
|
||||
{
|
||||
SwerveModule[] modArr = new SwerveModule[swerves.length];
|
||||
for (int i = 0; i < swerves.length; i++)
|
||||
{
|
||||
modArr[i] = new SwerveModule(i, swerves[i]);
|
||||
/**
|
||||
* Create modules based off of the SwerveModuleConfiguration.
|
||||
*
|
||||
* @param swerves Swerve constants.
|
||||
* @return Swerve Modules.
|
||||
*/
|
||||
public SwerveModule[] createModules(SwerveModuleConfiguration[] swerves) {
|
||||
SwerveModule[] modArr = new SwerveModule[swerves.length];
|
||||
for (int i = 0; i < swerves.length; i++) {
|
||||
modArr[i] = new SwerveModule(i, swerves[i]);
|
||||
}
|
||||
return modArr;
|
||||
}
|
||||
return modArr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user