Multiple PX4 Apps via Simulink (PX4 Support Package)

My main goal is to develop multiple modules/apps using PX4 support package in Simulink for my Cube Orange Plus. By multiple apps I mean to create apps other than default app named “px4_simulink_app” which gets overwritten whenever I built a model on Simulink.

First, these apps serve different purposes like controlling gpios, communicating with companion computer, changing flight mode mid mission, e.t.c. Then there could be one flight controller app separate from these apps.

Second, there is no available option in PX4 support package configuration to create multiple apps or even change the default name of Simulink generated app for PX4.

So what we tried was create our first app and built it, then rename it from “px4_simulink_app” to “test_app_1” and also renamed all files and subsequent module name in each file. However, what we noticed is that PX4 support package does not follow the usual template to generate code provided by PX4 Guide for developing custom apps. Then we created another app using Simulink and didn’t change any names of module, files or contents of files. So what we had at this point was two Simulink generated apps, one named “test_app_1” and the other named “px4_simulink_app”. These two apps are simple uORB publishing apps.

When we compiled the firmware using “make cubepilot_cubeorangeplus_default” in WSL console, it gave me error about having multiple definitions of a number of variables and functions in both modules created using Simulink. I am confused as to why it considers them the same functions and variables when they reside in totally different modules and files. Now If I changed all the variable names and function names in the first app I created using Simulink, then it got compiled and ran.

This approach is too crude since even a small change in my Simulink model would require me to go through the whole process of changing module name, file names, function names and variables, which, of course, is not a viable option.

For the record, I have been developing apps for PX4 architecture using the official guide on PX4 Guide website using C++ and have been successful so far. But I have been assigned to create multiple apps via Simulink and I am stuck at this point. Any kind of help will be appreciated.
Thanks!