Skip to content
Permalink
Browse files

gnsf: added flag to import model matrices manually

  • Loading branch information...
FreyJo committed Feb 8, 2019
1 parent fd19f98 commit 1e8441a7f17fd0b2197f96c06e3f24c10705ff62
Showing with 24 additions and 4 deletions.
  1. +6 −2 acados/sim/sim_gnsf.c
  2. +17 −1 acados/sim/sim_gnsf.h
  3. +1 −1 roadmap.md
@@ -374,6 +374,9 @@ void *sim_gnsf_model_assign(void *config, void *dims_, void *raw_memory)
gnsf_model *model = (gnsf_model *) c_ptr;
c_ptr += sizeof(gnsf_model);

// set default
model->auto_import_gnsf = true;

// assign model matrices
assign_and_advance_double((nx1 + nz1) * nx1, &model->A, &c_ptr);
assign_and_advance_double((nx1 + nz1) * nu, &model->B, &c_ptr);
@@ -533,14 +536,15 @@ int sim_gnsf_precompute(void *config_, sim_in *in, sim_out *out, void *opts_, vo
gnsf_model *model = in->model;


if (model->get_gnsf_matrices == NULL)
if (model->get_gnsf_matrices == NULL && model->auto_import_gnsf)
{
printf("sim_gnsf error: get_gnsf_matrices function seems to be unset!\n");
status = ACADOS_FAILURE;
return status;
}

sim_gnsf_import_matrices(dims, model);
if (model->auto_import_gnsf)
sim_gnsf_import_matrices(dims, model);

// dimension ints
int nx = dims->nx;
@@ -40,7 +40,13 @@ extern "C" {
#include "blasfeo/include/blasfeo_i_aux_ext_dep.h"
#include "blasfeo/include/blasfeo_target.h"

/*
GNSF - Generalized Nonlinear Static Feedback Model
has the following form
https://github.com/acados/acados/files/2318322/gnsf_structure.pdf
More details can be found in Master thesis of Jonathan Frey
*/

typedef struct
{
@@ -64,12 +70,19 @@ typedef struct
external_function_generic *phi_fun;
external_function_generic *phi_fun_jac_y;
external_function_generic *phi_jac_y_uhat;

// f_lo: linear output function
external_function_generic *f_lo_fun_jac_x1_x1dot_u_z;

// to import model matrices
external_function_generic *get_gnsf_matrices;

// flag indicating, if model defining matrices are imported via external (casadi) function,
// [default]: true -> auto;
bool auto_import_gnsf;

/* model defining matrices */
// TODO: add setters to set manually
double *A;
double *B;
double *C;
@@ -81,9 +94,12 @@ typedef struct
double *L_u;

double *A_LO;
// double *B_LO;
double *E_LO;

// double *B_LO; idea, maybe detect linear dependency on controlls to treat
// fully linear systems more efficiently


/* constant vector */
double *c;

@@ -15,7 +15,7 @@
- [x] qpDUNES
- [x] HPMPC
- [ ] FORCES
- [ ] OSQP
- [x] OSQP

#### `sim`
- [x] explicit Runge-Kutta

0 comments on commit 1e8441a

Please sign in to comment.
You can’t perform that action at this time.