mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 21:57:35 +08:00
battery: only reset soc filter with valid voltage measurement (#23513)
This commit is contained in:
@@ -108,10 +108,6 @@ void Battery::updateCurrent(const float current_a)
|
||||
|
||||
void Battery::updateBatteryStatus(const hrt_abstime ×tamp)
|
||||
{
|
||||
if (!_battery_initialized && _internal_resistance_initialized && _params.n_cells > 0) {
|
||||
resetInternalResistanceEstimation(_voltage_v, _current_a);
|
||||
}
|
||||
|
||||
// Require minimum voltage otherwise override connected status
|
||||
if (_voltage_v < LITHIUM_BATTERY_RECOGNITION_VOLTAGE) {
|
||||
_connected = false;
|
||||
@@ -121,9 +117,13 @@ void Battery::updateBatteryStatus(const hrt_abstime ×tamp)
|
||||
_last_unconnected_timestamp = timestamp;
|
||||
}
|
||||
|
||||
// wait with initializing filters to avoid relying on a voltage sample from the rising edge
|
||||
// Wait with initializing filters to avoid relying on a voltage sample from the rising edge
|
||||
_battery_initialized = _connected && (timestamp > _last_unconnected_timestamp + 2_s);
|
||||
|
||||
if (_connected && !_battery_initialized && _internal_resistance_initialized && _params.n_cells > 0) {
|
||||
resetInternalResistanceEstimation(_voltage_v, _current_a);
|
||||
}
|
||||
|
||||
sumDischarged(timestamp, _current_a);
|
||||
_state_of_charge_volt_based =
|
||||
calculateStateOfChargeVoltageBased(_voltage_v, _current_a);
|
||||
|
||||
Reference in New Issue
Block a user