How to start a module starting the simulation

Hi everyone, i’m doing a project for university and i’m trying to start a module when the simulation begin.
Let’s call the module “my_module”, i know that i have to put somewhere in the firmware the command my_module start, I’ve found some places in which other module like the mc_pos_control starts but I’m not able to figure out the right position to write this command (for simulation sitl, in future i will need it alto in hitl and on the actual px4).

Hey man,
Not too sure whether this would be helpful but for a module you can refer to First Application Tutorial (Hello Sky) | PX4 User Guide, also best to enable your own UORB message, this would help you to communicate with different modules and also log it down, using listener <message_name> in the mavlink console would help to debug too. You can add your module in the default.cmake for SITL

		dyn_hello # dynamically loading modules example
		fixedwing_control # Tutorial code from
		#hwtest # Hardware test
		px4_mavlink_debug # Tutorial code from
		px4_simple_app # Tutorial code from
		rover_steering_control # Rover example app

For starting SITL, when you etc make px4_sitl gazebo HEADLESS=1, you call on
and under the line

if [[ ${model} == test_* ]] || [[ ${model} == *_generated ]]; then
	sitl_command="\"$sitl_bin\" $no_pxh \"$src_path\"/ROMFS/px4fmu_test -s \"${src_path}\"/posix-configs/SITL/init/test/${model} -t \"$src_path\"/test_data"
	sitl_command="\"$sitl_bin\" $no_pxh \"$build_path\"/etc -s etc/init.d-posix/rcS -t \"$src_path\"/test_data"

You see it calls the file in the directory etc/init.d-posix/rcS looking at that file you can change the main SITL startup script.
Hope it goes well for you!

Thanks for your help, i had already figure out the position of the startup script and it is correct , I had to modify the file into ROMFS/px4fmu.common/init.d//rc.mc_apps when starting the simulation as make px4_sitl jmavsim.