LTVDifferentialDriveController

class wpimath.controller.LTVDifferentialDriveController(plant: wpimath._controls._controls.system.LinearSystem_2_2_2, trackwidth: meters, Qelems: Tuple[float, float, float, float, float], Relems: Tuple[float, float], dt: seconds)

Bases: pybind11_object

The linear time-varying differential drive controller has a similar form to the LQR, but the model used to compute the controller gain is the nonlinear model linearized around the drivetrain’s current state. We precomputed gains for important places in our state-space, then interpolated between them with a LUT to save computational resources.

See section 8.7 in Controls Engineering in FRC for a derivation of the control law we used shown in theorem 8.7.4.

Constructs a linear time-varying differential drive controller.

Parameters:
  • plant – The differential drive velocity plant.

  • trackwidth – The distance between the differential drive’s left and right wheels.

  • Qelems – The maximum desired error tolerance for each state.

  • Relems – The maximum desired control effort for each input.

  • dt – Discretization timestep. @throws std::domain_error if max velocity of plant with 12 V input <= 0.

atReference() bool

Returns true if the pose error is within tolerance of the reference.

calculate(*args, **kwargs)

Overloaded function.

  1. calculate(self: wpimath._controls._controls.controller.LTVDifferentialDriveController, currentPose: wpimath.geometry._geometry.Pose2d, leftVelocity: meters_per_second, rightVelocity: meters_per_second, poseRef: wpimath.geometry._geometry.Pose2d, leftVelocityRef: meters_per_second, rightVelocityRef: meters_per_second) -> wpimath._controls._controls.controller.DifferentialDriveWheelVoltages

Returns the left and right output voltages of the LTV controller.

The reference pose, linear velocity, and angular velocity should come from a drivetrain trajectory.

Parameters:
  • currentPose – The current pose.

  • leftVelocity – The current left velocity.

  • rightVelocity – The current right velocity.

  • poseRef – The desired pose.

  • leftVelocityRef – The desired left velocity.

  • rightVelocityRef – The desired right velocity.

  1. calculate(self: wpimath._controls._controls.controller.LTVDifferentialDriveController, currentPose: wpimath.geometry._geometry.Pose2d, leftVelocity: meters_per_second, rightVelocity: meters_per_second, desiredState: wpimath._controls._controls.trajectory.Trajectory.State) -> wpimath._controls._controls.controller.DifferentialDriveWheelVoltages

Returns the left and right output voltages of the LTV controller.

The reference pose, linear velocity, and angular velocity should come from a drivetrain trajectory.

Parameters:
  • currentPose – The current pose.

  • leftVelocity – The left velocity.

  • rightVelocity – The right velocity.

  • desiredState – The desired pose, linear velocity, and angular velocity from a trajectory.

setTolerance(poseTolerance: wpimath.geometry._geometry.Pose2d, leftVelocityTolerance: meters_per_second, rightVelocityTolerance: meters_per_second) None

Sets the pose error which is considered tolerable for use with AtReference().

Parameters:
  • poseTolerance – Pose error which is tolerable.

  • leftVelocityTolerance – Left velocity error which is tolerable.

  • rightVelocityTolerance – Right velocity error which is tolerable.