ArduPilot / ArduPilot/ardupilot
Copter: Auto mode will not execute command after RTL if RTL_ALT_FINAL > 0
- Dominant language
- C++
- Stars
- 15.9k
- Forks
- 21.4k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 119
Description
## Bug Report
From a review of PR https://github.com/ArduPilot/ardupilot/pull/33795 it is clear from inspection that Copter's Auto mode will not progress pass and RTL command if the RTL_ALT_FINAL > 0. Users set this parameter if they want the vehicle to stop descending a few meters above the home location. This rarely used feature can be useful in cases where the ground is very uneven and the pilot is more comfortable doing the final landing themselves.
The issue can be easily reproduced in SITL by doing the following:
- Create Auto mission with these commands:
- TAKEOFF to 10m
- RTL
- TAKEOFF to 10m
- LAND
- param set RTL_ALT_FINAL_M 0 (the default)
- param set AUTO_OPTIONS 3 (to enable arming in auto mode)
- auto
- arm throttle
The vehicle will fly the mission including the final TAKEOFF and LAND commands
- param set RTL_ALT_FINAL_M 2
- auto
- arm throttle
The vehicle will stop at the RTL command and never continue onto the TAKEOFF and LAND commands. Below is a screen shot from SITL showing the issue
The bug is in [ModeAuto's verity_RTL function](https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/mode_auto.cpp#L2238) and has been there for at least 7 years. The fix is likely to change the line to something like this:
```
return (copter.mode_rtl.state_complete() &&
((copter.mode_rtl.state() == ModeRTL::SubMode::FINAL_DESCENT) ||
(copter.mode_rtl.state() == ModeRTL::SubMode::LAND && motors->get_spool_state() == AP_Motors::SpoolState::GROUND_IDLE)));
```
**Version**
What version was the issue encountered with
4.8.0-dev (and earlier)
**Platform**
[ ] All
[ ] AntennaTracker
[x] Copter
[ ] Plane
[ ] Rover
[ ] Submarine
**Airframe type**
Copter
Contributor guide
Research direction
Start in ArduCopter/mode_auto.cpp at ModeAuto's verify_RTL function and compare the RTL state handling for RTL_ALT_FINAL_M values 0 and 2. Reproduce the issue in SITL with the listed TAKEOFF, RTL, TAKEOFF, and LAND mission, then confirm the mission continues past RTL when RTL_ALT_FINAL_M is 2 while the default behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot, robotics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100