Skip to content

Commit

Permalink
AP_Arming: Reduce response time when checks go from true to false
Browse files Browse the repository at this point in the history
  • Loading branch information
olliw42 authored and magicrub committed Nov 25, 2023
1 parent 4ffcc56 commit 8f9df5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libraries/AP_Arming/AP_Arming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ void AP_Arming::update(void)
const uint32_t now_ms = AP_HAL::millis();
// perform pre-arm checks & display failures every 30 seconds
bool display_fail = false;
if (now_ms - last_prearm_display_ms > PREARM_DISPLAY_PERIOD*1000) {
if ((report_immediately && (now_ms - last_prearm_display_ms > 4000)) ||
(now_ms - last_prearm_display_ms > PREARM_DISPLAY_PERIOD*1000)) {
report_immediately = false;
display_fail = true;
last_prearm_display_ms = now_ms;
}
Expand Down Expand Up @@ -1540,7 +1542,7 @@ bool AP_Arming::pre_arm_checks(bool report)
}
#endif

return hardware_safety_check(report)
bool checks_result = hardware_safety_check(report)
#if HAL_HAVE_IMU_HEATER
& heater_min_temperature_checks(report)
#endif
Expand Down Expand Up @@ -1575,6 +1577,13 @@ bool AP_Arming::pre_arm_checks(bool report)
& opendroneid_checks(report)
& serial_protocol_checks(report)
& estop_checks(report);

if (!checks_result && last_prearm_checks_result) { // check went from true to false
report_immediately = true;
}
last_prearm_checks_result = checks_result;

return checks_result;
}

bool AP_Arming::arm_checks(AP_Arming::Method method)
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_Arming/AP_Arming.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class AP_Arming {
uint32_t last_prearm_display_ms; // last time we send statustexts for prearm failures
bool running_arming_checks; // true if the arming checks currently being performed are being done because the vehicle is trying to arm the vehicle

bool last_prearm_checks_result; // result of last prearm check
bool report_immediately; // set to true when check goes from true to false, to trigger immediate report

void update_arm_gpio();
};

Expand Down

0 comments on commit 8f9df5a

Please sign in to comment.