From ec035b72684271367cd02f2c1bb0da40185e3866 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 13 Jul 2016 14:39:42 +0200 Subject: [PATCH] px4iofirmware: no override in multirotor mode This fixes a bug where multirotors got into override mode when the FMU is dead/not responding. The main bug was that the check was for FMU_OK || MANUAL_OVERRIDE_OK in order to get further in the override checks. Also a mixer_tick was called inside the controls_tick even though these are called in px4io.c after each other anyway. --- src/modules/px4iofirmware/controls.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/modules/px4iofirmware/controls.c b/src/modules/px4iofirmware/controls.c index 091be1a209..256e2d0902 100644 --- a/src/modules/px4iofirmware/controls.c +++ b/src/modules/px4iofirmware/controls.c @@ -481,14 +481,12 @@ controls_tick() /* * Check for manual override. * - * The PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK flag must be set, and we - * must have R/C input (NO FAILSAFE!). - * Override is enabled if either the hardcoded channel / value combination - * is selected, or the AP has requested it. + * Firstly, manual override must be enabled, RC input available and a mixer loaded. */ - if ((!(r_status_flags & PX4IO_P_STATUS_FLAGS_FMU_OK) || (r_setup_arming & PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK)) && + if ((r_setup_arming & PX4IO_P_SETUP_ARMING_MANUAL_OVERRIDE_OK) && (r_status_flags & PX4IO_P_STATUS_FLAGS_RC_OK) && - !(r_raw_rc_flags & PX4IO_P_RAW_RC_FLAGS_FAILSAFE)) { + !(r_raw_rc_flags & PX4IO_P_RAW_RC_FLAGS_FAILSAFE) && + (r_status_flags & PX4IO_P_STATUS_FLAGS_MIXER_OK)) { bool override = false; @@ -499,29 +497,24 @@ controls_tick() * requested override. * */ - if ((r_status_flags & PX4IO_P_STATUS_FLAGS_RC_OK) && (REG_TO_SIGNED(rc_value_override) < RC_CHANNEL_LOW_THRESH)) { + if ((r_status_flags & PX4IO_P_STATUS_FLAGS_RC_OK) && + (REG_TO_SIGNED(rc_value_override) < RC_CHANNEL_LOW_THRESH)) { override = true; } /* - if the FMU is dead then enable override if we have a - mixer and OVERRIDE_IMMEDIATE is set + * If the FMU is dead then enable override if we have a mixer + * and we want to immediately override (instead of using the RC channel + * as in the case above. */ if (!(r_status_flags & PX4IO_P_STATUS_FLAGS_FMU_OK) && - (r_setup_arming & PX4IO_P_SETUP_ARMING_OVERRIDE_IMMEDIATE) && - (r_status_flags & PX4IO_P_STATUS_FLAGS_MIXER_OK)) { + (r_setup_arming & PX4IO_P_SETUP_ARMING_OVERRIDE_IMMEDIATE)) { override = true; } if (override) { - r_status_flags |= PX4IO_P_STATUS_FLAGS_OVERRIDE; - /* mix new RC input control values to servos */ - if (dsm_updated || sbus_updated || ppm_updated || st24_updated || sumd_updated) { - mixer_tick(); - } - } else { r_status_flags &= ~(PX4IO_P_STATUS_FLAGS_OVERRIDE); }