Skip to content

Commit

Permalink
px4iofirmware: no override in multirotor mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julianoes authored and LorenzMeier committed Jul 29, 2016
1 parent 57b3bbf commit ec035b7
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/modules/px4iofirmware/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down

0 comments on commit ec035b7

Please sign in to comment.