rsLQR
0.1
|
Data Structures | |
struct | LQRData |
Holds the data for a single time step of LQR. More... | |
struct | LQRProblem |
Describes an LQR problem with affine terms. More... | |
Functions | |
LQRData * | ndlqr_ReadLQRDataJSONFile (const char *filename) |
Read an LQRData structure from JSON data. More... | |
LQRProblem * | ndlqr_ReadLQRProblemJSONFile (const char *filename) |
Read and LQRProblem structure from JSON data. More... | |
Matrix | ReadMatrixJSONFile (const char *filename, const char *name) |
Read a Matrix from a JSON file. More... | |
int | ndlqr_InitializeLQRData (LQRData *lqrdata, double *Q, double *R, double *q, double *r, double c, double *A, double *B, double *d) |
Copy data into an initialized LQRData structure. More... | |
LQRData * | ndlqr_NewLQRData (int nstates, int ninputs) |
Allocate memory for a new LQRData structure. More... | |
int | ndlqr_FreeLQRData (LQRData *lqrdata) |
Free the memory for and LQRData object. More... | |
int | ndlqr_CopyLQRData (LQRData *dest, LQRData *src) |
Copies one LQRData object to another. More... | |
Matrix | ndlqr_GetA (LQRData *lqrdata) |
Get (n,n) state transition matrix. | |
Matrix | ndlqr_GetB (LQRData *lqrdata) |
Get (n,m) control input matrix. | |
Matrix | ndlqr_Getd (LQRData *lqrdata) |
Get (n,) affine dynamice term. | |
Matrix | ndlqr_GetQ (LQRData *lqrdata) |
Get state cost Hessian. | |
Matrix | ndlqr_GetR (LQRData *lqrdata) |
Get control cost Hessian. | |
Matrix | ndlqr_Getq (LQRData *lqrdata) |
Get affine state cost. | |
Matrix | ndlqr_Getr (LQRData *lqrdata) |
Get affine control cost. | |
void | ndlqr_PrintLQRData (LQRData *lqrdata) |
Prints the data contained in LQRData. More... | |
int | ndlqr_InitializeLQRProblem (LQRProblem *lqrproblem, double *x0, LQRData **lqrdata) |
Initialize the problem with an initial state and the LQR data. More... | |
LQRProblem * | ndlqr_NewLQRProblem (int nstates, int ninputs, int nhorizon) |
Initialize a new LQRProblem data with unitialized data. More... | |
int | ndlqr_FreeLQRProblem (LQRProblem *lqrprob) |
Free the data stored by and LQRProblem. More... | |
Copies one LQRData object to another.
The two object must have equivalent dimensionality.
dest | Copy destination |
src | Source data |
int ndlqr_FreeLQRData | ( | LQRData * | lqrdata | ) |
int ndlqr_FreeLQRProblem | ( | LQRProblem * | lqrprob | ) |
Free the data stored by and LQRProblem.
Also frees the LQRProblem itself.
lqrprob | An initialized LQRProblem |
int ndlqr_InitializeLQRData | ( | LQRData * | lqrdata, |
double * | Q, | ||
double * | R, | ||
double * | q, | ||
double * | r, | ||
double | c, | ||
double * | A, | ||
double * | B, | ||
double * | d | ||
) |
Copy data into an initialized LQRData structure.
Does not allocate any new memory.
lqrdata | Initialized LQRData struct |
Q | Diagonal of state cost Hessian |
R | Diagonal of control cost Hessian |
q | State cost affine term |
r | Control cost affine term |
c | Constant cost term |
A | Dynamics state matrix |
B | Dynamics control matrix |
d | Dynamics affine term |
int ndlqr_InitializeLQRProblem | ( | LQRProblem * | lqrproblem, |
double * | x0, | ||
LQRData ** | lqrdata | ||
) |
Initialize the problem with an initial state and the LQR data.
lqrproblem | An initialized LQRProblem |
x0 | Initial state vector. The data is copied into the problem. |
lqrdata | A vector of LQR data. Each element is copied into the problem. |
LQRData* ndlqr_NewLQRData | ( | int | nstates, |
int | ninputs | ||
) |
Allocate memory for a new LQRData structure.
Must be paired with a single call to ndlqr_FreeLQRData().
nstates | Length of the state vector |
ninputs | Number of control inputs |
LQRProblem* ndlqr_NewLQRProblem | ( | int | nstates, |
int | ninputs, | ||
int | nhorizon | ||
) |
Initialize a new LQRProblem data with unitialized data.
Must be paired with a call to ndlqr_FreeLQRProblem().
nstates | Length of the state vector |
ninputs | Number of control inputs |
nhorizon | Length of the horizon (i.e. number of knot points) |
void ndlqr_PrintLQRData | ( | LQRData * | lqrdata | ) |
Prints the data contained in LQRData.
Cost data is printed in rows and dynamics data is printed as normal matrices.
lqrdata |
LQRData* ndlqr_ReadLQRDataJSONFile | ( | const char * | filename | ) |
Read an LQRData structure from JSON data.
The user is responsible for calling ndlqr_FreeLQRData() after calling this function.
The json data is expected to be structured as follows:
filename | path to the json file |
LQRProblem* ndlqr_ReadLQRProblemJSONFile | ( | const char * | filename | ) |
Read and LQRProblem structure from JSON data.
The user is expected to call ndlqr_FreeLQRProblem() after calling this function.
The json data is expected to be structured as follows:
where each element of lqrdata
is of the form specified in ndlqr_ReadLQRDataJSONFile().
filename | Path to the json file |