Hello everyone,
I have problems implementing MHE in closed loop with MPC in simulink, even with the doc and the CSTR example.
In my Simulink model, I have a MPC controller and a MHE block. I created another set of push buttons to compile and init the probfct and initData of each problem (MPC, MHE). I do not know if it is necessary but i also created another set of _Cmex.c functions for the second block.
I have difficulties to choose the correct inputs of the MHE block and on how to modify grampc_run_Sfct_MHE.c so that the MHE is possible.
I wanted to know if you had some guidelines
Best regards,
Pierre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
your approach sounds fine.
You need to supply your MHE-block/probfct with your measurements. This is best done with the userparam (see the CSTR example). To be able to do change the userparam with the S-function in simulink, see https://sourceforge.net/p/grampc/discussion/general/thread/c6123760c1/
where this problem was already discussed.
If you have any further questions, feel free to ask.
Regards,
Felix
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I modified grampc_run_Sfct_MHE.c, to collect N measures of the plant outputs.
I believe I also need the values of the previous values of the control signal. Since MHE and MPC are two different blocks, I do not have directly access to the control signal previous values. Is it correct to fill userparam with those values and replace the control u of the functions : ffct, dfdx_vec,dfdu_vec by the corresponding value of the control signal ?
I also need values of the states x for the system function ffct and the integral cost lfct.
I would give as an input of the MHE block the value of the state estimate at time (t - Thor) .
But, from what i understood from the CSTR example, it need the previous state estimate (at time t). Is that it ?
Regards,
Pierre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, you need the previous values of the control signal. I guess your way will work. Another approach would be to directly manipulate the field which holds the control values in the grampc struct (see line 171 of startMHE.m in the CSTR example).
Regarding the state estimate, to initialize you need the state estimate at time (t-Thor+dt) (Again see the paper, especially equations (6) and (8) in section 2.3).
Regards,
Felix
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
I have problems implementing MHE in closed loop with MPC in simulink, even with the doc and the CSTR example.
In my Simulink model, I have a MPC controller and a MHE block. I created another set of push buttons to compile and init the probfct and initData of each problem (MPC, MHE). I do not know if it is necessary but i also created another set of _Cmex.c functions for the second block.
I have difficulties to choose the correct inputs of the MHE block and on how to modify grampc_run_Sfct_MHE.c so that the MHE is possible.
I wanted to know if you had some guidelines
Best regards,
Pierre
Hi Pierre,
your approach sounds fine.
You need to supply your MHE-block/probfct with your measurements. This is best done with the userparam (see the CSTR example). To be able to do change the userparam with the S-function in simulink, see
https://sourceforge.net/p/grampc/discussion/general/thread/c6123760c1/
where this problem was already discussed.
If you have any further questions, feel free to ask.
Regards,
Felix
Thank you for your answer,
I modified grampc_run_Sfct_MHE.c, to collect N measures of the plant outputs.
I believe I also need the values of the previous values of the control signal. Since MHE and MPC are two different blocks, I do not have directly access to the control signal previous values. Is it correct to fill userparam with those values and replace the control u of the functions : ffct, dfdx_vec,dfdu_vec by the corresponding value of the control signal ?
I also need values of the states x for the system function ffct and the integral cost lfct.
I would give as an input of the MHE block the value of the state estimate at time (t - Thor) .
But, from what i understood from the CSTR example, it need the previous state estimate (at time t). Is that it ?
Regards,
Pierre
Hi Pierre,
sorry for the late answer....
Yes, you need the previous values of the control signal. I guess your way will work. Another approach would be to directly manipulate the field which holds the control values in the grampc struct (see line 171 of startMHE.m in the CSTR example).
Your states will be calculated via integration (See section 2.3 in https://link.springer.com/article/10.1007/s11081-018-9417-2?wt_mc=Internal.Event.1.SEM.ArticleAuthorOnlineFirst&utm_source=ArticleAuthorContributingOnlineFirst&utm_medium=email&utm_content=AA_en_06082018&ArticleAuthorContributingOnlineFirst_20190121)
Regarding the state estimate, to initialize you need the state estimate at time (t-Thor+dt) (Again see the paper, especially equations (6) and (8) in section 2.3).
Regards,
Felix