ArduPilot / ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
http://ardupilot.org/
GNU General Public License v3.0
10.81k stars 17.26k forks source link

Copter: SmartRTL can trigger flow-of-control internal error #17416

Open rmackay9 opened 3 years ago

rmackay9 commented 3 years ago

During testing of Copter-4.1 a user managed to trigger these lines of code in SmartRTL. In SITL this causes the simulator to crash (on purposes so that we can catch these types of error) but on a real vehicle the vehicle would immediately land and the user would find they were unable to re-arm and takeoff because of this internal error.

        } else if (g2.smart_rtl.get_num_points() == 0) {
            // We should never get here; should always have at least
            // two points and the "zero points left" is handled above.
            INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
            smart_rtl_state = SmartRTL_PreLandPosition;

by doing this in SITL:

1) Start mavproxy SITL, "sim_vehicle.py --console --map"
2) Set the ALT_HOLD mode
3) Set mode 21 (SRTL)
4) Set ALT_HOLD
5) Set mode 21 (SRTL)
6) ArduCopter will at this point crash and mavproxy reports "no link" 

@tridge has reproduced the issue in SITL.

timtuxworth commented 5 months ago

I just had this problem on master (post 4.5.0). I did it by having Smart_RTL as one of the modes on my FLTMODE_CH switch. Interesting that it doesn't happen if the switch is set to Smart_RTL on boot, but only when switching to Smart_RTL after switching to some other switch position/mode and then switching back.