PathPlannerLib
|
#include <SwerveSetpointGenerator.h>
Public Member Functions | |
SwerveSetpointGenerator () | |
SwerveSetpointGenerator (const RobotConfig &config, units::turns_per_second_t maxSteerVelocity) | |
SwerveSetpoint | generateSetpoint (SwerveSetpoint prevSetpoint, frc::ChassisSpeeds desiredStateRobotRelative, std::optional< PathConstraints > constraints, units::second_t dt, units::volt_t inputVoltage) |
SwerveSetpoint | generateSetpoint (SwerveSetpoint prevSetpoint, frc::ChassisSpeeds desiredStateRobotRelative, std::optional< PathConstraints > constraints, units::second_t dt) |
SwerveSetpoint | generateSetpoint (SwerveSetpoint prevSetpoint, frc::ChassisSpeeds desiredStateRobotRelative, units::second_t dt, units::volt_t inputVoltage) |
SwerveSetpoint | generateSetpoint (SwerveSetpoint prevSetpoint, frc::ChassisSpeeds desiredStateRobotRelative, units::second_t dt) |
Static Public Member Functions | |
static bool | flipHeading (frc::Rotation2d prevToGoal) |
static units::radian_t | unwrapAngle (double ref, double angle) |
Swerve setpoint generator based on a version created by FRC team 254.
Takes a prior setpoint, a desired setpoint, and outputs a new setpoint that respects all the kinematic constraints on module rotation and wheel velocity/torque, as well as preventing any forces acting on a module's wheel from exceeding the force of friction.
SwerveSetpointGenerator::SwerveSetpointGenerator | ( | ) |
Create a new swerve setpoint generator
SwerveSetpointGenerator::SwerveSetpointGenerator | ( | const RobotConfig & | config, |
units::turns_per_second_t | maxSteerVelocity | ||
) |
Create a new swerve setpoint generator
config | The robot configuration |
maxSteerVelocity | The maximum rotation velocity of a swerve module, in turns per second |
|
inlinestatic |
Check if it would be faster to go to the opposite of the goal heading (and reverse drive direction).
prevToGoal | The rotation from the previous state to the goal state (i.e. prev.inverse().rotateBy(goal)). |
SwerveSetpoint SwerveSetpointGenerator::generateSetpoint | ( | SwerveSetpoint | prevSetpoint, |
frc::ChassisSpeeds | desiredStateRobotRelative, | ||
std::optional< PathConstraints > | constraints, | ||
units::second_t | dt | ||
) |
Generate a new setpoint. Note: Do not discretize ChassisSpeeds passed into or returned from this method. This method will discretize the speeds for you.
Note: This method will automatically use the current robot controller input voltage.
prevSetpoint | The previous setpoint motion. Normally, you'd pass in the previous iteration setpoint instead of the actual measured/estimated kinematic state. |
desiredStateRobotRelative | The desired state of motion, such as from the driver sticks or a path following algorithm. |
constraints | The arbitrary constraints to respect along with the robot's max capabilities. If this is nullopt, the generator will only limit setpoints by the robot's max capabilities. |
dt | The loop time. |
SwerveSetpoint SwerveSetpointGenerator::generateSetpoint | ( | SwerveSetpoint | prevSetpoint, |
frc::ChassisSpeeds | desiredStateRobotRelative, | ||
std::optional< PathConstraints > | constraints, | ||
units::second_t | dt, | ||
units::volt_t | inputVoltage | ||
) |
Generate a new setpoint with explicit battery voltage. Note: Do not discretize ChassisSpeeds passed into or returned from this method. This method will discretize the speeds for you.
prevSetpoint | The previous setpoint motion. Normally, you'd pass in the previous iteration setpoint instead of the actual measured/estimated kinematic state. |
desiredStateRobotRelative | The desired state of motion, such as from the driver sticks or a path following algorithm. |
constraints | The arbitrary constraints to respect along with the robot's max capabilities. If this is nullopt, the generator will only limit setpoints by the robot's max capabilities. |
dt | The loop time. |
inputVoltage | The input voltage of the drive motor controllers, in volts. This can also be a static nominal voltage if you do not want the setpoint generator to react to changes in input voltage. If the given voltage is NaN, it will be assumed to be 12v. The input voltage will be clamped to a minimum of the robot controller's brownout voltage. |
|
inline |
Generate a new setpoint. Note: Do not discretize ChassisSpeeds passed into or returned from this method. This method will discretize the speeds for you.
Note: This method will automatically use the current robot controller input voltage.
prevSetpoint | The previous setpoint motion. Normally, you'd pass in the previous iteration setpoint instead of the actual measured/estimated kinematic state. |
desiredStateRobotRelative | The desired state of motion, such as from the driver sticks or a path following algorithm. |
dt | The loop time. |
|
inline |
Generate a new setpoint with explicit battery voltage. Note: Do not discretize ChassisSpeeds passed into or returned from this method. This method will discretize the speeds for you.
prevSetpoint | The previous setpoint motion. Normally, you'd pass in the previous iteration setpoint instead of the actual measured/estimated kinematic state. |
desiredStateRobotRelative | The desired state of motion, such as from the driver sticks or a path following algorithm. |
dt | The loop time. |
inputVoltage | The input voltage of the drive motor controllers, in volts. This can also be a static nominal voltage if you do not want the setpoint generator to react to changes in input voltage. If the given voltage is NaN, it will be assumed to be 12v. The input voltage will be clamped to a minimum of the robot controller's brownout voltage. |