Swerve
pathplannerlib Index / Pathplannerlib / Util / Swerve
Auto-generated documentation for pathplannerlib.util.swerve module.
SwerveSetpoint
Signature
SwerveSetpointGenerator
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.
Signature
class SwerveSetpointGenerator:
def __init__(
self, config: RobotConfig, max_steer_velocity_rads_per_sec: float
) -> None: ...
See also
SwerveSetpointGenerator.flipHeading
Check if it would be faster to go to the opposite of the goal heading (and reverse drive direction).
Arguments
prev_to_goal
- The rotation from the previous state to the goal state (i.e. prev.inverse().rotateBy(goal)).
Returns
True if the shortest path to achieve this rotation involves flipping the drive direction.
Signature
SwerveSetpointGenerator.from_rots_per_sec
Create a new swerve setpoint generator
Arguments
config
- The robot configurationmax_steer_velocity
- The maximum rotation velocity of a swerve module, in rotations
Returns
A SwerveSetpointGenerator object
Signature
@classmethod
def from_rots_per_sec(
cls, config: RobotConfig, max_steer_velocity: float
) -> "SwerveSetpointGenerator": ...
See also
SwerveSetpointGenerator().generateSetpoint
Generate a new setpoint. Note: Do not discretize ChassisSpeeds passed into or returned from this method. This method will discretize the speeds for you.
Arguments
prev_setpoint
- The previous setpoint motion. Normally, you'd pass in the previous iteration setpoint instead of the actual measured/estimated kinematic state.desired_state_robot_relative
- The desired state of motion, such as from the driver sticks or a path following algorithm.dt
- The loop time.input_voltage
- 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.constraints
- he arbitrary constraints to respect along with the robot's max capabilities. If this is None, the generator will only limit setpoints by the robot's max capabilities.
Returns
A Setpoint object that satisfies all the kinematic/friction limits while converging to desired_state quickly.
Signature
def generateSetpoint(
self,
prev_setpoint: SwerveSetpoint,
desired_state_robot_relative: ChassisSpeeds,
dt: float,
input_voltage: float = None,
constraints: PathConstraints = None,
) -> SwerveSetpoint: ...