Commander: make sure yaw airmode is not possible while arm gesture is enabled

It's unsafe to arm with the gesture when yaw airmode is enabled
because e.g. in Stabilized mode that results in a high yawrate setpoint
that the drone tries to follow even with zero thrust
because of the airmode.

It was handled before by checking the arm switch parameter because that
used to disable the stick arm gesture.
See 24dc316973
This commit is contained in:
Matthias Grob 2021-11-22 15:41:58 +01:00
parent 572890f8c0
commit 0153c870d2
1 changed files with 8 additions and 10 deletions

View File

@ -1739,7 +1739,7 @@ Commander::run()
bool sensor_fail_tune_played = false;
const param_t param_airmode = param_find("MC_AIRMODE");
const param_t param_rc_map_arm_switch = param_find("RC_MAP_ARM_SW");
const param_t param_man_arm_gesture = param_find("MAN_ARM_GESTURE");
/* initialize */
led_init();
@ -1795,9 +1795,6 @@ Commander::run()
_last_gpos_fail_time_us = _boot_timestamp;
_last_lvel_fail_time_us = _boot_timestamp;
int32_t airmode = 0;
int32_t rc_map_arm_switch = 0;
_status.system_id = _param_mav_sys_id.get();
arm_auth_init(&_mavlink_log_pub, &_status.system_id);
@ -1862,19 +1859,20 @@ Commander::run()
_auto_disarm_killed.set_hysteresis_time_from(false, _param_com_kill_disarm.get() * 1_s);
/* check for unsafe Airmode settings: yaw airmode requires the use of an arming switch */
if (param_airmode != PARAM_INVALID && param_rc_map_arm_switch != PARAM_INVALID) {
if (param_airmode != PARAM_INVALID && param_man_arm_gesture != PARAM_INVALID) {
int32_t airmode = 0, man_arm_gesture = 0;
param_get(param_airmode, &airmode);
param_get(param_rc_map_arm_switch, &rc_map_arm_switch);
param_get(param_man_arm_gesture, &man_arm_gesture);
if (airmode == 2 && rc_map_arm_switch == 0) {
if (airmode == 2 && man_arm_gesture == 1) {
airmode = 1; // change to roll/pitch airmode
param_set(param_airmode, &airmode);
mavlink_log_critical(&_mavlink_log_pub, "Yaw Airmode requires the use of an Arm Switch\t")
mavlink_log_critical(&_mavlink_log_pub, "Yaw Airmode requires disabling the stick arm gesture\t")
/* EVENT
* @description <param>MC_AIRMODE</param> is now set to roll/pitch airmode.
*/
events::send(events::ID("commander_airmode_requires_arm_sw"), {events::Log::Error, events::LogInternal::Disabled},
"Yaw Airmode requires the use of an Arm Switch");
events::send(events::ID("commander_airmode_requires_no_arm_gesture"), {events::Log::Error, events::LogInternal::Disabled},
"Yaw Airmode requires disabling the stick arm gesture");
}
}