From adc9ed61b888ebced95d39420e1c8642a532fae9 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 6 Dec 2016 17:25:49 +0100 Subject: [PATCH] commander: ignore arm/disarm in DO_SET_MODE cmd According to https://github.com/mavlink/mavlink/pull/629 the mavlink command DO_SET_MODE should only determine the mode but not the armed/disarmed state, so the MAV_MODE_FLAG_SAFETY_ARMED bit should be ignored. Instead the mavlink command COMPONENT_ARM_DISARM should be used instead. Therefore, the commander now ignores the arm/disarm bit. --- src/modules/commander/commander.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 2ecfbeaa0b..6d2ca2139d 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -730,17 +730,9 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s hil_state_t new_hil_state = (base_mode & VEHICLE_MODE_FLAG_HIL_ENABLED) ? vehicle_status_s::HIL_STATE_ON : vehicle_status_s::HIL_STATE_OFF; transition_result_t hil_ret = hil_state_transition(new_hil_state, status_pub, status_local, &mavlink_log_pub); - // Transition the arming state - bool cmd_arm = base_mode & VEHICLE_MODE_FLAG_SAFETY_ARMED; - - arming_ret = arm_disarm(cmd_arm, &mavlink_log_pub, "set mode command"); - - /* update home position on arming if at least 500 ms from commander start spent to avoid setting home on in-air restart */ - if (cmd_arm && (arming_ret == TRANSITION_CHANGED) && - (hrt_absolute_time() > (commander_boot_timestamp + INAIR_RESTART_HOLDOFF_INTERVAL))) { - - commander_set_home_position(*home_pub, *home, *local_pos, *global_pos, *attitude); - } + // We ignore base_mode & VEHICLE_MODE_FLAG_SAFETY_ARMED because + // the command VEHICLE_CMD_COMPONENT_ARM_DISARM should be used + // instead according to the latest mavlink spec. if (base_mode & VEHICLE_MODE_FLAG_CUSTOM_MODE_ENABLED) { /* use autopilot-specific mode */