Package yams.mechanisms.config
Class SwerveModuleConfig
java.lang.Object
yams.mechanisms.config.SwerveModuleConfig
Swerve Module
-
Constructor Summary
ConstructorsConstructorDescriptionCreate theSwerveModuleConfigfor theSwerveModuleSwerveModuleConfig(SmartMotorController drive, SmartMotorController azimuth) Create theSwerveModuleConfigfor theSwerveModule -
Method Summary
Modifier and TypeMethodDescriptionclone()Get the absolute encoder angle for the azimuthSmartMotorController.Get the azimuthSmartMotorControllerfor theSwerveModule.Get the driveSmartMotorControllerfor theSwerveModule.Get the location of theSwerveModulein meters from the center of rotation.Get the optimizedSwerveModuleStateapplying all optional optimizations.booleanEnable or disable state optimization.Get the telemetry name for theSwerveModule.Get the telemetry verbosity for theSwerveModule.withAbsoluteEncoder(Object absoluteEncoder) Set the absolute encoder for the azimuthSmartMotorControllerif it's the SAME VENDOR, only.withAbsoluteEncoder(DoubleSupplier rotationSupplier) Supply a non-alike vendor absolute encoder for the azimuthSmartMotorController.withAbsoluteEncoder(Supplier<Angle> locationProvider) Supply a non-alike vendor absolute encoder for the azimuthSmartMotorController.withAbsoluteEncoderGearing(GearBox gearing) Set the gearing of the absolute encoder if it's not 1:1.withAbsoluteEncoderOffset(Angle offset) Set the absolute encoder offset for the azimuthSmartMotorControllerso that the absolute encoder reads 0 while the wheel is facing forwards and bevel to the left.withCosineCompensation(boolean compensate) Cosine compensation for theSwerveModule, adjusting the velocity by the cosine of the (current_angle-desired_angle).withDistanceFromCenterOfRotation(Distance front, Distance left) Set the distance from the center of rotation for theSwerveModule.withLocation(Translation2d location) Set the location for theSwerveModulein Meters from the center of rotation.withLocation(Distance distance, Angle angle) Set the location for theSwerveModuleusing polar coordinates.withLocation(Distance front, Distance left) Set the distance from the center of rotation for theSwerveModule.Set the minimum velocity for theSmartMotorController.withOptimization(boolean swerveModuleStateOptimization) UseSwerveModuleState.optimize(Rotation2d)to optimize each state.withSmartMotorController(SmartMotorController driveMotor, SmartMotorController azimuthMotor) Set theSmartMotorControllerfor theSwerveModule.withTelemetry(String telemetryName, SmartMotorControllerConfig.TelemetryVerbosity telemetryVerbosity) Configure telemetry for theSwerveModulemechanism.withWheelDiameter(Distance diameter) Set the wheel diameter for theSmartMotorController, ideally should be set inside the drive motorSmartMotorControllerConfig.withWheelRadius(Distance radius) Set the wheel radius for theSmartMotorController, ideally should be set inside the drive motorSmartMotorControllerConfig
-
Constructor Details
-
SwerveModuleConfig
Create theSwerveModuleConfigfor theSwerveModule- Parameters:
drive- Drive motor controller.azimuth- Azimuth motor controller.
-
SwerveModuleConfig
public SwerveModuleConfig()Create theSwerveModuleConfigfor theSwerveModule- Implementation Note:
- Required to use
withSmartMotorController(SmartMotorController, SmartMotorController)BEFORE passed intoSwerveModule
-
-
Method Details
-
clone
-
withSmartMotorController
public SwerveModuleConfig withSmartMotorController(SmartMotorController driveMotor, SmartMotorController azimuthMotor) Set theSmartMotorControllerfor theSwerveModule.- Parameters:
driveMotor-SmartMotorControllerfor the drive motor.azimuthMotor-SmartMotorControllerfor the azimuth motor.- Returns:
SwerveModuleConfigfor chaining.
-
withCosineCompensation
Cosine compensation for theSwerveModule, adjusting the velocity by the cosine of the (current_angle-desired_angle).- Parameters:
compensate- Enable or disable cosine compensation.- Returns:
SwerveModuleConfigfor chaining.
-
withAbsoluteEncoder
Set the absolute encoder for the azimuthSmartMotorControllerif it's the SAME VENDOR, only.- Parameters:
absoluteEncoder- Same vendor, absolute encoder for theSmartMotorController- Returns:
SwerveModuleConfigfor chaining.
-
withDistanceFromCenterOfRotation
Set the distance from the center of rotation for theSwerveModule.- Parameters:
front- Distance from the front of the robot, will be converted to Meters. (The X location)left- Distance from the left of the robot, will be converted to Meters. (The Y location)- Returns:
SwerveModuleConfigfor chaining.
-
withLocation
Set the location for theSwerveModulein Meters from the center of rotation.- Parameters:
location- Location of theSwerveModulein meters from the center of rotation.- Returns:
SwerveModuleConfigfor chaining.
-
withLocation
Set the distance from the center of rotation for theSwerveModule.- Parameters:
front- Distance from the front of the robot, will be converted to meters. (The X location)left- Distance from the left of the robot, will be converted to meters. (The Y location)- Returns:
SwerveModuleConfigfor chaining.
-
withLocation
Set the location for theSwerveModuleusing polar coordinates.- Parameters:
distance- Distance from the center of rotation will be converted to meters.angle- Angle from the center of rotation.- Returns:
SwerveModuleConfigfor chaining.
-
withAbsoluteEncoder
Supply a non-alike vendor absolute encoder for the azimuthSmartMotorController.- Parameters:
locationProvider- Provides the Rotation for the azimuthSmartMotorController.- Returns:
SwerveModuleConfigfor chaining.
-
withAbsoluteEncoder
Supply a non-alike vendor absolute encoder for the azimuthSmartMotorController.- Parameters:
rotationSupplier- Provides the Rotation for the azimuthSmartMotorController.- Returns:
SwerveModuleConfigfor chaining.
-
withAbsoluteEncoderGearing
Set the gearing of the absolute encoder if it's not 1:1.- Parameters:
gearing-GearBoxfor the absolute encoder to get the azimuth angle.- Returns:
SwerveModuleConfigfor chaining.
-
withAbsoluteEncoderOffset
Set the absolute encoder offset for the azimuthSmartMotorControllerso that the absolute encoder reads 0 while the wheel is facing forwards and bevel to the left.- Parameters:
offset- Offset for the absolute encoder.- Returns:
SwerveModuleConfigfor chaining.
-
withWheelRadius
Set the wheel radius for theSmartMotorController, ideally should be set inside the drive motorSmartMotorControllerConfig- Parameters:
radius- Radius of the wheel.- Returns:
SwerveModuleConfigfor chaining.
-
withWheelDiameter
Set the wheel diameter for theSmartMotorController, ideally should be set inside the drive motorSmartMotorControllerConfig.- Parameters:
diameter- Diameter of the wheel.- Returns:
SwerveModuleConfigfor chaining.
-
withMinimumVelocity
Set the minimum velocity for theSmartMotorController.- Parameters:
speed- Minimum velocity for theSmartMotorController.- Returns:
SwerveModuleConfigfor chaining.
-
withOptimization
UseSwerveModuleState.optimize(Rotation2d)to optimize each state.- Parameters:
swerveModuleStateOptimization- True to enable optimization, false otherwise.- Returns:
SwerveModuleConfigfor chaining.
-
withTelemetry
public SwerveModuleConfig withTelemetry(String telemetryName, SmartMotorControllerConfig.TelemetryVerbosity telemetryVerbosity) Configure telemetry for theSwerveModulemechanism.- Parameters:
telemetryName- Telemetry NetworkTable name to appear under "SmartDashboard/"telemetryVerbosity- Telemetry verbosity to apply.- Returns:
ArmConfigfor chaining.
-
getAbsoluteEncoderAngle
Get the absolute encoder angle for the azimuthSmartMotorController.- Returns:
- Absolute encoder
Angle.
-
getStateOptimization
public boolean getStateOptimization()Enable or disable state optimization.- Returns:
- True if optimization is enabled, false otherwise.
-
getDriveMotor
Get the driveSmartMotorControllerfor theSwerveModule.- Returns:
SmartMotorControllerfor the drive motor.
-
getAzimuthMotor
Get the azimuthSmartMotorControllerfor theSwerveModule.- Returns:
SmartMotorControllerfor the azimuth motor.
-
getOptimizedState
Get the optimizedSwerveModuleStateapplying all optional optimizations.- Parameters:
state-SwerveModuleStateto optimize.- Returns:
SwerveModuleStateoptimized.
-
getTelemetryName
Get the telemetry name for theSwerveModule.- Returns:
- Telemetry name for the
SwerveModule.
-
getTelemetryVerbosity
Get the telemetry verbosity for theSwerveModule.- Returns:
SmartMotorControllerConfig.TelemetryVerbosityfor theSwerveModule.
-
getLocation
Get the location of theSwerveModulein meters from the center of rotation.- Returns:
Translation2dof theSwerveModule
-