How to know when in RTL in a mission?

Goodmorning, for a project of mine, i’m reading the mavlink stream with an esp32 LoRa capable board. I need to know when the copter goes in RTL mode and for that i’m listening for the heartbeat which gives me the current autoPilot mode via heartbeat_int.custom_mode. So far so good, however i found that when the copter is in auto mode, with a mission that has RTL as the last waypoint, the mode does NOT switch to RTL but remains in AUTO. Is this correct? am i doing something wrong? To be precise, if i use the radio, whenever i change the flight mode i see it with my code, so that is working.
I also understand that remaining in auto mode could be considered the correct behaviour, but then, how can i reliably know when the copter is in RTL mode while in AUTO?

Thank you very much guys

Compare the location in POSITION_TARGET_GLOBAL_INT and HOME_POSITION (maybe not == due to conversions but it will be really close). Home location can also be found at the 0th index of the waypoint list.

Thank you for your suggestion, however that is not what i need. I need to know when drone is coming back to RTL postion. I am already able to calculate distance frome home with that information. Now i need to know when i am executing RTL

Thanks anyway

This is exactly what you need.
When vehicle switch to RTL in auto mode, POSITION_TARGET_GLOBAL_INT contains the home location’s latitude, longitude and the vehicle will fly to the home location.

Probably you’re referring GLOBAL_POSITION_INT by saying that.
What I’m saying is POSITION_TARGET_GLOBAL_INT.

1 Like

Oh, i see, now i understand, thank you. That is indeed the solution to my problem. I’m going to implement it next week

1 Like