diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-09-02 11:20:36 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-09-02 11:20:36 +0200 |
commit | e9373752d1a651cc65555781b3c6c0ab6134ccc5 (patch) | |
tree | 321719ac4800a25ca71badb155b9e796b86f1b78 | |
parent | cf62c892f9a8016ee238be269ee6c4b674928e7f (diff) | |
download | px4-firmware-e9373752d1a651cc65555781b3c6c0ab6134ccc5.tar.gz px4-firmware-e9373752d1a651cc65555781b3c6c0ab6134ccc5.tar.bz2 px4-firmware-e9373752d1a651cc65555781b3c6c0ab6134ccc5.zip |
Fixed arming state setting / publication
-rw-r--r-- | apps/commander/state_machine_helper.c | 2 | ||||
-rw-r--r-- | apps/mavlink/mavlink.c | 19 |
2 files changed, 8 insertions, 13 deletions
diff --git a/apps/commander/state_machine_helper.c b/apps/commander/state_machine_helper.c index 462406648..7db920f91 100644 --- a/apps/commander/state_machine_helper.c +++ b/apps/commander/state_machine_helper.c @@ -121,7 +121,7 @@ int do_state_update(int status_pub, struct vehicle_status_s *current_status, con if (current_status->state_machine == SYSTEM_STATE_STANDBY || current_status->state_machine == SYSTEM_STATE_PREFLIGHT) { /* set system flags according to state */ - current_status->flag_system_armed = true; + current_status->flag_system_armed = false; mavlink_log_critical(mavlink_fd, "[commander] Switched to PREFLIGHT state"); } else { invalid_state = true; diff --git a/apps/mavlink/mavlink.c b/apps/mavlink/mavlink.c index 674efe4e7..d2780dec3 100644 --- a/apps/mavlink/mavlink.c +++ b/apps/mavlink/mavlink.c @@ -375,70 +375,65 @@ void get_mavlink_mode_and_state(const struct vehicle_status_s *c_status, uint8_t *mavlink_mode |= MAV_MODE_FLAG_MANUAL_INPUT_ENABLED; } + /* set arming state */ + if (c_status->flag_system_armed) { + *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; + } else { + *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; + } + switch (c_status->state_machine) { case SYSTEM_STATE_PREFLIGHT: if (c_status->flag_preflight_gyro_calibration || c_status->flag_preflight_mag_calibration || c_status->flag_preflight_accel_calibration) { *mavlink_state = MAV_STATE_CALIBRATING; - *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; } else { *mavlink_state = MAV_STATE_UNINIT; - *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; } break; case SYSTEM_STATE_STANDBY: *mavlink_state = MAV_STATE_STANDBY; - *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_GROUND_READY: *mavlink_state = MAV_STATE_ACTIVE; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_MANUAL: *mavlink_state = MAV_STATE_ACTIVE; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; *mavlink_mode |= MAV_MODE_FLAG_MANUAL_INPUT_ENABLED; break; case SYSTEM_STATE_STABILIZED: *mavlink_state = MAV_STATE_ACTIVE; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; *mavlink_mode |= MAV_MODE_FLAG_STABILIZE_ENABLED; break; case SYSTEM_STATE_AUTO: *mavlink_state = MAV_STATE_ACTIVE; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; *mavlink_mode |= MAV_MODE_FLAG_GUIDED_ENABLED; break; case SYSTEM_STATE_MISSION_ABORT: *mavlink_state = MAV_STATE_EMERGENCY; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_EMCY_LANDING: *mavlink_state = MAV_STATE_EMERGENCY; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_EMCY_CUTOFF: *mavlink_state = MAV_STATE_EMERGENCY; - *mavlink_mode |= MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_GROUND_ERROR: *mavlink_state = MAV_STATE_EMERGENCY; - *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; break; case SYSTEM_STATE_REBOOT: *mavlink_state = MAV_STATE_POWEROFF; - *mavlink_mode &= ~MAV_MODE_FLAG_SAFETY_ARMED; break; } |