Hi, i would like to know if its possible to use the predicted states vector in case my real system loses its feedback for a very short time.
So, my question is: Can i access the latest computed predicted state vector using GRAMPC?
Thanks a lot
Regards,
Hao
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the predicted states are stored in grampc.rws.x and the predicted controls in grampc.rws.u. Note that the values in rws are scaled if the respective option is activated. If only the predicted state at the next sampling instant is required, i.e. x(\Delta t), then you can simply use grampc.sol.xnext. Thus, if you have feedback, set x0 for the next step to the measured state. Otherwise, set x0 for the next step to the predicted state grampc.sol.xnext.
Regards,
Andreas
❤️
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Fortunately i was able to implement the MPC Controller in Matlab and Simulink smoothly. But i only have access to "grampc.rws.x" and "grampc.rws.u" vectors after the simulation is completely finished.
I was wondering if its possible to access the grampc Structure data (i.e. grampc.rws) while the simulation is running on simulink?
Since the Grampc Controller in Simulink uses a S-function i don't know where can i enable these Outputs in order to use them.
Truly thank you and blue skies!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you have to modify the S-function grampc_run_Sfct.c if you need further inputs or outputs. In the function mdlInitializeSizes you can add outputs for predicted states and controls and in the function mdlOutputs you have access to grampc->rws->x and grampc->rws->u and can copy them to the respective output port. Furthermore, note that you already get xnext as output, which is the predicted state after the sampling time, i.e. grampc.rws.x(\Delta t).
Regards,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To whom it may concern,
Hi, i would like to know if its possible to use the predicted states vector in case my real system loses its feedback for a very short time.
So, my question is: Can i access the latest computed predicted state vector using GRAMPC?
Thanks a lot
Regards,
Hao
Hello Hao,
the predicted states are stored in grampc.rws.x and the predicted controls in grampc.rws.u. Note that the values in rws are scaled if the respective option is activated. If only the predicted state at the next sampling instant is required, i.e. x(\Delta t), then you can simply use grampc.sol.xnext. Thus, if you have feedback, set x0 for the next step to the measured state. Otherwise, set x0 for the next step to the predicted state grampc.sol.xnext.
Regards,
Andreas
Dear Andreas,
Fortunately i was able to implement the MPC Controller in Matlab and Simulink smoothly. But i only have access to "grampc.rws.x" and "grampc.rws.u" vectors after the simulation is completely finished.
I was wondering if its possible to access the grampc Structure data (i.e. grampc.rws) while the simulation is running on simulink?
Since the Grampc Controller in Simulink uses a S-function i don't know where can i enable these Outputs in order to use them.
Truly thank you and blue skies!
Hello Hao,
you have to modify the S-function grampc_run_Sfct.c if you need further inputs or outputs. In the function mdlInitializeSizes you can add outputs for predicted states and controls and in the function mdlOutputs you have access to grampc->rws->x and grampc->rws->u and can copy them to the respective output port. Furthermore, note that you already get xnext as output, which is the predicted state after the sampling time, i.e. grampc.rws.x(\Delta t).
Regards,
Andreas