Wrong Flight Mode After Geofence Violation

Hi All,

Today I had a weird behaviour with current BETA Version PX4 using QGC.

Programmed Flight modes are : Stabilized, Manual, Position

I have tested the Geofence, (30m Vertical, 100m Horizontal), went beyond 100m and when it came back, I have changed the flight mode to cancel RTL, and no matter which flight mode I was using, it was always coming back to Position Mode.

If it can help, I am almost sure it was working correctly before…

Today I have changed 2 things:

1- The GPS I am now using the HK MICRO UBLOX M8N
2- I have tried to change SYSTEM -> Position Estimator from INAV to LPE and came back to LPE. To verify how it controls the altitude.

It is also behaving differently when using LPE and going through Geofence, it stays in POSITION and even if TH is completely LOW, it takes a lot of time to come down and also it switches this time from POSITION to Stabilized and it stays in Stabilized. Something is weird there and the flight modes.

Please feel free to ask anything you need, LOG file, etc. I will try to send it to you.



Thanks for reporting the issue. I’ll try to reproduce it to see what’s going on.

Could you post your log here?



Hi dagar,
Here are the links,

Could you describe what happened vs what you were trying to do?

I see stabilized -> rtl -> stabilized -> loiter -> position (1s) -> stabilized -> position -> stabilized

Which changes were intentional? Was stabilized after rtl?

Hi Dagar,

IN this flight I tried the Geofence with the LOITER mode enabled.

What is curious is that it did a RTL (even if LOITER was used).

What I believe is the following: I am using different versions of QGroundControl.

If I always program the option “LOITER” in the safety section as the action to perform on a Geofence Violation it will perform differently depending on the version of QGC I am using.

If using stable LOITER will do a LOITER during GeoFence Violation. This is using Stable version of QGC (MAC VERSION).

If using stable LOITER will do a RTL during GeoFence Violation. This is using BETA version of QGC (MAC VERSION).

If using stable LOITER will do a LOITER during GeoFence Violation. This is using Stable version of QGC (Android on my Phone).

Unfortunately I do not have all the versions with me, etc. This is something I can test more thoroughly later.

What I think is using Beta version of PX4, Beta version of QGC there is a mismatch somewhere that is causing this strange behavior.

When using the option “Geofence Violation” with beta Versions of PX4 and QGC it does a RTL but even if my mode switch is set at “STABILIZED” it switches by itself in position.

I am sorry I know all this is not very clear I will develop the aptitude to report bugs correctly and describe them correctly.



@dagar Any new insights on this? Is this something we have to fix before 1.4.1 goes out?

I haven’t had time to step through the code, but it sounds like we’re incorrectly holding or not resetting the previous main state. I’ll have time to look at it this weekend.

I haven’t been able to reproduce your issue.

If I didn’t miss anything in your comment it’s only an issue on your mac with beta QGC? I wonder if you could be stuck with old/bad parameter metadata somehow? Are you able to easily reproduce this? If so I have a few things you can try.

Let me check if I can reproduce it and I will record it so you can see it.
I do not want to loose your time for nothing.
Keep you posted soon.
Thanks for the follow-up!

HI Guys,

This time I have the LOG file…
Here it is:

This what is happening, everything works fine, Stabilize, ALTITUDE, Position mode, RTL, etc.

As soon as it performs a GEO FENCE Violation, it comes back, but it always stay in POSITION regardless of what I am doing, here is a video to show how it behaves.




Hi pturcotte

I’ve just (a few hours ago) added a fix to master to reset the fallback mode properly. So your issue is most likely fixed now.


Excellent, I will try it tomorrow,
Keep you posted,

Hi Guys,

I have tested, found another issue, might be related.
Now flight mode is not changing, but if it performs a GEO FENCE VIOLATION, the second time I try to perform another GEO FENCE VIOLATION, it sees it but it does not take any action.

Here is the log file:

Here is the video:



It doesn’t look like you flashed master. The fixes are on master only (not stable, not beta). If the action is set to RTL everything works. I found another problem however with Loiter that I will fix and test shortly.

  • ada

Hi AndreasAntener,

I have used the Master release from QGC, maybe I did something wrong…

I have tested it again today, this is something I have discovered

1- If set to Return to Lunch on a Geofence violation, it will behave as per previous description.
2- if I set it to LOITER in QGC it will now perform a RTL.

Looks like it gets confused by one index in the drop down list.

I can test this tomorrow, please send me a link on the file you want me to test.



Thanks for testing. I pushed the latest fix to master to update the fallback mode properly. I don’t see why Loiter won’t work for you. Can you post a log where you have Loiter set before you arm? Then I can check the actual values.