|
RIT VEXU Core API
|
#include <linear_quadratic_regulator.h>
Public Member Functions | |
| template<int OUTPUTS> | |
| LinearQuadraticRegulator (LinearSystem< STATES, INPUTS, OUTPUTS > &plant, const VectorX &Qtolerances, const VectorU &Rtolerances, const double &dt) | |
| LinearQuadraticRegulator (const MatrixA &A, const MatrixB &B, const VectorX &Qtolerances, const VectorU &Rtolerances, const double &dt) | |
| LinearQuadraticRegulator (const MatrixA &A, const MatrixB &B, const EMat< STATES, STATES > &Q, const EMat< INPUTS, INPUTS > &R, const double &dt) | |
| VectorU | calculate (const VectorX &x, const VectorX &r) |
| template<int OUTPUTS> | |
| void | latency_compensate (LinearSystem< STATES, INPUTS, OUTPUTS > &plant, const double &dt, const double &input_delay) |
Class implements an LQR controller. This finds the optimal gain matrix K where:
u = K(r - x)
K is optimized to minimize a cost function:
∞
J = ∑ xₖᵀQxₖ + uₖᵀRuₖ k=0
Where Q and R are the state and control cost matrices.
| STATES | The number of states in the system. |
| INPUTS | The number of inputs to the system. |
|
inline |
Constructs an LQR given a plant, a vector of tolerances for the states and inputs, and the timestep in seconds.
| OUTPUTS | The number of outputs of the plant. |
| plant | The linear system to control. |
| Qtolerances | A vector of tolerances for each state. |
| Rtolerances | A vector of tolerances for each input. |
|
inline |
Constructs an LQR given state and input matrices, a vector of tolerances for the states and inputs, and the timestep in seconds.
| A | The state matrix of the linear system. |
| B | The input matrix of the linear system. |
| Qtolerances | A vector of tolerances for each state. |
| Rtolerances | A vector of tolerances for each input. |
|
inline |
Constructs an LQR given state and input matrices, the cost matrices of states and inputs, and the timestep in seconds.
| A | The state matrix of the linear system. |
| B | The input matrix of the linear system. |
| Q | The cost matrix of the states. |
| R | The cost matrix of the inputs. |
|
inline |
Computes the control input u as:
u = K(r - x)
| x | The current state. |
| r | The reference state. |
|
inline |
Recomputes K to work for a time delayed state.
Kdelay = K(A - BK)^(delay / dt)
| OUTPUTS | The number of outputs of the plant |
| plant | The linear system. |
| dt | The timestep in seconds. |
| input_delay | The time delay of the system. |