Class SwerveRequest.ApplyFieldVelocity
- All Implemented Interfaces:
SwerveRequest, SwerveRequest.NativeSwerveRequest
- Enclosing interface:
SwerveRequest
-
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 TypeFieldDescriptionorg.wpilib.math.geometry.Translation2dThe 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 perspective to use when determining which direction is forward.The type of control request to use for the drive motor.org.wpilib.math.kinematics.ChassisVelocitiesThe field-centric chassis velocity to apply to the drivetrain.double[]Field-centric wheel force feedforwards to apply in the X direction, in newtons.double[]Field-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(org.wpilib.math.geometry.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.withForwardPerspective(SwerveRequest.ForwardPerspectiveValue newForwardPerspective) Modifies the ForwardPerspective parameter and returns itself.withSteerRequestType(SwerveModule.SteerRequestType newSteerRequestType) Modifies the SteerRequestType parameter and returns itself.withVelocity(org.wpilib.math.kinematics.ChassisVelocities newVelocity) Modifies the Velocity parameter and returns itself.withWheelForceFeedforwardsX(double[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsX(org.wpilib.units.measure.Force[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.withWheelForceFeedforwardsY(double[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.withWheelForceFeedforwardsY(org.wpilib.units.measure.Force[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.
-
Field Details
-
Velocity
The field-centric chassis velocity to apply to the drivetrain. -
WheelForceFeedforwardsX
Field-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
Field-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
Whether to desaturate wheel velocities before applying. For more information, see the documentation ofSwerveDriveKinematics.desaturateWheelVelocities(SwerveModuleVelocity[], double). -
ForwardPerspective
The perspective to use when determining which direction is forward.
-
-
Constructor Details
-
ApplyFieldVelocity
public ApplyFieldVelocity()
-
-
Method Details
-
withVelocity
public final SwerveRequest.ApplyFieldVelocity withVelocity(org.wpilib.math.kinematics.ChassisVelocities newVelocity) Modifies the Velocity parameter and returns itself.The field-centric chassis velocity to apply to the drivetrain.
- Parameters:
newVelocity- Parameter to modify- Returns:
- this object
-
withWheelForceFeedforwardsX
public final SwerveRequest.ApplyFieldVelocity withWheelForceFeedforwardsX(double[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.Field-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.ApplyFieldVelocity withWheelForceFeedforwardsX(org.wpilib.units.measure.Force[] newWheelForceFeedforwardsX) Modifies the WheelForceFeedforwardsX parameter and returns itself.Field-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.ApplyFieldVelocity withWheelForceFeedforwardsY(double[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.Field-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.ApplyFieldVelocity withWheelForceFeedforwardsY(org.wpilib.units.measure.Force[] newWheelForceFeedforwardsY) Modifies the WheelForceFeedforwardsY parameter and returns itself.Field-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.ApplyFieldVelocity withCenterOfRotation(org.wpilib.math.geometry.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.ApplyFieldVelocity 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.ApplyFieldVelocity 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.ApplyFieldVelocity 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
-
withForwardPerspective
public final SwerveRequest.ApplyFieldVelocity withForwardPerspective(SwerveRequest.ForwardPerspectiveValue newForwardPerspective) Modifies the ForwardPerspective parameter and returns itself.The perspective to use when determining which direction is forward.
- Parameters:
newForwardPerspective- 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
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
-