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

	EXAMPLES
		dyn_hello # dynamically loading modules example
		fake_gps
		fake_magnetometer
		fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
		hello
		#hwtest # Hardware test
		#matlab_csv_serial
		px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html
		px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html
		rover_steering_control # Rover example app
		uuv_example_app
		work_item
		<name_of_module>
	)

For starting SITL, when you etc make px4_sitl gazebo HEADLESS=1, you call on sitl_run.sh
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"
else
	sitl_command="\"$sitl_bin\" $no_pxh \"$build_path\"/etc -s etc/init.d-posix/rcS -t \"$src_path\"/test_data"
fi

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.