We had some issues trying to code-gen the Simulink MPC block. The generated C++ files reference a few structs that aren’t defined anywhere in the code, and looking through the code and the model we’re not sure where the structs are coming from. The image below shows the issues and the model. The model was created by taking an MPC block (without any modifications) and adding inports/outports.
The MPC block can be code generated into C/C++, so we’re not sure why it runs into this issue when trying to code gen for RTMaps.
Any help would be greatly appreciated!
Thanks for reporting this.
I was able to reproduce this issue. It seems the structures are declared in the model description, but with a ‘Skip’ attribute that wasn’t taken into account on our code template. There was a similar issue with parameters that weren’t tunable.
It is now fixed with version 3.20.5 of the RTMaps Mathworks package, available on our update site (https://support.intempora.com/hc/en-us/articles/115001658369-RTMaps-Updater).
Please let us know if your component generated with this update works as expected.
If this version doesn’t solve it, what configuration on the MPC controller can be used to reproduce this issue?
Did this issue occurred only after updating the RTMaps TLC target to 3.21.0? Or is it reproducible with the previous version (3.20.5 or 3.20.4)?
This appears to be an issue on 3.21.0 on Ubuntu specifically, as the Windows counterpart builds fine. The previous version had issues with the MPC in general and so couldn’t be used.
I’m not sure how to share the MPC configurations with you as there are a few changes we’ve made on our side, but if there’s a way for me to provide you the necessary files I’d be happy to do that.
You can switch to older version the same way you update to new versions. Just make sure the option for “show older versions” is enabled in the updater and then select 3.21.0 from the standard update site
From the compile error, it now seems to be caused by a file purely generated by Simulink (ACCMPC.cpp). The RTMaps TLC Target should only affect the generation of the files with the “maps_” prefix.
Can you try using a TLC from base Simulink (grt.tlc for example), and see if it compiles correctly? If you get the same error, the Matlab community should be able to help on Matlab Answers.
But if it compiles correctly then, I would need a Simulink model file (.mdl) to reproduce this. If you prefer to share it privately, feel free to send a private message on the forum or by email to maxime.beluguet@intempora.com.
I tried compiling it with both the grt.tlc and the ert.tlc (embedded coder) and both worked fine. I did this on the deployment computer (dSPACE’s Autera) directly, which runs Ubuntu 22.04.
Both methods run successfully and built binary outputs, although with the ERT our goal was to write an RTMaps wrapper around the generated code, which seemed to due to a missing symbol (there some chance this was because of a mistake in writing the wrapper). I can send those details if you’d like me to.
As for the MPC, version 3.21.0 of the RTMaps TLC still has the same error, and v 3.21.0.1 has those include problems still. I’ve emailed you the files and details on how to open them.