Package com.marswars.swerve_lib
Class ChassisRequest.RobotCentricFacingAngle
java.lang.Object
com.marswars.swerve_lib.ChassisRequest.RobotCentricFacingAngle
- All Implemented Interfaces:
ChassisRequest
- Enclosing interface:
- ChassisRequest
Applies robot-relative chassis speeds while maintaining a field-centric facing angle.
This allows the robot to move in any direction relative to itself while independently
controlling its orientation to face a specific field-relative direction.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.marswars.swerve_lib.ChassisRequest
ChassisRequest.ApplyChassisSpeeds, ChassisRequest.ApplyFieldSpeeds, ChassisRequest.ChassisRequestParameters, ChassisRequest.FieldCentric, ChassisRequest.FieldCentricFacingAngle, ChassisRequest.Idle, ChassisRequest.PointWheelsAt, ChassisRequest.RobotCentric, ChassisRequest.RobotCentricFacingAngle, ChassisRequest.SwerveDriveBrake, ChassisRequest.XPositiveReference -
Field Summary
FieldsModifier and TypeFieldDescriptionThe center of rotation the robot should rotate around.doubleThe allowable deadband of the request.The type of control request to use for the drive motor.The PID controller used to maintain the desired heading.doubleFeedforward rotational velocity in rad/s to add to the PID output.doubleThe maximum absolute rotational rate of the request.doubleThe rotational deadband of the request.The robot-relative chassis speeds to apply to the drivetrain.The type of control request to use for the steer motor.The direction the robot should face. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(ChassisRequest.ChassisRequestParameters parameters, Module... modulesToApply) Applies this swerve request to the given modules.withCenterOfRotation(Translation2d centerOfRotation) Sets the center of rotation of the requestwithDeadband(double deadband) Sets the allowable deadband of the request.withDriveRequestType(Module.DriveControlMode driveRequestType) Sets the type of control request to use for the drive motor.withHeadingController(PhoenixPIDController headingController) Sets the PID controller used to maintain the desired heading.withHeadingFeedforward(double headingFeedforward) Sets the feedforward rotational velocity to add to the PID output.withMaxAbsRotationalRate(double maxAbsRotationalRate) Sets the maximum absolute rotational rate of the request.withRotationalDeadband(double rotationalDeadband) Sets the rotational deadband of the request.withSpeeds(ChassisSpeeds speeds) Sets the robot-relative chassis speeds to apply to the drivetrain.withSteerRequestType(Module.SteerControlMode steerRequestType) Sets the type of control request to use for the steer motor.withTargetHeading(Rotation2d targetDirection) Sets the desired direction to face.
-
Field Details
-
Speeds
The robot-relative chassis speeds to apply to the drivetrain. -
TargetDirection
The direction the robot should face. 0 Degrees is defined as in the direction of the X axis. -
Deadband
public double DeadbandThe allowable deadband of the request. -
RotationalDeadband
public double RotationalDeadbandThe rotational deadband of the request. -
MaxAbsRotationalRate
public double MaxAbsRotationalRateThe maximum absolute rotational rate of the request. -
HeadingFeedforward
public double HeadingFeedforwardFeedforward rotational velocity in rad/s to add to the PID output. -
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 steer motor. -
HeadingController
The PID controller used to maintain the desired heading. Users can specify the PID gains to change how aggressively to maintain heading.This PID controller operates on heading radians and outputs a target rotational rate in radians per second.
-
-
Constructor Details
-
RobotCentricFacingAngle
public RobotCentricFacingAngle()
-
-
Method Details
-
apply
Applies this swerve request to the given modules. This is typically called by the SwerveDrivetrain.- Specified by:
applyin interfaceChassisRequest- Parameters:
parameters- Parameters the control request needs to calculate the module statemodulesToApply- Modules to which the control request is applied
-
withSpeeds
Sets the robot-relative chassis speeds to apply to the drivetrain.- Parameters:
speeds- Robot-relative chassis speeds to apply- Returns:
- this request
-
withTargetHeading
Sets the desired direction to face. 0 Degrees is defined as in the direction of the X axis. As a result, a TargetDirection of 90 degrees will point along the Y axis, or to the left.- Parameters:
targetDirection- Desired direction to face- Returns:
- this request
-
withDeadband
Sets the allowable deadband of the request.- Parameters:
deadband- Allowable deadband of the request- Returns:
- this request
-
withRotationalDeadband
Sets the rotational deadband of the request.- Parameters:
rotationalDeadband- Rotational deadband of the request- Returns:
- this request
-
withMaxAbsRotationalRate
Sets the maximum absolute rotational rate of the request.- Parameters:
maxAbsRotationalRate- The maximum absolute rotational rate- Returns:
- this request
-
withCenterOfRotation
Sets the center of rotation of the request- Parameters:
centerOfRotation- The center of rotation the robot should rotate around.- Returns:
- this request
-
withDriveRequestType
public ChassisRequest.RobotCentricFacingAngle withDriveRequestType(Module.DriveControlMode driveRequestType) Sets the type of control request to use for the drive motor.- Parameters:
driveRequestType- The type of control request to use for the drive motor- Returns:
- this request
-
withSteerRequestType
public ChassisRequest.RobotCentricFacingAngle withSteerRequestType(Module.SteerControlMode steerRequestType) Sets the type of control request to use for the steer motor.- Parameters:
steerRequestType- The type of control request to use for the steer motor- Returns:
- this request
-
withHeadingController
public ChassisRequest.RobotCentricFacingAngle withHeadingController(PhoenixPIDController headingController) Sets the PID controller used to maintain the desired heading. Users can specify the PID gains to change how aggressively to maintain heading.- Parameters:
headingController- The PID controller used to maintain the desired heading.- Returns:
- this request
-
withHeadingFeedforward
Sets the feedforward rotational velocity to add to the PID output. This improves tracking performance when the target heading is changing.- Parameters:
headingFeedforward- Feedforward rotational velocity in rad/s- Returns:
- this request
-