commander: collapse ArmStateMachine and simplify

- simplify vehicle_status.arming_state down to just armed and disarmed
    - ARMING_STATE_INIT doesn't matter
    - ARMING_STATE_STANDBY is effectively pre_flight_checks_pass
    - ARMING_STATE_STANDBY_ERROR not needed
    - ARMING_STATE_SHUTDOWN effectively not used (all the poweroff/shutdown calls loop forever in place)
    - ARMING_STATE_IN_AIR_RESTORE doesn't exist anymore
 - collapse ArmStateMachine into commander
     - all requests already go through Commander::arm() and Commander::dismarm()
 - other minor changes
     - VEHICLE_CMD_DO_FLIGHTTERMINATION undocumented (unused?) test command (param1 > 1.5f) removed
     - switching to NAVIGATION_STATE_TERMINATION triggers parachute command centrally (only if armed)

---------

Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
Daniel Agar
2023-07-28 17:12:01 -04:00
committed by GitHub
co-authored by Matthias Grob
parent 84b6b472b4
commit 88e7452492
10 changed files with 162 additions and 814 deletions
+7 -12
View File
@@ -107,28 +107,23 @@ private:
// uint8_t system_status (MAV_STATE) - System status flag.
uint8_t system_status = MAV_STATE_UNINIT;
switch (vehicle_status.arming_state) {
case vehicle_status_s::ARMING_STATE_ARMED:
if (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED) {
system_status = vehicle_status.failsafe ? MAV_STATE_CRITICAL : MAV_STATE_ACTIVE;
break;
case vehicle_status_s::ARMING_STATE_STANDBY:
} else if (vehicle_status.calibration_enabled || vehicle_status.rc_calibration_in_progress
|| actuator_armed.in_esc_calibration_mode) {
system_status = MAV_STATE_CALIBRATING;
} else if (vehicle_status.pre_flight_checks_pass) {
system_status = MAV_STATE_STANDBY;
break;
case vehicle_status_s::ARMING_STATE_SHUTDOWN:
system_status = MAV_STATE_POWEROFF;
break;
}
// system_status overrides
if (actuator_armed.force_failsafe || (actuator_armed.lockdown
&& vehicle_status.hil_state == vehicle_status_s::HIL_STATE_OFF) || actuator_armed.manual_lockdown
|| vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_TERMINATION) {
system_status = MAV_STATE_FLIGHT_TERMINATION;
} else if (vehicle_status.calibration_enabled) {
system_status = MAV_STATE_CALIBRATING;
system_status = MAV_STATE_FLIGHT_TERMINATION;
}