|
YAMS
Yet Another Mechanism System
|
#include <LQRConfig.hpp>
Public Types | |
| enum class | LQRType { FLYWHEEL , ARM , ELEVATOR } |
| using | Loop1 = wpi::math::LinearSystemLoop< 1, 1, 1 > |
| using | Loop2 = wpi::math::LinearSystemLoop< 2, 1, 1 > |
Public Member Functions | |
| LQRConfig & | WithType (LQRType type) |
| LQRConfig & | WithFlywheelSystem (const wpi::math::DCMotor &motor, double momentOfInertia, double gearing) |
| LQRConfig & | WithArmSystem (const wpi::math::DCMotor &motor, double momentOfInertia, double gearing) |
| LQRConfig & | WithElevatorSystem (const wpi::math::DCMotor &motor, double mass, double drumRadius, double gearing) |
| LQRConfig & | WithQElems (std::initializer_list< double > qElems) |
| LQRConfig & | WithRElems (std::initializer_list< double > rElems) |
| LQRConfig & | WithStateStdDevs (std::initializer_list< double > stateStdDevs) |
| LQRConfig & | WithMeasurementStdDevs (std::initializer_list< double > measStdDevs) |
| LQRConfig & | WithMaxVoltage (wpi::units::volt_t maxVoltage) |
| LQRConfig & | WithPeriod (wpi::units::second_t period) |
| LQRType | GetType () const |
| wpi::units::second_t | GetPeriod () const |
| wpi::units::volt_t | GetMaxVoltage () const |
| std::variant< wpi::math::LinearSystem< 1, 1, 1 >, wpi::math::LinearSystem< 2, 1, 1 > > | GetSystem () const |
| std::variant< Loop1, Loop2 > | GetLoop () const |
Friends | |
| class | LQRController |
Configuration for an LQR (Linear Quadratic Regulator) closed-loop controller.
Uses a fluent builder pattern; all With* methods return *this for chaining. After configuring the plant type, gains, and noise parameters call GetLoop() to obtain the ready-to-use LinearSystemLoop.
| using yams::math::LQRConfig::Loop1 = wpi::math::LinearSystemLoop<1, 1, 1> |
LinearSystemLoop type alias for 1-state plants (flywheel).
| using yams::math::LQRConfig::Loop2 = wpi::math::LinearSystemLoop<2, 1, 1> |
LinearSystemLoop type alias for 2-state plants (arm, elevator).
|
strong |
Build and return the complete LinearSystemLoop ready for use.
| wpi::units::volt_t yams::math::LQRConfig::GetMaxVoltage | ( | ) | const |
Get the configured maximum voltage.
| wpi::units::second_t yams::math::LQRConfig::GetPeriod | ( | ) | const |
Get the configured loop period.
| std::variant< wpi::math::LinearSystem< 1, 1, 1 >, wpi::math::LinearSystem< 2, 1, 1 > > yams::math::LQRConfig::GetSystem | ( | ) | const |
Build and return the linear plant model.
| LQRType yams::math::LQRConfig::GetType | ( | ) | const |
Get the configured LQR plant type.
| LQRConfig & yams::math::LQRConfig::WithArmSystem | ( | const wpi::math::DCMotor & | motor, |
| double | momentOfInertia, | ||
| double | gearing | ||
| ) |
Configure a single-jointed arm plant model.
| motor | DC motor model. |
| momentOfInertia | Moment of inertia of the arm (kg·m²). |
| gearing | Gear reduction from motor to arm joint. |
| LQRConfig & yams::math::LQRConfig::WithElevatorSystem | ( | const wpi::math::DCMotor & | motor, |
| double | mass, | ||
| double | drumRadius, | ||
| double | gearing | ||
| ) |
Configure an elevator plant model.
| motor | DC motor model. |
| mass | Carriage mass (kg). |
| drumRadius | Radius of the drum (m). |
| gearing | Gear reduction from motor to drum. |
| LQRConfig & yams::math::LQRConfig::WithFlywheelSystem | ( | const wpi::math::DCMotor & | motor, |
| double | momentOfInertia, | ||
| double | gearing | ||
| ) |
Configure a flywheel plant model.
| motor | DC motor model. |
| momentOfInertia | Moment of inertia of the flywheel (kg·m²). |
| gearing | Gear reduction from motor to flywheel. |
| LQRConfig & yams::math::LQRConfig::WithMaxVoltage | ( | wpi::units::volt_t | maxVoltage | ) |
Set the maximum voltage output of the LinearSystemLoop.
| maxVoltage | Maximum voltage (default 12 V). |
| LQRConfig & yams::math::LQRConfig::WithMeasurementStdDevs | ( | std::initializer_list< double > | measStdDevs | ) |
Set the Kalman filter measurement standard deviations.
| measStdDevs | Standard deviations of the encoder measurements. |
| LQRConfig & yams::math::LQRConfig::WithPeriod | ( | wpi::units::second_t | period | ) |
Set the loop period for the LQR.
| period | Loop period (default 20 ms). |
| LQRConfig & yams::math::LQRConfig::WithQElems | ( | std::initializer_list< double > | qElems | ) |
Set the Q matrix diagonal elements (state error tolerances).
Decrease values to more aggressively penalize state excursion.
| qElems | Q-matrix diagonal entries (one per state). |
| LQRConfig & yams::math::LQRConfig::WithRElems | ( | std::initializer_list< double > | rElems | ) |
Set the R matrix diagonal elements (control effort tolerances).
Decrease values to more aggressively penalize control effort. A good starting value is 12 (approximately the maximum battery voltage).
| rElems | R-matrix diagonal entries (one per input). |
| LQRConfig & yams::math::LQRConfig::WithStateStdDevs | ( | std::initializer_list< double > | stateStdDevs | ) |
Set the Kalman filter model standard deviations.
| stateStdDevs | Standard deviations of the model states. |
Set the LQR plant type explicitly.
| type | LQRType to use. |
|
friend |