How to: Dynamic System Models and Integrators in acados
You are new to acados? You want to start using it with your dynamic system model of choice?! This is a guide for you!!!
It is recommended to use CasADi (3.4.x) from Matlab to generate the C Code needed to simulate your model.
There are three types of models used in acados integrators:
- implicit models: in the form
f_impl
(x, xdot, u, [z])- these type of formulation is used by the implicit integrators:
sim_irk_integrator
,sim_lifted_irk_integrator
,sim_new_lifted_irk_integrator
- where algebraic variables z are an optional part of the model, currently only supported by
sim_irk_integrator
- these type of formulation is used by the implicit integrators:
- explicit models: in the form xdot =
f_expl
(x, u)- used by the
sim_erk_integrator
- used by the
- GNSF models:
- Model formulation needed to use the structure exploiting implicit integrator
sim_gnsf
- Can be generated automatically from implicit models, for models in SX CasADi variables
- The exact model format is described here. For more information on the scheme, the user is referred to the Master thesis of Jonathan Frey.
- Model formulation needed to use the structure exploiting implicit integrator
Generally you should first start with CasADi symbolic variables representing x, xdot, z, u. Hereby it is best practice to create each component of the vector separately and giving it a name. You should create Matlab function taking
/examples/c/pendulum_model/export_pendulum_ode_model.m
as a template to generate your model.
NOTE: The field f_expl
only has to be set if you want to use option 2 in the section above. If you want to use option 1 or 3 setting f_impl
is sufficient.
To generate C Code for your model you should use the file
/examples/c/pendulum_model/generate_C_model.m
as a Template. Depending on which integrator/type of model you want to use, see "Types of models in acados" section. Un/comment the three sections accordingly.
For this we refer to the
folder, where examples for simulation and NMPC schemes can be found.