97 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
98 modulesToApply[i]->Apply(moduleRequest.WithState({0_mps, parameters.moduleLocations[i].Angle()}));
114 this->DriveRequestType = std::move(newDriveRequestType);
127 this->DriveRequestType = std::move(newDriveRequestType);
128 return std::move(*
this);
141 this->SteerRequestType = std::move(newSteerRequestType);
154 this->SteerRequestType = std::move(newSteerRequestType);
155 return std::move(*
this);
232 Translation2d tmp{toApplyX * 1_s, toApplyY * 1_s};
234 toApplyX = tmp.X() / 1_s;
235 toApplyY = tmp.Y() / 1_s;
238 if (units::math::hypot(toApplyX, toApplyY) <
Deadband) {
243 toApplyOmega = 0_rad_per_s;
246 auto const speeds = ChassisSpeeds::Discretize(
247 ChassisSpeeds::FromFieldRelativeSpeeds(
248 {toApplyX, toApplyY, toApplyOmega}, parameters.
currentPose.Rotation()
262 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
263 modulesToApply[i]->Apply(moduleRequest.WithState(states[i]));
280 this->VelocityX = std::move(newVelocityX);
294 this->VelocityX = std::move(newVelocityX);
295 return std::move(*
this);
310 this->VelocityY = std::move(newVelocityY);
325 this->VelocityY = std::move(newVelocityY);
326 return std::move(*
this);
340 this->RotationalRate = std::move(newRotationalRate);
354 this->RotationalRate = std::move(newRotationalRate);
355 return std::move(*
this);
368 this->Deadband = std::move(newDeadband);
381 this->Deadband = std::move(newDeadband);
382 return std::move(*
this);
395 this->RotationalDeadband = std::move(newRotationalDeadband);
408 this->RotationalDeadband = std::move(newRotationalDeadband);
409 return std::move(*
this);
438 return std::move(*
this);
451 this->DriveRequestType = std::move(newDriveRequestType);
464 this->DriveRequestType = std::move(newDriveRequestType);
465 return std::move(*
this);
478 this->SteerRequestType = std::move(newSteerRequestType);
491 this->SteerRequestType = std::move(newSteerRequestType);
492 return std::move(*
this);
506 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
520 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
521 return std::move(*
this);
534 this->ForwardPerspective = std::move(newForwardPerspective);
547 this->ForwardPerspective = std::move(newForwardPerspective);
548 return std::move(*
this);
618 if (units::math::hypot(toApplyX, toApplyY) <
Deadband) {
623 toApplyOmega = 0_rad_per_s;
625 ChassisSpeeds
const speeds{toApplyX, toApplyY, toApplyOmega};
636 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
637 modulesToApply[i]->Apply(moduleRequest.WithState(states[i]));
654 this->VelocityX = std::move(newVelocityX);
668 this->VelocityX = std::move(newVelocityX);
669 return std::move(*
this);
684 this->VelocityY = std::move(newVelocityY);
699 this->VelocityY = std::move(newVelocityY);
700 return std::move(*
this);
714 this->RotationalRate = std::move(newRotationalRate);
728 this->RotationalRate = std::move(newRotationalRate);
729 return std::move(*
this);
742 this->Deadband = std::move(newDeadband);
755 this->Deadband = std::move(newDeadband);
756 return std::move(*
this);
769 this->RotationalDeadband = std::move(newRotationalDeadband);
782 this->RotationalDeadband = std::move(newRotationalDeadband);
783 return std::move(*
this);
812 return std::move(*
this);
825 this->DriveRequestType = std::move(newDriveRequestType);
838 this->DriveRequestType = std::move(newDriveRequestType);
839 return std::move(*
this);
852 this->SteerRequestType = std::move(newSteerRequestType);
865 this->SteerRequestType = std::move(newSteerRequestType);
866 return std::move(*
this);
880 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
894 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
895 return std::move(*
this);
924 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
925 modulesToApply[i]->Apply(moduleRequest.WithState({0_mps, ModuleDirection}));
957 return std::move(*
this);
970 this->DriveRequestType = std::move(newDriveRequestType);
983 this->DriveRequestType = std::move(newDriveRequestType);
984 return std::move(*
this);
997 this->SteerRequestType = std::move(newSteerRequestType);
1010 this->SteerRequestType = std::move(newSteerRequestType);
1011 return std::move(*
this);
1081 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
1086 modulesToApply[i]->Apply(moduleRequest.WithState(states[i]));
1103 this->
Speeds = std::move(newSpeeds);
1116 this->
Speeds = std::move(newSpeeds);
1117 return std::move(*
this);
1137 this->WheelForceFeedforwardsX = std::move(newWheelForceFeedforwardsX);
1157 this->WheelForceFeedforwardsX = std::move(newWheelForceFeedforwardsX);
1158 return std::move(*
this);
1178 this->WheelForceFeedforwardsY = std::move(newWheelForceFeedforwardsY);
1198 this->WheelForceFeedforwardsY = std::move(newWheelForceFeedforwardsY);
1199 return std::move(*
this);
1228 return std::move(*
this);
1241 this->DriveRequestType = std::move(newDriveRequestType);
1254 this->DriveRequestType = std::move(newDriveRequestType);
1255 return std::move(*
this);
1268 this->SteerRequestType = std::move(newSteerRequestType);
1281 this->SteerRequestType = std::move(newSteerRequestType);
1282 return std::move(*
this);
1296 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
1310 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
1311 return std::move(*
this);
1373 auto fieldSpeeds =
Speeds;
1378 fieldSpeeds.vx = tmp.X() / 1_s;
1379 fieldSpeeds.vy = tmp.Y() / 1_s;
1382 auto const robotSpeeds = ChassisSpeeds::Discretize(
1383 ChassisSpeeds::FromFieldRelativeSpeeds(
1399 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
1404 Translation2d tmp{wheelForceFeedforwardX * 1_m/1_N, wheelForceFeedforwardY * 1_m/1_N};
1410 tmp = tmp.RotateBy(-parameters.
currentPose.Rotation());
1412 wheelForceFeedforwardX = tmp.X() * 1_N/1_m;
1413 wheelForceFeedforwardY = tmp.Y() * 1_N/1_m;
1415 moduleRequest.WithWheelForceFeedforwardX(wheelForceFeedforwardX)
1416 .WithWheelForceFeedforwardY(wheelForceFeedforwardY);
1419 modulesToApply[i]->Apply(moduleRequest.WithState(states[i]));
1435 this->
Speeds = std::move(newSpeeds);
1448 this->
Speeds = std::move(newSpeeds);
1449 return std::move(*
this);
1469 this->WheelForceFeedforwardsX = std::move(newWheelForceFeedforwardsX);
1489 this->WheelForceFeedforwardsX = std::move(newWheelForceFeedforwardsX);
1490 return std::move(*
this);
1510 this->WheelForceFeedforwardsY = std::move(newWheelForceFeedforwardsY);
1530 this->WheelForceFeedforwardsY = std::move(newWheelForceFeedforwardsY);
1531 return std::move(*
this);
1560 return std::move(*
this);
1573 this->DriveRequestType = std::move(newDriveRequestType);
1586 this->DriveRequestType = std::move(newDriveRequestType);
1587 return std::move(*
this);
1600 this->SteerRequestType = std::move(newSteerRequestType);
1613 this->SteerRequestType = std::move(newSteerRequestType);
1614 return std::move(*
this);
1628 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
1642 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
1643 return std::move(*
this);
1656 this->ForwardPerspective = std::move(newForwardPerspective);
1669 this->ForwardPerspective = std::move(newForwardPerspective);
1670 return std::move(*
this);
1781 parameters.
currentPose.Rotation().Radians().value(),
1782 angleToFace.Radians().value(),
1804 .
Apply(parameters, modulesToApply);
1839 this->VelocityX = std::move(newVelocityX);
1855 this->VelocityY = std::move(newVelocityY);
1888 this->TargetRateFeedforward = std::move(newTargetRateFeedforward);
1902 this->Deadband = std::move(newDeadband);
1916 this->RotationalDeadband = std::move(newRotationalDeadband);
1931 this->MaxAbsRotationalRate = std::move(newMaxAbsRotationalRate);
1960 this->DriveRequestType = std::move(newDriveRequestType);
1974 this->SteerRequestType = std::move(newSteerRequestType);
1989 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
2003 this->ForwardPerspective = std::move(newForwardPerspective);
2117 parameters.
currentPose.Rotation().Radians().value(),
2118 angleToFace.Radians().value(),
2139 .
Apply(parameters, modulesToApply);
2174 this->VelocityX = std::move(newVelocityX);
2190 this->VelocityY = std::move(newVelocityY);
2223 this->TargetRateFeedforward = std::move(newTargetRateFeedforward);
2237 this->Deadband = std::move(newDeadband);
2251 this->RotationalDeadband = std::move(newRotationalDeadband);
2266 this->MaxAbsRotationalRate = std::move(newMaxAbsRotationalRate);
2295 this->DriveRequestType = std::move(newDriveRequestType);
2309 this->SteerRequestType = std::move(newSteerRequestType);
2324 this->DesaturateWheelSpeeds = std::move(newDesaturateWheelSpeeds);
2339 this->ForwardPerspective = std::move(newForwardPerspective);
2357 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
2358 switch (modulesToApply[i]->GetSteerClosedLoopOutputType()) {
2360 modulesToApply[i]->Apply(
2366 modulesToApply[i]->Apply(
2384 this->VoltsToApply = volts;
2395 this->VoltsToApply = volts;
2396 return std::move(*
this);
2424 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
2426 auto const driveVoltage = speed / parameters.
kMaxSpeed * 12_V;
2428 auto const angle = parameters.
moduleLocations[i].Angle() + Rotation2d{90_deg};
2430 switch (modulesToApply[i]->GetSteerClosedLoopOutputType()) {
2432 modulesToApply[i]->Apply(
2438 modulesToApply[i]->Apply(
2456 this->RotationalRate = rotationalRate;
2467 this->RotationalRate = rotationalRate;
2468 return std::move(*
this);
2485 for (
size_t i = 0; i < modulesToApply.size(); ++i) {
2499 this->VoltsToApply = volts;
2510 this->VoltsToApply = volts;
2511 return std::move(*
this);
Request coast neutral output of actuator.
Definition CoastOut.hpp:21
Requires Phoenix Pro; Request PID to target position with torque current feedforward.
Definition PositionTorqueCurrentFOC.hpp:27
Request PID to target position with voltage feedforward.
Definition PositionVoltage.hpp:26
Request a specified voltage.
Definition VoltageOut.hpp:24
Phoenix-centric PID controller taken from WPI's frc#PIDController class.
Definition PhoenixPIDController.hpp:22
double Calculate(double measurement, double setpoint, units::second_t currentTimestamp)
Returns the next output of the PID controller.
void EnableContinuousInput(double minimumInput, double maximumInput)
Enables continuous input.
void SetPID(double Kp, double Ki, double Kd)
Sets the PID Controller gain parameters.
static void DesaturateWheelSpeeds(WheelSpeeds *moduleStates, units::meters_per_second_t attainableMaxSpeed)
Renormalizes the wheel speeds if any individual speed is above the specified maximum.
WheelSpeeds ToSwerveModuleStates(ChassisSpeeds const &chassisSpeeds, Translation2d const ¢erOfRotation=Translation2d{})
Performs inverse kinematics to return the module states from a desired chassis velocity.
Accepts a generic field-centric ChassisSpeeds to apply to the drivetrain.
Definition SwerveRequest.hpp:1320
ApplyFieldSpeeds && WithWheelForceFeedforwardsY(std::vector< units::newton_t > newWheelForceFeedforwardsY) &&
Modifies the WheelForceFeedforwardsY parameter and returns itself.
Definition SwerveRequest.hpp:1528
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:1364
ApplyFieldSpeeds && WithWheelForceFeedforwardsX(std::vector< units::newton_t > newWheelForceFeedforwardsX) &&
Modifies the WheelForceFeedforwardsX parameter and returns itself.
Definition SwerveRequest.hpp:1487
ApplyFieldSpeeds && WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective) &&
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:1667
ForwardPerspectiveValue ForwardPerspective
The perspective to use when determining which direction is forward.
Definition SwerveRequest.hpp:1369
ApplyFieldSpeeds & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1571
ApplyFieldSpeeds && WithCenterOfRotation(Translation2d newCenterOfRotation) &&
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:1557
ApplyFieldSpeeds & WithWheelForceFeedforwardsY(std::vector< units::newton_t > newWheelForceFeedforwardsY) &
Modifies the WheelForceFeedforwardsY parameter and returns itself.
Definition SwerveRequest.hpp:1508
ApplyFieldSpeeds & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:1626
ChassisSpeeds Speeds
The field-centric chassis speeds to apply to the drivetrain.
Definition SwerveRequest.hpp:1325
ApplyFieldSpeeds & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1598
ApplyFieldSpeeds & WithWheelForceFeedforwardsX(std::vector< units::newton_t > newWheelForceFeedforwardsX) &
Modifies the WheelForceFeedforwardsX parameter and returns itself.
Definition SwerveRequest.hpp:1467
ApplyFieldSpeeds && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1611
std::vector< units::newton_t > WheelForceFeedforwardsX
Field-centric wheel force feedforwards to apply in the X direction.
Definition SwerveRequest.hpp:1336
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:1371
ApplyFieldSpeeds && WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &&
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:1640
ApplyFieldSpeeds & WithSpeeds(ChassisSpeeds newSpeeds) &
Modifies the Speeds parameter and returns itself.
Definition SwerveRequest.hpp:1433
std::vector< units::newton_t > WheelForceFeedforwardsY
Field-centric wheel force feedforwards to apply in the Y direction.
Definition SwerveRequest.hpp:1347
Translation2d CenterOfRotation
The center of rotation to rotate around.
Definition SwerveRequest.hpp:1351
ApplyFieldSpeeds && WithSpeeds(ChassisSpeeds newSpeeds) &&
Modifies the Speeds parameter and returns itself.
Definition SwerveRequest.hpp:1446
ApplyFieldSpeeds & WithCenterOfRotation(Translation2d newCenterOfRotation) &
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:1543
ApplyFieldSpeeds && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1584
ApplyFieldSpeeds & WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective) &
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:1654
Accepts a generic robot-centric ChassisSpeeds to apply to the drivetrain.
Definition SwerveRequest.hpp:1023
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:1070
ApplyRobotSpeeds && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1279
ChassisSpeeds Speeds
The robot-centric chassis speeds to apply to the drivetrain.
Definition SwerveRequest.hpp:1029
std::vector< units::newton_t > WheelForceFeedforwardsY
Robot-centric wheel force feedforwards to apply in the Y direction.
Definition SwerveRequest.hpp:1051
std::vector< units::newton_t > WheelForceFeedforwardsX
Robot-centric wheel force feedforwards to apply in the X direction.
Definition SwerveRequest.hpp:1040
ApplyRobotSpeeds && WithCenterOfRotation(Translation2d newCenterOfRotation) &&
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:1225
ApplyRobotSpeeds & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1239
ApplyRobotSpeeds & WithSpeeds(ChassisSpeeds newSpeeds) &
Modifies the Speeds parameter and returns itself.
Definition SwerveRequest.hpp:1101
ApplyRobotSpeeds & WithWheelForceFeedforwardsX(std::vector< units::newton_t > newWheelForceFeedforwardsX) &
Modifies the WheelForceFeedforwardsX parameter and returns itself.
Definition SwerveRequest.hpp:1135
ApplyRobotSpeeds && WithSpeeds(ChassisSpeeds newSpeeds) &&
Modifies the Speeds parameter and returns itself.
Definition SwerveRequest.hpp:1114
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:1068
ApplyRobotSpeeds & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1266
ApplyRobotSpeeds & WithWheelForceFeedforwardsY(std::vector< units::newton_t > newWheelForceFeedforwardsY) &
Modifies the WheelForceFeedforwardsY parameter and returns itself.
Definition SwerveRequest.hpp:1176
ApplyRobotSpeeds & WithCenterOfRotation(Translation2d newCenterOfRotation) &
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:1211
ApplyRobotSpeeds && WithWheelForceFeedforwardsY(std::vector< units::newton_t > newWheelForceFeedforwardsY) &&
Modifies the WheelForceFeedforwardsY parameter and returns itself.
Definition SwerveRequest.hpp:1196
ApplyRobotSpeeds && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1252
Translation2d CenterOfRotation
The center of rotation to rotate around.
Definition SwerveRequest.hpp:1055
ApplyRobotSpeeds && WithWheelForceFeedforwardsX(std::vector< units::newton_t > newWheelForceFeedforwardsX) &&
Modifies the WheelForceFeedforwardsX parameter and returns itself.
Definition SwerveRequest.hpp:1155
ApplyRobotSpeeds && WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &&
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:1308
ApplyRobotSpeeds & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:1294
Drives the swerve drivetrain in a field-centric manner, maintaining a specified heading angle to ensu...
Definition SwerveRequest.hpp:1689
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:1748
FieldCentricFacingAngle & WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband)
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:1914
FieldCentricFacingAngle & WithMaxAbsRotationalRate(units::radians_per_second_t newMaxAbsRotationalRate)
Modifies the MaxAbsRotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:1929
FieldCentricFacingAngle & WithSteerRequestType(impl::SteerRequestType newSteerRequestType)
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1972
Rotation2d TargetDirection
The desired direction to face.
Definition SwerveRequest.hpp:1708
units::radians_per_second_t MaxAbsRotationalRate
The maximum absolute rotational rate to allow.
Definition SwerveRequest.hpp:1729
units::meters_per_second_t VelocityX
The velocity in the X direction.
Definition SwerveRequest.hpp:1695
FieldCentricFacingAngle & WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective)
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:2001
FieldCentricFacingAngle & WithTargetDirection(Rotation2d newTargetDirection)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:1869
FieldCentricFacingAngle & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds)
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:1987
PhoenixPIDController HeadingController
The PID controller used to maintain the desired heading.
Definition SwerveRequest.hpp:1764
units::radians_per_second_t TargetRateFeedforward
The rotational rate feedforward to add to the output of the heading controller, in radians per second...
Definition SwerveRequest.hpp:1715
Translation2d CenterOfRotation
The center of rotation the robot should rotate around.
Definition SwerveRequest.hpp:1734
FieldCentricFacingAngle()
Definition SwerveRequest.hpp:1766
FieldCentricFacingAngle & WithVelocityY(units::meters_per_second_t newVelocityY)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:1853
FieldCentricFacingAngle & WithVelocityX(units::meters_per_second_t newVelocityX)
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:1837
units::meters_per_second_t Deadband
The allowable deadband of the request.
Definition SwerveRequest.hpp:1720
units::meters_per_second_t VelocityY
The velocity in the Y direction.
Definition SwerveRequest.hpp:1701
FieldCentricFacingAngle & WithDeadband(units::meters_per_second_t newDeadband)
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:1900
units::radians_per_second_t RotationalDeadband
The rotational deadband of the request.
Definition SwerveRequest.hpp:1724
FieldCentricFacingAngle & WithDriveRequestType(impl::DriveRequestType newDriveRequestType)
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1958
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:1771
FieldCentricFacingAngle & WithTargetRateFeedforward(units::radians_per_second_t newTargetRateFeedforward)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:1886
FieldCentricFacingAngle & WithCenterOfRotation(Translation2d newCenterOfRotation)
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:1944
FieldCentricFacingAngle & WithHeadingPID(double kP, double kI, double kD)
Modifies the PID gains of the HeadingController parameter and returns itself.
Definition SwerveRequest.hpp:1822
ForwardPerspectiveValue ForwardPerspective
The perspective to use when determining which direction is forward.
Definition SwerveRequest.hpp:1753
Drives the swerve drivetrain in a field-centric manner.
Definition SwerveRequest.hpp:172
FieldCentric && WithRotationalRate(units::radians_per_second_t newRotationalRate) &&
Modifies the RotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:352
FieldCentric && WithCenterOfRotation(Translation2d newCenterOfRotation) &&
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:435
FieldCentric && WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband) &&
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:406
FieldCentric & WithCenterOfRotation(Translation2d newCenterOfRotation) &
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:421
FieldCentric && WithVelocityY(units::meters_per_second_t newVelocityY) &&
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:323
FieldCentric && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:489
FieldCentric & WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband) &
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:393
units::meters_per_second_t Deadband
The allowable deadband of the request.
Definition SwerveRequest.hpp:194
FieldCentric & WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective) &
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:532
units::radians_per_second_t RotationalRate
The angular rate to rotate at.
Definition SwerveRequest.hpp:190
units::meters_per_second_t VelocityY
The velocity in the Y direction.
Definition SwerveRequest.hpp:184
FieldCentric & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:476
FieldCentric && WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective) &&
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:545
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:224
FieldCentric && WithDeadband(units::meters_per_second_t newDeadband) &&
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:379
units::meters_per_second_t VelocityX
The velocity in the X direction.
Definition SwerveRequest.hpp:178
Translation2d CenterOfRotation
The center of rotation the robot should rotate around.
Definition SwerveRequest.hpp:203
FieldCentric && WithVelocityX(units::meters_per_second_t newVelocityX) &&
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:292
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:217
ForwardPerspectiveValue ForwardPerspective
The perspective to use when determining which direction is forward.
Definition SwerveRequest.hpp:222
FieldCentric && WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &&
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:518
FieldCentric & WithDeadband(units::meters_per_second_t newDeadband) &
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:366
FieldCentric & WithRotationalRate(units::radians_per_second_t newRotationalRate) &
Modifies the RotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:338
FieldCentric & WithVelocityY(units::meters_per_second_t newVelocityY) &
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:308
FieldCentric & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:449
units::radians_per_second_t RotationalDeadband
The rotational deadband of the request.
Definition SwerveRequest.hpp:198
FieldCentric & WithVelocityX(units::meters_per_second_t newVelocityX) &
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:278
FieldCentric && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:462
FieldCentric & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:504
Does nothing to the swerve module state.
Definition SwerveRequest.hpp:67
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const &, std::span< std::unique_ptr< impl::SwerveModuleImpl > const >) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:69
Sets the swerve drive modules to point to a specified direction.
Definition SwerveRequest.hpp:902
PointWheelsAt && WithModuleDirection(Rotation2d newModuleDirection) &&
Modifies the ModuleDirection parameter and returns itself.
Definition SwerveRequest.hpp:954
PointWheelsAt && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:981
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:918
PointWheelsAt && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:1008
PointWheelsAt & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:968
PointWheelsAt & WithModuleDirection(Rotation2d newModuleDirection) &
Modifies the ModuleDirection parameter and returns itself.
Definition SwerveRequest.hpp:940
Rotation2d ModuleDirection
The direction to point the modules toward.
Definition SwerveRequest.hpp:908
PointWheelsAt & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:995
Drives the swerve drivetrain in a robot-centric manner, maintaining a specified heading angle to ensu...
Definition SwerveRequest.hpp:2024
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:2107
units::radians_per_second_t TargetRateFeedforward
The rotational rate feedforward to add to the output of the heading controller, in radians per second...
Definition SwerveRequest.hpp:2050
ForwardPerspectiveValue ForwardPerspective
The perspective to use when determining which direction is forward for the target heading.
Definition SwerveRequest.hpp:2089
units::meters_per_second_t Deadband
The allowable deadband of the request.
Definition SwerveRequest.hpp:2055
units::meters_per_second_t VelocityY
The velocity in the Y direction.
Definition SwerveRequest.hpp:2036
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:2083
Translation2d CenterOfRotation
The center of rotation the robot should rotate around.
Definition SwerveRequest.hpp:2069
units::radians_per_second_t RotationalDeadband
The rotational deadband of the request.
Definition SwerveRequest.hpp:2059
RobotCentricFacingAngle & WithMaxAbsRotationalRate(units::radians_per_second_t newMaxAbsRotationalRate)
Modifies the MaxAbsRotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:2264
RobotCentricFacingAngle & WithTargetRateFeedforward(units::radians_per_second_t newTargetRateFeedforward)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:2221
RobotCentricFacingAngle & WithSteerRequestType(impl::SteerRequestType newSteerRequestType)
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:2307
RobotCentricFacingAngle & WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband)
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:2249
RobotCentricFacingAngle & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds)
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:2322
RobotCentricFacingAngle & WithForwardPerspective(ForwardPerspectiveValue newForwardPerspective)
Modifies the ForwardPerspective parameter and returns itself.
Definition SwerveRequest.hpp:2337
RobotCentricFacingAngle & WithVelocityY(units::meters_per_second_t newVelocityY)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:2188
RobotCentricFacingAngle()
Definition SwerveRequest.hpp:2102
RobotCentricFacingAngle & WithDeadband(units::meters_per_second_t newDeadband)
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:2235
RobotCentricFacingAngle & WithHeadingPID(double kP, double kI, double kD)
Modifies the PID gains of the HeadingController parameter and returns itself.
Definition SwerveRequest.hpp:2157
units::meters_per_second_t VelocityX
The velocity in the X direction.
Definition SwerveRequest.hpp:2030
PhoenixPIDController HeadingController
The PID controller used to maintain the desired heading.
Definition SwerveRequest.hpp:2100
RobotCentricFacingAngle & WithCenterOfRotation(Translation2d newCenterOfRotation)
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:2279
RobotCentricFacingAngle & WithTargetDirection(Rotation2d newTargetDirection)
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:2204
Rotation2d TargetDirection
The desired direction to face.
Definition SwerveRequest.hpp:2043
units::radians_per_second_t MaxAbsRotationalRate
The maximum absolute rotational rate to allow.
Definition SwerveRequest.hpp:2064
RobotCentricFacingAngle & WithDriveRequestType(impl::DriveRequestType newDriveRequestType)
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:2293
RobotCentricFacingAngle & WithVelocityX(units::meters_per_second_t newVelocityX)
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:2172
Drives the swerve drivetrain in a robot-centric manner.
Definition SwerveRequest.hpp:565
units::radians_per_second_t RotationalRate
The angular rate to rotate at.
Definition SwerveRequest.hpp:583
RobotCentric & WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband) &
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:767
RobotCentric & WithCenterOfRotation(Translation2d newCenterOfRotation) &
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:795
bool DesaturateWheelSpeeds
Whether to desaturate wheel speeds before applying.
Definition SwerveRequest.hpp:611
RobotCentric && WithDeadband(units::meters_per_second_t newDeadband) &&
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:753
units::meters_per_second_t VelocityY
The velocity in the Y direction.
Definition SwerveRequest.hpp:577
RobotCentric && WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &&
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:892
RobotCentric && WithRotationalDeadband(units::radians_per_second_t newRotationalDeadband) &&
Modifies the RotationalDeadband parameter and returns itself.
Definition SwerveRequest.hpp:780
RobotCentric && WithRotationalRate(units::radians_per_second_t newRotationalRate) &&
Modifies the RotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:726
units::radians_per_second_t RotationalDeadband
The rotational deadband of the request.
Definition SwerveRequest.hpp:592
RobotCentric && WithVelocityX(units::meters_per_second_t newVelocityX) &&
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:666
RobotCentric & WithDeadband(units::meters_per_second_t newDeadband) &
Modifies the Deadband parameter and returns itself.
Definition SwerveRequest.hpp:740
units::meters_per_second_t VelocityX
The velocity in the X direction.
Definition SwerveRequest.hpp:571
RobotCentric & WithRotationalRate(units::radians_per_second_t newRotationalRate) &
Modifies the RotationalRate parameter and returns itself.
Definition SwerveRequest.hpp:712
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:613
RobotCentric && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:863
Translation2d CenterOfRotation
The center of rotation the robot should rotate around.
Definition SwerveRequest.hpp:597
RobotCentric && WithCenterOfRotation(Translation2d newCenterOfRotation) &&
Modifies the CenterOfRotation parameter and returns itself.
Definition SwerveRequest.hpp:809
RobotCentric && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:836
units::meters_per_second_t Deadband
The allowable deadband of the request.
Definition SwerveRequest.hpp:588
RobotCentric & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:823
RobotCentric & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:850
RobotCentric & WithVelocityX(units::meters_per_second_t newVelocityX) &
Modifies the VelocityX parameter and returns itself.
Definition SwerveRequest.hpp:652
RobotCentric & WithVelocityY(units::meters_per_second_t newVelocityY) &
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:682
RobotCentric && WithVelocityY(units::meters_per_second_t newVelocityY) &&
Modifies the VelocityY parameter and returns itself.
Definition SwerveRequest.hpp:697
RobotCentric & WithDesaturateWheelSpeeds(bool newDesaturateWheelSpeeds) &
Modifies the DesaturateWheelSpeeds parameter and returns itself.
Definition SwerveRequest.hpp:878
Sets the swerve drive module states to point inward on the robot in an "X" fashion,...
Definition SwerveRequest.hpp:80
SwerveDriveBrake & WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:112
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:91
SwerveDriveBrake && WithDriveRequestType(impl::DriveRequestType newDriveRequestType) &&
Modifies the DriveRequestType parameter and returns itself.
Definition SwerveRequest.hpp:125
SwerveDriveBrake && WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &&
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:152
SwerveDriveBrake & WithSteerRequestType(impl::SteerRequestType newSteerRequestType) &
Modifies the SteerRequestType parameter and returns itself.
Definition SwerveRequest.hpp:139
Container for all the Swerve Requests.
Definition SwerveRequest.hpp:46
virtual ~SwerveRequest()=default
virtual ctre::phoenix::StatusCode Apply(ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply)=0
Applies this swerve request to the given modules.
SysId-specific SwerveRequest to characterize the rotational characteristics of a swerve drivetrain.
Definition SwerveRequest.hpp:2415
units::radians_per_second_t RotationalRate
The angular rate to rotate at, in radians per second.
Definition SwerveRequest.hpp:2420
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:2422
SysIdSwerveRotation && WithRotationalRate(units::radians_per_second_t rotationalRate) &&
Update the angular rate to rotate at, in radians per second.
Definition SwerveRequest.hpp:2465
SysIdSwerveRotation & WithRotationalRate(units::radians_per_second_t rotationalRate) &
Update the angular rate to rotate at, in radians per second.
Definition SwerveRequest.hpp:2454
SysId-specific SwerveRequest to characterize the steer module characteristics of a swerve drivetrain.
Definition SwerveRequest.hpp:2476
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:2483
SysIdSwerveSteerGains && WithVolts(units::volt_t volts) &&
Update the voltage to apply to the drive wheels.
Definition SwerveRequest.hpp:2508
units::volt_t VoltsToApply
Voltage to apply to drive wheels.
Definition SwerveRequest.hpp:2481
SysIdSwerveSteerGains & WithVolts(units::volt_t volts) &
Update the voltage to apply to the drive wheels.
Definition SwerveRequest.hpp:2497
SysId-specific SwerveRequest to characterize the translational characteristics of a swerve drivetrain...
Definition SwerveRequest.hpp:2348
SysIdSwerveTranslation & WithVolts(units::volt_t volts) &
Sets the voltage to apply to drive wheels.
Definition SwerveRequest.hpp:2382
SysIdSwerveTranslation && WithVolts(units::volt_t volts) &&
Sets the voltage to apply to drive wheels.
Definition SwerveRequest.hpp:2393
units::volt_t VoltsToApply
Voltage to apply to drive wheels.
Definition SwerveRequest.hpp:2353
ctre::phoenix::StatusCode Apply(SwerveRequest::ControlParameters const ¶meters, std::span< std::unique_ptr< impl::SwerveModuleImpl > const > modulesToApply) override
Applies this swerve request to the given modules.
Definition SwerveRequest.hpp:2355
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
static constexpr int OK
No Error.
Definition StatusCodes.h:35
SteerRequestType
All possible control requests for the module steer motor.
Definition SwerveModuleImpl.hpp:25
@ Position
Control the drive motor using an unprofiled position request.
DriveRequestType
All possible control requests for the module drive motor.
Definition SwerveModuleImpl.hpp:41
@ OpenLoopVoltage
Control the drive motor using an open-loop voltage request.
ForwardPerspectiveValue
In field-centric control, the direction of "forward" is sometimes different depending on perspective.
Definition SwerveRequest.hpp:21
@ BlueAlliance
"Forward" (positive X) is always from the perspective of the blue alliance (i.e.
@ OperatorPerspective
"Forward" (positive X) is determined from the operator's perspective.
@ TorqueCurrentFOC
Requires Pro.
Definition motor_constants.h:14
Contains everything the control requests need to calculate the module state.
Definition SwerveDrivetrainImpl.hpp:141
units::second_t timestamp
The timestamp of the current control apply, in the timebase of utils::GetCurrentTime()
Definition SwerveDrivetrainImpl.hpp:156
units::meters_per_second_t kMaxSpeed
The max speed of the robot at 12 V output.
Definition SwerveDrivetrainImpl.hpp:147
units::second_t updatePeriod
The update period of control apply.
Definition SwerveDrivetrainImpl.hpp:158
impl::SwerveDriveKinematics * kinematics
The kinematics object used for control.
Definition SwerveDrivetrainImpl.hpp:143
Pose2d currentPose
The current pose of the robot.
Definition SwerveDrivetrainImpl.hpp:154
Rotation2d operatorForwardDirection
The forward direction from the operator perspective.
Definition SwerveDrivetrainImpl.hpp:150
Translation2d const * moduleLocations
The locations of the swerve modules.
Definition SwerveDrivetrainImpl.hpp:145
Contains everything the swerve module needs to apply a request.
Definition SwerveModuleImpl.hpp:66
ModuleRequest & WithSteerRequest(SteerRequestType newSteerRequest)
Modifies the SteerRequest parameter and returns itself.
Definition SwerveModuleImpl.hpp:190
ModuleRequest & WithDriveRequest(DriveRequestType newDriveRequest)
Modifies the DriveRequest parameter and returns itself.
Definition SwerveModuleImpl.hpp:177
ModuleRequest & WithUpdatePeriod(units::second_t newUpdatePeriod)
Modifies the UpdatePeriod parameter and returns itself.
Definition SwerveModuleImpl.hpp:205