Class SwerveRequest.ApplyRobotSpeeds
- All Implemented Interfaces:
SwerveRequest
,SwerveRequest.NativeSwerveRequest
- Direct Known Subclasses:
SwerveRequest.ApplyChassisSpeeds
- Enclosing interface:
- SwerveRequest
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.ctre.phoenix6.swerve.SwerveRequest
SwerveRequest.ApplyChassisSpeeds, SwerveRequest.ApplyFieldSpeeds, SwerveRequest.ApplyRobotSpeeds, SwerveRequest.FieldCentric, SwerveRequest.FieldCentricFacingAngle, SwerveRequest.ForwardPerspectiveValue, SwerveRequest.Idle, SwerveRequest.NativeSwerveRequest, SwerveRequest.PointWheelsAt, SwerveRequest.RobotCentric, SwerveRequest.SwerveDriveBrake, SwerveRequest.SysIdSwerveRotation, SwerveRequest.SysIdSwerveSteerGains, SwerveRequest.SysIdSwerveTranslation
-
Field Summary
Modifier and TypeFieldDescriptionThe center of rotation the robot should rotate around.boolean
Whether to desaturate wheel speeds before applying.The type of control request to use for the drive motor.The robot-centric chassis speeds to apply to the drivetrain.The type of control request to use for the drive motor.double[]
Robot-centric wheel force feedforwards to apply in the X direction, in newtons.double[]
Robot-centric wheel force feedforwards to apply in the Y direction, in newtons. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(SwerveDrivetrain.SwerveControlParameters parameters, SwerveModule... modulesToApply) Applies this swerve request to the given modules.void
applyNative
(int id) Applies a native swerve request to the native drivetrain with the provided ID.withCenterOfRotation
(Translation2d newCenterOfRotation) Modifies the CenterOfRotation parameter and returns itself.withDesaturateWheelSpeeds
(boolean newDesaturateWheelSpeeds) Modifies the DesaturateWheelSpeeds parameter and returns itself.withDriveRequestType
(SwerveModule.DriveRequestType newDriveRequestType) Modifies the DriveRequestType parameter and returns itself.withSpeeds
(ChassisSpeeds newSpeeds) Modifies the Speeds parameter and returns itself.withSteerRequestType
(SwerveModule.SteerRequestType newSteerRequestType) Modifies the SteerRequestType parameter and returns itself.withWheelForceFeedforwardsX
(double[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsX
(edu.wpi.first.units.measure.Force[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsY
(double[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.withWheelForceFeedforwardsY
(edu.wpi.first.units.measure.Force[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.
-
Field Details
-
Speeds
The robot-centric chassis speeds to apply to the drivetrain. -
WheelForceFeedforwardsX
Robot-centric wheel force feedforwards to apply in the X direction, in newtons. X is defined as forward according to WPILib convention, so this determines the forward forces to apply.These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
-
WheelForceFeedforwardsY
Robot-centric wheel force feedforwards to apply in the Y direction, in newtons. Y is defined as to the left according to WPILib convention, so this determines the forces to apply to the left.These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
-
CenterOfRotation
The center of rotation the robot should rotate around. This is (0,0) by default, which will rotate around the center of the robot. -
DriveRequestType
The type of control request to use for the drive motor. -
SteerRequestType
The type of control request to use for the drive motor. -
DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying. For more information, see the documentation ofSwerveDriveKinematics.desaturateWheelSpeeds(edu.wpi.first.math.kinematics.SwerveModuleState[], double)
.
-
-
Constructor Details
-
ApplyRobotSpeeds
public ApplyRobotSpeeds()
-
-
Method Details
-
withSpeeds
Modifies the Speeds parameter and returns itself.The robot-centric chassis speeds to apply to the drivetrain.
- Parameters:
newSpeeds
- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsX
public SwerveRequest.ApplyRobotSpeeds withWheelForceFeedforwardsX(double[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.Robot-centric wheel force feedforwards to apply in the X direction, in newtons. X is defined as forward according to WPILib convention, so this determines the forward forces to apply.
These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
- Parameters:
newWheelForceFeedforwardsX
- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsX
public SwerveRequest.ApplyRobotSpeeds withWheelForceFeedforwardsX(edu.wpi.first.units.measure.Force[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.Robot-centric wheel force feedforwards to apply in the X direction, in newtons. X is defined as forward according to WPILib convention, so this determines the forward forces to apply.
These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
- Parameters:
newWheelForceFeedforwardsX
- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsY
public SwerveRequest.ApplyRobotSpeeds withWheelForceFeedforwardsY(double[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.Robot-centric wheel force feedforwards to apply in the Y direction, in newtons. Y is defined as to the left according to WPILib convention, so this determines the forces to apply to the left.
These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
- Parameters:
newWheelForceFeedforwardsY
- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsY
public SwerveRequest.ApplyRobotSpeeds withWheelForceFeedforwardsY(edu.wpi.first.units.measure.Force[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.Robot-centric wheel force feedforwards to apply in the Y direction, in newtons. Y is defined as to the left according to WPILib convention, so this determines the forces to apply to the left.
These forces should include friction applied to the ground.
The order of the forces should match the order of the modules returned from SwerveDrivetrain.
- Parameters:
newWheelForceFeedforwardsY
- Parameter to modify- Returns:
- this object
-
withCenterOfRotation
Modifies the CenterOfRotation parameter and returns itself.The center of rotation the robot should rotate around. This is (0,0) by default, which will rotate around the center of the robot.
- Parameters:
newCenterOfRotation
- Parameter to modify- Returns:
- this object
-
withDriveRequestType
public SwerveRequest.ApplyRobotSpeeds withDriveRequestType(SwerveModule.DriveRequestType newDriveRequestType) Modifies the DriveRequestType parameter and returns itself.The type of control request to use for the drive motor.
- Parameters:
newDriveRequestType
- Parameter to modify- Returns:
- this object
-
withSteerRequestType
public SwerveRequest.ApplyRobotSpeeds withSteerRequestType(SwerveModule.SteerRequestType newSteerRequestType) Modifies the SteerRequestType parameter and returns itself.The type of control request to use for the drive motor.
- Parameters:
newSteerRequestType
- Parameter to modify- Returns:
- this object
-
withDesaturateWheelSpeeds
Modifies the DesaturateWheelSpeeds parameter and returns itself.Whether to desaturate wheel speeds before applying. For more information, see the documentation of
SwerveDriveKinematics.desaturateWheelSpeeds(edu.wpi.first.math.kinematics.SwerveModuleState[], double)
.- Parameters:
newDesaturateWheelSpeeds
- Parameter to modify- Returns:
- this object
-
apply
public StatusCode apply(SwerveDrivetrain.SwerveControlParameters parameters, SwerveModule... modulesToApply) Description copied from interface:SwerveRequest
Applies this swerve request to the given modules. This is typically called by the SwerveDrivetrain odometry thread.For native swerve requests, this API can be called from a non-native request's
apply
to compose the two together.- Specified by:
apply
in interfaceSwerveRequest
- Parameters:
parameters
- Parameters the control request needs to calculate the module statemodulesToApply
- Modules to which the control request is applied- Returns:
- Status code of sending the request
-
applyNative
Description copied from interface:SwerveRequest.NativeSwerveRequest
Applies a native swerve request to the native drivetrain with the provided ID.When this is implemented, the regular
SwerveRequest.apply(com.ctre.phoenix6.swerve.SwerveDrivetrain.SwerveControlParameters, com.ctre.phoenix6.swerve.SwerveModule...)
function should do nothing (return OK). Additionally, this cannot be called from another swerve request's apply method, as this overrides the native swerve request of the drivetrain.Unlike
SwerveRequest.apply(com.ctre.phoenix6.swerve.SwerveDrivetrain.SwerveControlParameters, com.ctre.phoenix6.swerve.SwerveModule...)
, this function is called every timeSwerveDrivetrain.setControl(com.ctre.phoenix6.swerve.SwerveRequest)
is run, not every loop of the odometry thread. Instead, the underlying native request is run at the full update frequency of the odometry thread.- Specified by:
applyNative
in interfaceSwerveRequest.NativeSwerveRequest
- Parameters:
id
- ID of the native swerve drivetrain
-