|
rsLQR
0.1
|
Solver that uses Riccati recursion to solve an LQR problem. More...
#include <riccati_solver.h>
Data Fields | |
| LQRProblem * | prob |
| Problem data. | |
| int | nhorizon |
| length of the time horizon | |
| int | nstates |
| size of state vector (n) | |
| int | ninputs |
| number of control inputs (m) | |
| int | nvars |
| total number of decision variables, including the dual variables | |
| double * | data |
| pointer to the beginning of the single block of memory allocated by the solver | |
| Matrix * | K |
| N-1 feedback gain matrices of size (m,n) | |
| Matrix * | d |
| N-1 feedforward gains of size (m,) | |
| Matrix * | P |
| N cost-to-go Hessians of size (n,n) | |
| Matrix * | p |
| N cost-to-go gradients of size (n,) | |
| Matrix * | X |
| State trajectory. N vectors of size (n,) | |
| Matrix * | U |
| Control trajectory. N-1 vectors of size (m,) | |
| Matrix * | Y |
| Lagrange multipliers. N vectors of size (n,) | |
| Matrix * | Qx |
| Gradient of the action-value function with respect to the state. N vectors of size (n,). | |
| Matrix * | Qu |
| Gradient of the action-value function with respect to the control. N vectors of size (m,). | |
| Matrix * | Qxx |
| Hessian of the action-value function with respect to the state. N vectors of size (n,n). | |
| Matrix * | Qux |
| Cross-term Hessian of the action-value function. N vectors of size (m,n). | |
| Matrix * | Quu |
| Hessian of the action-value function with respect to the control. N vectors of size (m,m). | |
| double | t_solve_ms |
| Total solve time in milliseconds. | |
| double | t_backward_pass_ms |
| Time spent in the backward pass in milliseconds. | |
| double | t_forward_pass_ms |
| Time spent in the forward pass in milliseconds. | |
Solver that uses Riccati recursion to solve an LQR problem.
Solves the generic LQR problem with affine terms using Riccati recursion and a forward simulation of the linear dynamics. Assumes problems are of the following form:
\begin{align*} \underset{x_{1:N}, u_{1:N-1}}{\text{minimize}} &&& \frac{1}{2} x_N^T Q_N + x_N + q_N^T x_N + \sum_{k-1}^{N-1} \frac{1}{2} x_k^T Q_k + x_k + q_k^T x_k + u_k^T R_k + u_k + r_k^T u_k \\ \text{subject to} &&& x_{k+1} = A_k x_k + B_k u_k + f_k \\ &&& x_1 = x_\text{init} \end{align*}
All the memory required by the solver is initialized upon the creation of the solver to avoid any dynamic memory allocations during the solve.
Use ndlqr_NewRiccatiSolver() to initialize a new solver, which much be paired with a single call to ndlqr_FreeRiccatiSolver() to free all of solver's memory.
Standard usage will typically look like the following: