commander: enable arming on boot

This commit is contained in:
mahima-yoga authored and Mahima Yoga committed 2026-03-24 15:01:15 +00:00
1 parent 30bbd6ecd4
commit 873ee61d57
3 files changed
+29 -1

No files matched your search

+15
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