Class SwerveModule.ModuleRequest
- Enclosing class:
- SwerveModule<DriveMotorT extends CommonTalon,
SteerMotorT extends CommonTalon, EncoderT extends ParentDevice>
-
Field Summary
Modifier and TypeFieldDescriptionThe type of control request to use for the drive motor.boolean
When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.Unoptimized speed and direction the module should target.The type of control request to use for the steer motor.double
The update period of the module request.double
Robot-centric wheel force feedforward to apply in the X direction.double
Robot-centric wheel force feedforward to apply in the Y direction. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionHelper method to get the WheelForceFeedforwardX parameter as a unit type.Helper method to get the WheelForceFeedforwardY parameter as a unit type.withDriveRequest
(SwerveModule.DriveRequestType newDriveRequest) Modifies the DriveRequest parameter and returns itself.withEnableFOC
(boolean newEnableFOC) Modifies the EnableFOC parameter and returns itself.withState
(SwerveModuleState newState) Modifies the State parameter and returns itself.withSteerRequest
(SwerveModule.SteerRequestType newSteerRequest) Modifies the SteerRequest parameter and returns itself.withUpdatePeriod
(double newUpdatePeriod) Modifies the UpdatePeriod parameter and returns itself.withWheelForceFeedforwardX
(double newWheelForceFeedforwardX) Modifies the WheelForceFeedforwardX parameter and returns itself.withWheelForceFeedforwardX
(Force newWheelForceFeedforwardX) Modifies the WheelForceFeedforwardX parameter and returns itself.withWheelForceFeedforwardY
(double newWheelForceFeedforwardY) Modifies the WheelForceFeedforwardY parameter and returns itself.withWheelForceFeedforwardY
(Force newWheelForceFeedforwardY) Modifies the WheelForceFeedforwardY parameter and returns itself.
-
Field Details
-
State
Unoptimized speed and direction the module should target. -
WheelForceFeedforwardX
Robot-centric wheel force feedforward to apply in the X direction. X is defined as forward according to WPILib convention, so this determines the forward force to apply.This force should include friction.
-
WheelForceFeedforwardY
Robot-centric wheel force feedforward to apply in the Y direction. Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.This force should include friction.
-
DriveRequest
The type of control request to use for the drive motor. -
SteerRequest
The type of control request to use for the steer motor. -
UpdatePeriod
The update period of the module request. Setting this to a non-zero value adds a velocity feedforward to the steer motor. -
EnableFOC
When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%. Set to false to use trapezoidal commutation. This is ignored when using Torque-based control, which always uses FOC.FOC improves motor performance by leveraging torque (current) control. However, this may be inconvenient for applications that require specifying duty cycle or voltage. CTR-Electronics has developed a hybrid method that combines the performances gains of FOC while still allowing applications to provide duty cycle or voltage demand. This not to be confused with simple sinusoidal control or phase voltage control which lacks the performance gains.
-
-
Constructor Details
-
ModuleRequest
public ModuleRequest()
-
-
Method Details
-
withState
Modifies the State parameter and returns itself.Unoptimized speed and direction the module should target.
- Parameters:
newState
- Parameter to modify- Returns:
- Itself
-
withWheelForceFeedforwardX
Modifies the WheelForceFeedforwardX parameter and returns itself.Robot-centric wheel force feedforward to apply in the X direction. X is defined as forward according to WPILib convention, so this determines the forward force to apply.
This force should include friction applied to the ground.
- Parameters:
newWheelForceFeedforwardX
- Parameter to modify- Returns:
- Itself
-
withWheelForceFeedforwardX
Modifies the WheelForceFeedforwardX parameter and returns itself.Robot-centric wheel force feedforward to apply in the X direction. X is defined as forward according to WPILib convention, so this determines the forward force to apply.
This force should include friction applied to the ground.
- Parameters:
newWheelForceFeedforwardX
- Parameter to modify- Returns:
- Itself
-
getWheelForceFeedforwardXMeasure
Helper method to get the WheelForceFeedforwardX parameter as a unit type. If not using the Java units library,WheelForceFeedforwardX
can be accessed directly instead.Robot-centric wheel force feedforward to apply in the X direction. X is defined as forward according to WPILib convention, so this determines the forward force to apply.
This force should include friction applied to the ground.
- Returns:
- WheelForceFeedforwardX
-
withWheelForceFeedforwardY
Modifies the WheelForceFeedforwardY parameter and returns itself.Robot-centric wheel force feedforward to apply in the Y direction. Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.
This force should include friction applied to the ground.
- Parameters:
newWheelForceFeedforwardY
- Parameter to modify- Returns:
- Itself
-
withWheelForceFeedforwardY
Modifies the WheelForceFeedforwardY parameter and returns itself.Robot-centric wheel force feedforward to apply in the Y direction. Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.
This force should include friction applied to the ground.
- Parameters:
newWheelForceFeedforwardY
- Parameter to modify- Returns:
- Itself
-
getWheelForceFeedforwardYMeasure
Helper method to get the WheelForceFeedforwardY parameter as a unit type. If not using the Java units library,WheelForceFeedforwardY
can be accessed directly instead.Robot-centric wheel force feedforward to apply in the Y direction. Y is defined as to the left according to WPILib convention, so this determines the force to apply to the left.
This force should include friction applied to the ground.
- Returns:
- WheelForceFeedforwardY
-
withDriveRequest
Modifies the DriveRequest parameter and returns itself.The type of control request to use for the drive motor.
- Parameters:
newDriveRequest
- Parameter to modify- Returns:
- Itself
-
withSteerRequest
Modifies the SteerRequest parameter and returns itself.The type of control request to use for the steer motor.
- Parameters:
newSteerRequest
- Parameter to modify- Returns:
- Itself
-
withUpdatePeriod
Modifies the UpdatePeriod parameter and returns itself.The update period of the module request. Setting this to a non-zero value adds a velocity feedforward to the steer motor.
- Parameters:
newUpdatePeriod
- Parameter to modify- Returns:
- Itself
-
withEnableFOC
Modifies the EnableFOC parameter and returns itself.When using Voltage-based control, set to true (default) to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%. Set to false to use trapezoidal commutation. This is ignored when using Torque-based control, which always uses FOC.
FOC improves motor performance by leveraging torque (current) control. However, this may be inconvenient for applications that require specifying duty cycle or voltage. CTR-Electronics has developed a hybrid method that combines the performances gains of FOC while still allowing applications to provide duty cycle or voltage demand. This not to be confused with simple sinusoidal control or phase voltage control which lacks the performance gains.
- Parameters:
newEnableFOC
- Parameter to modify- Returns:
- Itself
-