Package yams.math

Class LQRController

java.lang.Object
yams.math.LQRController

public class LQRController extends Object
Linear Quadratic Regulator (Regulator is a type of controller)
  • Constructor Details

  • Method Details

    • updateConfig

      public void updateConfig(LQRConfig config)
      Update LQR based off config.
      Parameters:
      config - LQRConfig
    • reset

      public void reset(Angle angle, AngularVelocity velocity)
      Reset the Arm or Flywheel LQR.
      Parameters:
      angle - Current angle.
      velocity - Current velocity.
    • reset

      public void reset(Distance distance, LinearVelocity velocity)
      Reset the Elevator LQR.
      Parameters:
      distance - Current distance.
      velocity - Current velocity.
    • calculate

      public Voltage calculate(Angle measured, Angle position, AngularVelocity velocity)
      Calculate the voltage for an Arm LQR
      Parameters:
      measured - Measured angle from the arm.
      position - Angle setpoint to go to.
      velocity - AngularVelocity setpoint to go to.
      Returns:
      Voltage to apply to the arm.
    • calculate

      public Voltage calculate(Distance measured, Distance position, LinearVelocity velocity)
      Calculate the voltage for a Elevator LQR
      Parameters:
      measured - Measured distance of the elevator.
      position - Setpoint distance of the elevator from the motion profile.
      velocity - Setpoint velocity of the elevator from the motion profile.
      Returns:
      Voltage to apply to the elevator.
    • calculate

      public Voltage calculate(AngularVelocity measured, AngularVelocity velocity)
      Calculate the voltage for a Flywheel LQR
      Parameters:
      measured - Measured velocity of the flywheel.
      velocity - Setpoint velocity of the flywheel.
      Returns:
      Voltage to apply to the flywheel.
    • calculate

      public Voltage calculate(LinearVelocity measured, LinearVelocity velocity)
      Calculate the voltage for a Flywheel LQR
      Parameters:
      measured - Measured velocity of the flywheel.
      velocity - Setpoint velocity of the flywheel.
      Returns:
      Voltage to apply to the flywheel.
    • getType

      public LQRConfig.LQRType getType()
      Get the type of LQR.
      Returns:
      LQRConfig.LQRType
    • getConfig

      public Optional<LQRConfig> getConfig()
      Get the LQRConfig for the LQR.
      Returns:
      LQRConfig