Class SwerveRequest.ApplyRobotVelocity
- All Implemented Interfaces:
SwerveRequest, SwerveRequest.NativeSwerveRequest
- Enclosing interface:
SwerveRequest
Unlike the field-centric requests, this request does not automatically discretize the provided ChassisVelocities.
-
Nested Class Summary
Nested classes/interfaces inherited from interface SwerveRequest
SwerveRequest.ApplyFieldVelocity, SwerveRequest.ApplyRobotVelocity, SwerveRequest.FieldCentric, SwerveRequest.FieldCentricFacingAngle, SwerveRequest.ForwardPerspectiveValue, SwerveRequest.Idle, SwerveRequest.NativeSwerveRequest, SwerveRequest.PointWheelsAt, SwerveRequest.RobotCentric, SwerveRequest.RobotCentricFacingAngle, SwerveRequest.SwerveDriveBrake, SwerveRequest.SysIdSwerveRotation, SwerveRequest.SysIdSwerveSteerGains, SwerveRequest.SysIdSwerveTranslation, SwerveRequest.TargetDirectionPerspectiveValue -
Field Summary
FieldsModifier and TypeFieldDescriptionThe center of rotation the robot should rotate around.booleanWhether to desaturate wheel velocities before applying.The type of control request to use for the drive motor.The type of control request to use for the drive motor.The robot-centric chassis velocity to apply to the drivetrain.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(SwerveDrivetrain.SwerveControlParameters parameters, SwerveModule<?, ?, ?>... modulesToApply) Applies this swerve request to the given modules.voidapplyNative(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.withDesaturateWheelVelocities(boolean newDesaturateWheelVelocities) Modifies the DesaturateWheelVelocities parameter and returns itself.withDriveRequestType(SwerveModule.DriveRequestType newDriveRequestType) Modifies the DriveRequestType parameter and returns itself.withSteerRequestType(SwerveModule.SteerRequestType newSteerRequestType) Modifies the SteerRequestType parameter and returns itself.withVelocity(ChassisVelocities newVelocity) Modifies the Velocity parameter and returns itself.withWheelForceFeedforwardsX(double[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsX(Force[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsY(double[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.withWheelForceFeedforwardsY(Force[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.
-
Field Details
-
Velocity
The robot-centric chassis velocity to apply to the drivetrain. Users must manually discretize the velocity if appropriate. -
WheelForceFeedforwardsX
public double[] WheelForceFeedforwardsXRobot-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
public double[] WheelForceFeedforwardsYRobot-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. -
DesaturateWheelVelocities
public boolean DesaturateWheelVelocitiesWhether to desaturate wheel velocities before applying. For more information, see the documentation ofSwerveDriveKinematics.desaturateWheelVelocities(SwerveModuleVelocity[], double).
-
-
Constructor Details
-
ApplyRobotVelocity
public ApplyRobotVelocity()
-
-
Method Details
-
withVelocity
Modifies the Velocity parameter and returns itself.The robot-centric chassis velocity to apply to the drivetrain. Users must manually discretize the velocity if appropriate.
- Parameters:
newVelocity- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsX
public final SwerveRequest.ApplyRobotVelocity 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 final SwerveRequest.ApplyRobotVelocity withWheelForceFeedforwardsX(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 final SwerveRequest.ApplyRobotVelocity 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 final SwerveRequest.ApplyRobotVelocity withWheelForceFeedforwardsY(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
public final SwerveRequest.ApplyRobotVelocity withCenterOfRotation(Translation2d newCenterOfRotation) 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 final SwerveRequest.ApplyRobotVelocity 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 final SwerveRequest.ApplyRobotVelocity 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
-
withDesaturateWheelVelocities
public final SwerveRequest.ApplyRobotVelocity withDesaturateWheelVelocities(boolean newDesaturateWheelVelocities) Modifies the DesaturateWheelVelocities parameter and returns itself.Whether to desaturate wheel velocities before applying. For more information, see the documentation of
SwerveDriveKinematics.desaturateWheelVelocities(SwerveModuleVelocity[], double).- Parameters:
newDesaturateWheelVelocities- Parameter to modify- Returns:
- this object
-
apply
public StatusCode apply(SwerveDrivetrain.SwerveControlParameters parameters, SwerveModule<?, ?, ?>... modulesToApply) Description copied from interface:SwerveRequestApplies 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
applyto compose the two together.- Specified by:
applyin 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
public void applyNative(int id) Description copied from interface:SwerveRequest.NativeSwerveRequestApplies a native swerve request to the native drivetrain with the provided ID.When this is implemented, the regular
SwerveRequest.apply(SwerveDrivetrain.SwerveControlParameters, 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(SwerveDrivetrain.SwerveControlParameters, SwerveModule...), this function is called every timeSwerveDrivetrain.setControl(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:
applyNativein interfaceSwerveRequest.NativeSwerveRequest- Parameters:
id- ID of the native swerve drivetrain
-