Open peterbarker opened 4 years ago
@rmackay9 @peterbarker The (main) reason for not (or only short) switching to RTL in this case is a nested mode_switch call.
Set_mode to auto will be triggere, in set_mode Mode_Auto::init will be called which then detect the malfunction of the rangefinder and try to set RTL with another set_mode call (while the first set_mode is still running) it sets the mode to RTL then all is going back in the Stack and the first set_mode (to auto) will finished and set it back to auto. Because there are a lot of functions calls between the two set_mode calls it is not so easy to fix. We have lost one copter that hit into the ground due to this issue.
Bug report
Issue details
Copter has multiple issues with terrain failsafe with a configured but not used rangefinder. And terrain.
I have not fully characterised everything that's going on here.
@mirkix pointed out that a simple mission in SITL produced some bad results.
https://github.com/ArduPilot/ardupilot/pull/15514 contains this mission:
When the new autotest is run (
killall gdb xterm ; ./Tools/autotest/autotest.py --gdb --debug test.Copter.RangeFinderMissionRTL --map
), this is what happens:Note the "RTL" mode? That's because a terrain failsafe triggers, and we momentarily end up in RTL mode. We actually enter RTL mode but then trundle on through the "auto wp" code:
It's much worse if you don't use guided mode to move around but move away using loiter mode: https://github.com/ardupilot/ardupilot/blob/master/ArduCopter/mode_auto.cpp#L1137 - that call can
set_mode
to RTL on terrain failsafe, which will reset targets etc - but then we continue in auto-mode (I've no idea what switches the mode back to auto....)In that image, we think we're going to waypoint one (see the console text), actually moving towards home (or, more likely, origin) (see map) - and crashing into the ground part-way there (see rangefinder graph).
As mentioned, haven't fully characterised this. It feels like potentially several bugs.
In addition to any bugs here, we should probably not allow arming if the mission contains AGL mission items and the user doesn't have a working terrain altitude source.
Version master
Platform
Airframe type +
Hardware type SITL
Logs