Mission using script SITL

On SITL, can I load a simple mission: (takeoff wp1 wp2 land) using rcS or some other script that can be loaded on startup without using QGC.

currently I have on the rcS:

commander mode auto:mission
sleep 5
commander arm

with mission being loaded from QGC.


If you sent a mission it’s saved to the sdcard, so changing to mission and arming would start running it.

Another option if you have a computer onboard (like an odroid, raspi, etc), you could have it execute a script that would send mission items.

I push some waypoints throug the “/mavros/mission/push” service. But the mode can’t be set to AUTO.MISSION without running the QGC. Do you know how to deal with it?
Thank you very much!

You can definitely use MISSION without QGC. What error did you get when you tried to change the mode? Does the vehicle have a valid position?

yes, I think the vehicle has a valid position. I test my code in SITL.( I try to set the mode to AUTO.TAKEOFF and it works.) If I set the mode to AUTO.MISSION through the mavros_msgs/SetMode.srv without running QGC, the mode will be changed to AUTO.RTL and can’t start the mission. If the QGC is running, it works.
I don’t have a good understanding of the flight mode setting. What are the requirements to set the mode to AUTO.MISSION without running the QGC? Can you give me some advice?
Thanks for your reply.

It sounds like the failsafes are inconsistent between AUTO_TAKEOFF and AUTO_MISSION. I’d start by checking your setting for data link loss.

Through the just study, I understand why the mode is set to AUTO.RTL.
In my humble opinion, when I try to set the mode to AUTO.MISSION by “/mavros/set_mode” service, the “set_data_link_loss_nav_state” function will be called due to the data link loss enabled. Then the function will set the mode to AUTO.RTL because the "link_loss_act " is equal to “link_loss_actions_t::AUTO.RTL”.
But I’m confused where to set the “data_link_loss_act” parameter in “set_nav_state” function. Is it related to “NAV_DLL_ACT”? I try to change the value but it doesn’t work.
I try to set the mode to AUTO.MISSION forcibly as shown below. It works but I think it’s not a good way. So can you give me some advice? Is there a better way to set the mode to AUTO.MISSION and start the mission without running the QGC?

Thanks for your patience.