FW position controller: only allow switching to AUTO_ALTITDUE or AUTO_CLIMBRATE if pos_sp_curr_valid

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer 2021-11-05 17:36:30 +01:00 committed by JaeyoungLim
parent 2f8cb5a1c2
commit dbd9b88bea

View File

@ -642,7 +642,8 @@ FixedwingPositionControl::set_control_mode_current(const hrt_abstime &now, bool
_control_mode.flag_control_offboard_enabled) && pos_sp_curr_valid) {
_control_mode_current = FW_POSCTRL_MODE_AUTO;
} else if (_control_mode.flag_control_auto_enabled && _control_mode.flag_control_climb_rate_enabled) {
} else if (_control_mode.flag_control_auto_enabled && _control_mode.flag_control_climb_rate_enabled
&& pos_sp_curr_valid) {
// reset timer the first time we switch into this mode
if (_control_mode_current != FW_POSCTRL_MODE_AUTO_ALTITUDE && _control_mode_current != FW_POSCTRL_MODE_AUTO_CLIMBRATE) {