ulqr  0.1.0
RiccatiSolver Struct Reference

Solver that uses Riccati recursion to solve an LQR problem. More...

#include <riccati_solver.h>

Data Fields

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
 
KnotPointZ
 state and control trajectory
 
LQRDatalqrdata
 LQR Problem data.
 
double * data
 pointer to the beginning of the single block of memory allocated by the solver
 
Matrix x0
 Initial state.
 
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.
 

Detailed Description

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.

Construction and destruction

Use ulqr_NewRiccatiSolver() to initialize a new solver, which much be paired with a single call to ulqr_FreeRiccatiSolver() to free all of solver's memory.

Typical Usage

Standard usage will typically look like the following:

LQRProblem* lqrprob = ulqr_ReadTestLQRProblem(); // your data here
double* soln = (double*) malloc(solver->nvars * sizeof(double));
ulqr_CopyRiccatiSolution(solver, soln);
ulqr_FreeLQRProblem();
free(soln);

Methods


The documentation for this struct was generated from the following file:
ulqr_SolveRiccati
int ulqr_SolveRiccati(RiccatiSolver *solver)
Solve the LQR problem using Riccati recursion and a forward simulation of the linear dynamics.
Definition: riccati_solve.c:11
RiccatiSolver
Solver that uses Riccati recursion to solve an LQR problem.
Definition: riccati_solver.h:63
ulqr_NewRiccatiSolver
RiccatiSolver * ulqr_NewRiccatiSolver(int nstates, int ninputs, int nhorizon)
Initialize a new Riccati solver.
Definition: riccati_solver.c:20
ulqr_PrintRiccatiSummary
int ulqr_PrintRiccatiSummary(RiccatiSolver *solver)
Prints a summary of the solve.
Definition: riccati_solver.c:129
RiccatiSolver::nvars
int nvars
total number of decision variables, including the dual variables
Definition: riccati_solver.h:68
ulqr_FreeRiccatiSolver
int ulqr_FreeRiccatiSolver(RiccatiSolver **solver_ptr)
Free the memory for a Riccati solver.
Definition: riccati_solver.c:103