Skip to content

Commit

Permalink
battery: only reset soc filter with valid voltage measurement (#23513)
Browse files Browse the repository at this point in the history
  • Loading branch information
chfriedrich98 authored Aug 8, 2024
1 parent 0381e14 commit a91aa40
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ void Battery::updateCurrent(const float current_a)

void Battery::updateBatteryStatus(const hrt_abstime &timestamp)
{
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;
Expand All @@ -121,9 +117,13 @@ void Battery::updateBatteryStatus(const hrt_abstime &timestamp)
_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);
Expand Down

0 comments on commit a91aa40

Please sign in to comment.