LTVUnicycleController
- class wpimath.LTVUnicycleController(*args, **kwargs)
Bases:
pybind11_objectThe linear time-varying unicycle controller has a similar form to the LQR, but the model used to compute the controller gain is the nonlinear unicycle model linearized around the drivetrain’s current state.
See section 8.9 in Controls Engineering in FRC for a derivation of the control law we used shown in theorem 8.9.1.
Overloaded function.
__init__(self: wpimath._wpimath.LTVUnicycleController, dt: wpimath.units.seconds) -> None
Constructs a linear time-varying unicycle controller with default maximum desired error tolerances of (x = 0.0625 m, y = 0.125 m, heading = 2 rad) and default maximum desired control effort of (linear velocity = 1 m/s, angular velocity = 2 rad/s).
- Parameters:
dt – Discretization timestep.
__init__(self: wpimath._wpimath.LTVUnicycleController, Qelems: Tuple[typing.SupportsFloat | typing.SupportsIndex, typing.SupportsFloat | typing.SupportsIndex, typing.SupportsFloat | typing.SupportsIndex], Relems: Tuple[typing.SupportsFloat | typing.SupportsIndex, typing.SupportsFloat | typing.SupportsIndex], dt: wpimath.units.seconds) -> None
Constructs a linear time-varying unicycle controller.
See https://docs.wpilib.org/en/stable/docs/software/advanced-controls/state-space/state-space-intro.html#lqr-tuning for how to select the tolerances.
- Parameters:
Qelems – The maximum desired error tolerance for each state (x, y, heading).
Relems – The maximum desired control effort for each input (linear velocity, angular velocity).
dt – Discretization timestep.
- atReference() bool
Returns true if the pose error is within tolerance of the reference.
- calculate(*args, **kwargs)
Overloaded function.
calculate(self: wpimath._wpimath.LTVUnicycleController, currentPose: wpimath._wpimath.Pose2d, poseRef: wpimath._wpimath.Pose2d, linearVelocityRef: wpimath.units.meters_per_second, angularVelocityRef: wpimath.units.radians_per_second) -> wpimath._wpimath.ChassisVelocities
Returns the linear and angular velocity outputs of the LTV controller.
The reference pose, linear velocity, and angular velocity should come from a drivetrain trajectory.
- Parameters:
currentPose – The current pose.
poseRef – The desired pose.
linearVelocityRef – The desired linear velocity.
angularVelocityRef – The desired angular velocity.
calculate(self: wpimath._wpimath.LTVUnicycleController, currentPose: wpimath._wpimath.Pose2d, desiredState: wpimath._wpimath.Trajectory.State) -> wpimath._wpimath.ChassisVelocities
Returns the linear and angular velocity outputs of the LTV controller.
The reference pose, linear velocity, and angular velocity should come from a drivetrain trajectory.
- Parameters:
currentPose – The current pose.
desiredState – The desired pose, linear velocity, and angular velocity from a trajectory.
- setEnabled(enabled: bool) None
Enables and disables the controller for troubleshooting purposes.
- Parameters:
enabled – If the controller is enabled or not.
- setTolerance(poseTolerance: wpimath._wpimath.Pose2d) None
Sets the pose error which is considered tolerable for use with AtReference().
- Parameters:
poseTolerance – Pose error which is tolerable.