commander: enable arming on boot

This commit is contained in:
mahima-yoga
2026-02-27 16:57:18 +01:00
committed by Mahima Yoga
parent 30bbd6ecd4
commit 873ee61d57
3 changed files with 29 additions and 1 deletions

View File

@@ -1870,6 +1870,7 @@ void Commander::run()
#endif // BOARD_HAS_POWER_CONTROL
_boot_timestamp = hrt_absolute_time();
_arm_on_boot_requested = _param_com_arm_on_boot.get();
arm_auth_init(&_mavlink_log_pub, &_vehicle_status.system_id);
@@ -1949,6 +1950,20 @@ void Commander::run()
perf_end(_preflight_check_perf);
checkAndInformReadyForTakeoff();
// Arm automatically on boot once preflight checks pass
// _arm_on_boot_done prevents re-arming after disarming
const bool should_arm_on_boot = _arm_on_boot_requested
&& !_arm_on_boot_done
&& !isArmed()
&& hrt_elapsed_time(&_boot_timestamp) > 5_s
&& pre_flight_checks_pass;
if (should_arm_on_boot) {
if (arm(arm_disarm_reason_t::mission_start, false) != TRANSITION_DENIED) {
_arm_on_boot_done = true;
}
}
}
// handle commands last, as the system needs to be updated to handle them