Skip to content

jgillis/mpc-simulink-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An example of how to use CasADi's QRQP QP solver for MPC in Simulink.

main.m           - A demonstration script. After adding CasADi to the path this file should run without errors.
LMPC.c           - the Level-2 C S-Function definition; needs to be compiled together with MPC_step.c
MPC_step.c/h     - self-contained c code generated by generate_block.m
generate_block.m - A CasADi-Matlab function that constructs a QP solve step in a symbolic way, codegenerates and compiles to MPC_step.c
demo.slx         - A demonstration of a block that uses LMPC, and a 'mask' that automatically calls generate_block with appropriate parameters


Caveats:
  - C/D matrices are not used at the moment.
  - Status information is very limited for: only boolean success/fail, no statistics. There is a verbose mode for debugging though.
  - Beware of indefinite Hessians (Q,R)!
  - For exploiting minimal active set changes in an MPC setting, do connect (x->x_initial),(lam_x->lam_x_initial),(lam_g->lam_g_initial)
    Otherwise, feed zeros.
  - The mex command in generate_block does not specify compiler optimization flags. They are highly recommended.
  - Bottleneck assumed to be in QP. There is overhead involved in using the QP solver in an expression-oriented way as opposed to working with (sparse) matrices directly.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published