ESC check: use constants for ESC timeout

This commit is contained in:
ttechnick 2026-03-02 13:47:38 +01:00 committed by Matthias Grob
parent a9461c4d1a
commit 7aa28de922
2 changed files with 6 additions and 4 deletions

View File

@ -71,7 +71,7 @@ static constexpr const char *esc_fault_reason_str(esc_fault_reason_t esc_fault_r
void EscChecks::checkAndReport(const Context &context, Report &reporter)
{
const hrt_abstime now = hrt_absolute_time();
const hrt_abstime esc_telemetry_timeout = 700_ms; // Some DShot ESCs are unresponsive for ~550ms during their initialization
const hrt_abstime esc_init_time = 700_ms; // Some DShot ESCs are unresponsive for ~550ms during their initialization
esc_status_s esc_status;
@ -97,7 +97,7 @@ void EscChecks::checkAndReport(const Context &context, Report &reporter)
reporter.setIsPresent(health_component_t::motors_escs);
reporter.failsafeFlags().fd_motor_failure = mask != 0;
} else if ((_param_com_arm_chk_escs.get() > 0) && now - _start_time > esc_telemetry_timeout) { // Allow ESCs to init
} else if ((_param_com_arm_chk_escs.get() > 0) && now - _start_time > esc_init_time) { // Allow ESCs to init
/* EVENT
* @description
* <profile name="dev">
@ -126,7 +126,7 @@ uint16_t EscChecks::checkEscOnline(const Context &context, Report &reporter, con
continue; // Skip unmapped ESC status entries
}
const bool timeout = now > esc_status.esc[esc_index].timestamp + 300_ms;
const bool timeout = now > esc_status.esc[esc_index].timestamp + ESC_TIMEOUT_US;
const bool is_offline = (esc_status.esc_online_flags & (1 << esc_index)) == 0;
// Set failure bits for this motor
@ -324,7 +324,7 @@ void EscChecks::updateEscsStatus(const Context &context, Report &reporter, const
const int all_escs_armed_mask = (1 << limited_esc_count) - 1;
const bool is_all_escs_armed = (all_escs_armed_mask == esc_status.esc_armed_flags);
_esc_arm_hysteresis.set_hysteresis_time_from(false, 300_ms);
_esc_arm_hysteresis.set_hysteresis_time_from(false, ESC_TIMEOUT_US);
_esc_arm_hysteresis.set_state_and_update(!is_all_escs_armed, now);
if (_esc_arm_hysteresis.get_state()) {

View File

@ -58,6 +58,8 @@ private:
uint16_t checkMotorStatus(const Context &context, Report &reporter, const esc_status_s &esc_status, hrt_abstime now);
void updateEscsStatus(const Context &context, Report &reporter, const esc_status_s &esc_status, hrt_abstime now);
static constexpr hrt_abstime ESC_TIMEOUT_US = 300_ms;
uORB::Subscription _esc_status_sub{ORB_ID(esc_status)};
uORB::Subscription _actuator_motors_sub{ORB_ID(actuator_motors)};