Optistack for NMPC and MPC

556 views
Skip to first unread message

ae17...@smail.iitm.ac.in

unread,
Aug 17, 2018, 7:30:39 AM8/17/18
to CasADi
Hello everyone.
I have used the optistack feature of CASADI to solve optimal control problem via pseudospectral methods for trajectory optimization. I would also like to create NMPC and MHE  solvers using optistack. However there seems to be problem in the controls obtained from the solver as they are out the limits specified for the controls in the formulation. Since OCP is solved repeatedly for NMPC my reference trajectory and initial condition for the state are subject to vary over every iteration . Can anyone suggest how to implement NMPC in optistack using the above formulation. I am also attack the code I tried for implementing NMPC using  optistack. Thanks in advance
main.m

Bruno Martins Lima

unread,
Aug 21, 2018, 4:20:36 PM8/21/18
to CasADi
Hi,

the Rawlings' Group developed a toolbox called MPCTools which implements NMPC and MHE using CasADi. It is available to Octave/Matlab and Python. 

They implement many high level functions which might help your implementation. Looking at the documentation, I can see that they implement path constraints and a function called "cyclepar" for NMHE but I never used them.

Maybe you could try to use the toolbox or could look at the source code to learn how they implemented it.

Hope it helps,
Bruno

Joris Gillis

unread,
Aug 21, 2018, 6:14:56 PM8/21/18
to CasADi
Hi!

Could you make your code runnable by providing dependencies like 'legslb'  'legslbdiff' and 'conref/stateref', or avoiding them?

Best,
   Joris

R Sandeep kumar

unread,
Aug 22, 2018, 1:53:05 AM8/22/18
to Joris Gillis, CasADi
Thanks Bruno. I saw it long back in bitbucket. I am trying to implement some algorithms and see the difference in performance especially for differentially flat systems. That's why I preferred casadi's environment. Jorris I just wanted to know it was a problem with my usage of optistack. Here are the required files

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/casadi-users/ccb3d565-bdf5-44bb-b50a-ba88e785b181%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
legslbdiff.m
stateref.m
lepoly.m
legslb.m
conref.m

Joris Gillis

unread,
Aug 22, 2018, 8:11:51 AM8/22/18
to CasADi
Hi again,

It's a bit embarrassing to suggest, but could it be that the control saturation violation is inferred from the second plot?
That second plot is plotting Usim(1,:) three times, instead of looping over all rows of Usim..

Otherwise, nice work!

Best,
  Joris

On Wednesday, 22 August 2018 07:53:05 UTC+2, R Sandeep kumar wrote:
Thanks Bruno. I saw it long back in bitbucket. I am trying to implement some algorithms and see the difference in performance especially for differentially flat systems. That's why I preferred casadi's environment. Jorris I just wanted to know it was a problem with my usage of optistack. Here are the required files

On Wed, Aug 22, 2018, 3:44 AM Joris Gillis <joris.g...@gmail.com> wrote:
Hi!

Could you make your code runnable by providing dependencies like 'legslb'  'legslbdiff' and 'conref/stateref', or avoiding them?

Best,
   Joris

On Friday, 17 August 2018 13:30:39 UTC+2, ae17...@smail.iitm.ac.in wrote:
Hello everyone.
I have used the optistack feature of CASADI to solve optimal control problem via pseudospectral methods for trajectory optimization. I would also like to create NMPC and MHE  solvers using optistack. However there seems to be problem in the controls obtained from the solver as they are out the limits specified for the controls in the formulation. Since OCP is solved repeatedly for NMPC my reference trajectory and initial condition for the state are subject to vary over every iteration . Can anyone suggest how to implement NMPC in optistack using the above formulation. I am also attack the code I tried for implementing NMPC using  optistack. Thanks in advance

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users+unsubscribe@googlegroups.com.

R Sandeep kumar

unread,
Aug 22, 2018, 11:25:25 AM8/22/18
to Joris Gillis, CasADi
Thanks Joris. It is embarrassing for me but thanks for pointing it out. After changing the weights for the controller it works like a charm.The weights were taken from a nmpc problem solved using ACADO for tracking the same trajectory.But I just remembered the auto scale feature in ipopt. Changed the weights  to identity matrix and it  solved the problem. However at a specific point time =7 secs the ocp became infeasible. I'll investigate this further and let you know. But anyways thanks a lot for investing your time and for this beautiful piece of software.

On Wed, Aug 22, 2018, 5:41 PM Joris Gillis <joris.g...@gmail.com> wrote:
Hi again,

It's a bit embarrassing to suggest, but could it be that the control saturation violation is inferred from the second plot?
That second plot is plotting Usim(1,:) three times, instead of looping over all rows of Usim..

Otherwise, nice work!

Best,
  Joris

On Wednesday, 22 August 2018 07:53:05 UTC+2, R Sandeep kumar wrote:
Thanks Bruno. I saw it long back in bitbucket. I am trying to implement some algorithms and see the difference in performance especially for differentially flat systems. That's why I preferred casadi's environment. Jorris I just wanted to know it was a problem with my usage of optistack. Here are the required files

On Wed, Aug 22, 2018, 3:44 AM Joris Gillis <joris.g...@gmail.com> wrote:
Hi!

Could you make your code runnable by providing dependencies like 'legslb'  'legslbdiff' and 'conref/stateref', or avoiding them?

Best,
   Joris

On Friday, 17 August 2018 13:30:39 UTC+2, ae17...@smail.iitm.ac.in wrote:
Hello everyone.
I have used the optistack feature of CASADI to solve optimal control problem via pseudospectral methods for trajectory optimization. I would also like to create NMPC and MHE  solvers using optistack. However there seems to be problem in the controls obtained from the solver as they are out the limits specified for the controls in the formulation. Since OCP is solved repeatedly for NMPC my reference trajectory and initial condition for the state are subject to vary over every iteration . Can anyone suggest how to implement NMPC in optistack using the above formulation. I am also attack the code I tried for implementing NMPC using  optistack. Thanks in advance

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users...@googlegroups.com.

--
Sent from CasADi's user forum at http://forum.casadi.org.
---
You received this message because you are subscribed to the Google Groups "CasADi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casadi-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/casadi-users/143b3eb2-c292-47ad-a801-4f44ad21e305%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages