|
YAMS
Yet Another Mechanism System
|
#include <LQRController.hpp>
Public Member Functions | |
| LQRController (LQRConfig config) | |
| void | UpdateConfig (LQRConfig config) |
| void | Reset (wpi::units::radian_t angle, wpi::units::radians_per_second_t velocity) |
| void | Reset (wpi::units::meter_t distance, wpi::units::meters_per_second_t velocity) |
| wpi::units::volt_t | Calculate (wpi::units::radian_t measured, wpi::units::radian_t position, wpi::units::radians_per_second_t velocity) |
| wpi::units::volt_t | Calculate (wpi::units::meter_t measured, wpi::units::meter_t position, wpi::units::meters_per_second_t velocity) |
| wpi::units::volt_t | Calculate (wpi::units::radians_per_second_t measured, wpi::units::radians_per_second_t velocity) |
| wpi::units::volt_t | Calculate (wpi::units::meters_per_second_t measured, wpi::units::meters_per_second_t velocity) |
| LQRConfig::LQRType | GetType () const |
| const std::optional< LQRConfig > & | GetConfig () const |
Linear Quadratic Regulator controller wrapper.
Wraps a WPILib LinearSystemLoop to provide a common Calculate() interface for flywheel (velocity), arm, and elevator (position + velocity) plant types.
Internally the LQR gain matrix and Kalman filter are heap-allocated alongside the LinearSystemLoop so that the loop's internal raw pointers remain valid for the lifetime of this object. Never copy or std::move an LQRController while it is in use.
|
explicit |
Construct an LQRController by building the loop from an LQRConfig.
| config | Fully-configured LQRConfig. |
| wpi::units::volt_t yams::math::LQRController::Calculate | ( | wpi::units::meter_t | measured, |
| wpi::units::meter_t | position, | ||
| wpi::units::meters_per_second_t | velocity | ||
| ) |
Calculate the next voltage output for a linear positional mechanism (elevator).
| measured | Current measured distance. |
| position | Target distance setpoint. |
| velocity | Target linear velocity setpoint. |
| wpi::units::volt_t yams::math::LQRController::Calculate | ( | wpi::units::meters_per_second_t | measured, |
| wpi::units::meters_per_second_t | velocity | ||
| ) |
Calculate the next voltage output for a linear velocity mechanism.
| measured | Current measured linear velocity. |
| velocity | Target linear velocity setpoint. |
| wpi::units::volt_t yams::math::LQRController::Calculate | ( | wpi::units::radian_t | measured, |
| wpi::units::radian_t | position, | ||
| wpi::units::radians_per_second_t | velocity | ||
| ) |
Calculate the next voltage output for an angular positional mechanism (arm).
| measured | Current measured angle. |
| position | Target angle setpoint. |
| velocity | Target angular velocity setpoint. |
| wpi::units::volt_t yams::math::LQRController::Calculate | ( | wpi::units::radians_per_second_t | measured, |
| wpi::units::radians_per_second_t | velocity | ||
| ) |
Calculate the next voltage output for an angular velocity mechanism (flywheel).
| measured | Current measured angular velocity. |
| velocity | Target angular velocity setpoint. |
| const std::optional< LQRConfig > & yams::math::LQRController::GetConfig | ( | ) | const |
Get the optional LQRConfig used to construct this controller.
| LQRConfig::LQRType yams::math::LQRController::GetType | ( | ) | const |
Get the configured LQR plant type.
| void yams::math::LQRController::Reset | ( | wpi::units::meter_t | distance, |
| wpi::units::meters_per_second_t | velocity | ||
| ) |
Reset the linear position+velocity state of the controller (elevator).
| distance | Current mechanism distance. |
| velocity | Current mechanism linear velocity. |
| void yams::math::LQRController::Reset | ( | wpi::units::radian_t | angle, |
| wpi::units::radians_per_second_t | velocity | ||
| ) |
Reset the angular position+velocity state of the controller (arm/elevator).
| angle | Current mechanism angle. |
| velocity | Current mechanism velocity. |
| void yams::math::LQRController::UpdateConfig | ( | LQRConfig | config | ) |
Replace the current LQR configuration and rebuild the internal loop.
| config | New LQRConfig to apply. |