Skip to content

Commit

Permalink
battery: only reset soc filter with valid voltage measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
chfriedrich98 committed Aug 7, 2024
1 parent 2d99ae1 commit 19d9e1d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ 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;
}

if (_connected && !_battery_initialized && _internal_resistance_initialized && _params.n_cells > 0) {
resetInternalResistanceEstimation(_voltage_v, _current_a);
}

if (!_connected || (_last_unconnected_timestamp == 0)) {
_last_unconnected_timestamp = timestamp;
}
Expand Down

0 comments on commit 19d9e1d

Please sign in to comment.