Mode switches to RTL when mode Guided is requested by Mavlink

On real hardware:

  • Fly manually using a Graupner remote to certain position and switch to LOITER mode.
  • Using a PC to send command MAV_CMD_DO_SET_MODE to switch to GUIDED mode.
  • Drone returns to launch position. This is not expected.

On SITL:

  • Send take off command.
  • Using a PC to send command MAV_CMD_DO_SET_MODE to switch to GUIDED mode.
  • Drone does not return to launch position.
  • Drone can be controlled using SET_POSITION_TARGET_LOCAL_NED

What could cause the issue with real hardware?

GCS_FAILSAFE comes to my mind.
Or the wrong SYS_ID.

Did you compared the SITL parameters with the real copter parameters? what are the differences?

Disabled failsafe on real hardware and now it works! Might need regular heartbeat in guided mode. Needs more testing.