ardupilot
ardupilot copied to clipboard
Plane: Quadplane: add option to refuse change to FW mode at low altitude
This adds a Q_OPTION that will refuse changing into a forward flight mode if lower altitude than the larger of fence minimum altitude and ALT_HOLD_FBWCM. The idea is to prevent transitioning where there is not enough room. Guided and Auto modes are special cases because its too hard to tell if its going to be VTOL or FW, this is the same as what we did for the only arm in VTOL modes option.
This currently refuses any mode change. Possibly it should only refuse mode change from RC or GCS. There are some odd cases where we should enter the new mode. One example is the Q_RTL_MODE "QRTL Always", currently we would enter RTL and
then instantly QRTL. With this change we would refuse entering RTL and so not end up in QRTL.
Example with fence min alt set to 40m and a 2m margin:

Also added a Q_OPTIONS helper.
There are lots of options in the fail safe case. Currently this will refuse the mode change. Which may be the right thing to do if too low to transition. We could make the current code smarter in that case, so if change to RTL fails then try QRTL or QLAND. Or we could only block pilot mode changes from either RC or GCS and let everything else work as now.
I think RTL is the only mode you might want to get into and not be blocked, so we could also special case RTL mode. Depending on your QRTL mode param it might not try and fly in fixed wing at all.
Personally, I am not a fan of how this is setup....making one have to ascend to a typically high FENCE or FBWB_MIN is too much of a burden...I would typically set those at least above surrounding area treeline (maybe 100feet or more), where one might only need an altitude of 20-30 feet to safely transition, and climb out.....since you are not tackling the more important cases of where a pilot has no immediate control , ie AUTO, and actually denying the pilot the choice of how high to transition based on params setup for a wider area of operation, I feel this unnecessarily restricts pilot control...and not allowing a FS to go to one of its designated modes is very bad in my opinion...especially since normally ALL pilot control is lost in the failsafe due to link loss, denying RTL FS mode change is dooming the vehicle
aside from the FS issue, if this was a new independent param to pre-arm warn of VTOL takeoffs to some minimum safe transition alt, that might have value, but then again, if the user cant set a proper alt for VTOL takeoffs, why would we believe he would set the new param?
Maybe split out the enum change into another PR?
I'd also suggest option_enabled(...) or option_is_set(...)rather than option_set as the latter could be read as "set this option"
Since the conclusion was that is was better to switch to QLand than refuse the mode change I realized we could just do it in scripting.
This still does not really have a great way to deal with failsafe cases because scripting has no way to tell. We could add bindings for that, or mode reason.
In case of RTL the script could ascend then enable RTL.