Skip to content

How to: Dynamic System Models and Integrators in acados

Jonathan Frey edited this page Jul 12, 2019 · 5 revisions

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.

Types of models in acados

There are three types of models used in acados integrators:

  1. 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
  2. explicit models: in the form xdot = f_expl(x, u)
    • used by the sim_erk_integrator
  3. 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.

Define your model structure in Matlab

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


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.

Generate C Code

To generate C Code for your model you should use the file


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.

Using the model with acados

For this we refer to the


folder, where examples for simulation and NMPC schemes can be found.

You can’t perform that action at this time.