xiaolou - 2021-05-31

Hello Andreas Völz,

Thank you for your patience and guidance, I have solved this problem myself during this period of time. For this problem, I will make a brief summary in the hope that I can give you some help.
For the dynamic constraint problem that changes over time, how to add your own constraints, I summarize the following two methods based on my situation.
1. first add the global time variable t0 in MPCloop, (the distinction between t0 and t have been introduced). similar to grampc.userparam(1) = grampc.param.t0; then you can add your own dynamic constraints in MPCloop, and finally pass a pointer to userparam and your own constraint equations.**
2. the same process of defining time variables as before, this method adds constraints directly in initData and then passes them to the constraint function via userparam.

Note: the above two methods must be global time variables in mpc definition; specific details can refer to MHE this example. Among the above two methods, the advantage of the first method is that the cpu consumption time is shorter.

Some students need to implement real-time simulation in simulink, you can use the latest version v2.2, first you can put t0 in the first place of userparam, fuse[2:end]parameters, write a matlab function, t0 is generated by the clock, and then access to the userparam interface. This is done for the second method above, the first method has not yet been implemented in simulink for real-time simulation. For visual representation, I take the following screenshots.

Finally, I sincerely thank Andreas Völz for his guidance and wish you all the best.

Best regards,
xiaolou