Skip to content

Commit

Permalink
Fix battery charge level filter
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzMeier committed May 5, 2016
1 parent 6c61b67 commit bbd2b76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/systemlib/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ Battery::estimateRemaining(float voltage_v, float throttle_normalized)
// remaining battery capacity based on voltage
const float rvoltage = (voltage_v - (_param_n_cells.get() * bat_v_empty_dynamic))
/ (_param_n_cells.get() * voltage_range);
const float rvoltage_filt = rvoltage * 0.997f + _remaining_voltage * 0.003f;
const float rvoltage_filt = _remaining_voltage * 0.99f + rvoltage * 0.01f;

This comment has been minimized.

Copy link
@julianoes

julianoes May 5, 2016

Contributor

@LorenzMeier is it correct that the two variables are swapped now?

This comment has been minimized.

Copy link
@LorenzMeier

LorenzMeier May 5, 2016

Author Member

Yep, if you look at it the lowpass does only work if they are this way. I only adjusted the filter gains at the same point because I had incorrectly assumed in a previous attempt to fix it the filter was too low.

This comment has been minimized.

Copy link
@julianoes

julianoes May 5, 2016

Contributor

Ah yes, got it!


if (PX4_ISFINITE(rvoltage_filt)) {
_remaining_voltage = rvoltage_filt;
}

// remaining battery capacity based on used current integrated time
const float rcap = 1.0f - _discharged_mah / _param_capacity.get();
const float rcap_filt = rcap * 0.99f + _remaining_capacity * 0.01f;
const float rcap_filt = _remaining_capacity * 0.99f + rcap * 0.01f;

if (PX4_ISFINITE(rcap_filt)) {
_remaining_capacity = rcap_filt;
Expand Down

0 comments on commit bbd2b76

Please sign in to comment.