Package com.marswars.swerve_lib
Class ChassisRequest.RobotCentric
java.lang.Object
com.marswars.swerve_lib.ChassisRequest.RobotCentric
- All Implemented Interfaces:
ChassisRequest
- Enclosing interface:
- ChassisRequest
Drives the swerve drivetrain in a robot-centric manner.
When users use this request, they specify the direction the robot should travel oriented against the robot itself, and the rate at which their robot should rotate about the center of the robot.
An example scenario is that the robot is oriented to the east, the VelocityX is +5 m/s, VelocityY is 0 m/s, and RotationRate is 0.5 rad/s. In this scenario, the robot would drive eastward at 5 m/s and turn counterclockwise at 0.5 rad/s.
-
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.doubleThe rotational deadband of the request.The desired chassis speeds (robot-relative)The type of control request to use for the steer motor. -
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.withRotationalDeadband(double rotationalDeadband) Sets the rotational deadband of the request.withSpeeds(ChassisSpeeds speeds) The linear and angular velocity to apply to the drivetrain, specified as ChassisSpeeds.withSteerRequestType(Module.SteerControlMode steerRequestType) Sets the type of control request to use for the steer motor.
-
Field Details
-
Speeds
The desired chassis speeds (robot-relative) -
Deadband
public double DeadbandThe allowable deadband of the request. -
RotationalDeadband
public double RotationalDeadbandThe rotational deadband of the request. -
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.
-
-
Constructor Details
-
RobotCentric
public RobotCentric()
-
-
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
The linear and angular velocity to apply to the drivetrain, specified as ChassisSpeeds. These speeds are assumed to be robot-relative.- Parameters:
speeds- Robot-relative chassis speeds to apply- 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
-
withCenterOfRotation
Sets the center of rotation of the request- Parameters:
centerOfRotation- The center of rotation the robot should rotate around.- Returns:
- this request
-
withDriveRequestType
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
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
-