Skip to content

Commit

Permalink
commander: fix broken 'commander arm/disarm' CLI
Browse files Browse the repository at this point in the history
Regression from #13613.

VEHICLE_CMD_COMPONENT_ARM_DISARM from CLI would enter the
ARMING_STATE_IN_AIR_RESTORE logic. This was never intended for disarming
(and leads to state machine transition failures), and IMO it is also not
intended for commands from CLI.
  • Loading branch information
bkueng authored and dagar committed Feb 20, 2020
1 parent 20276d4 commit 116a094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/drivers/px4io/px4io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ PX4IO::init()
/* send command to arm system via command API */
vcmd.timestamp = hrt_absolute_time();
vcmd.param1 = 1.0f; /* request arming */
vcmd.param3 = 1234.f; /* mark the command coming from IO (for in-air restoring) */
vcmd.command = vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM;

/* send command once */
Expand Down
7 changes: 5 additions & 2 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,11 @@ Commander::handle_command(vehicle_status_s *status_local, const vehicle_command_
break;
}

// Flick to inair restore first if this comes from an onboard system
if (cmd.source_system == status_local->system_id && cmd.source_component == status_local->component_id) {
const bool cmd_from_io = (static_cast<int>(roundf(cmd.param3)) == 1234);

// Flick to inair restore first if this comes from an onboard system and from IO
if (cmd.source_system == status_local->system_id && cmd.source_component == status_local->component_id
&& cmd_from_io && cmd_arms) {
status.arming_state = vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE;

} else {
Expand Down

0 comments on commit 116a094

Please sign in to comment.