Browse Source

battery:Only change the warning level on a connected battery.

Connected is assumed when the battery voltages is greater than
   a predefined level.
sbg
David Sidrane 8 years ago committed by Daniel Agar
parent
commit
24eb56aa27
  1. 20
      src/modules/systemlib/battery.cpp
  2. 2
      src/modules/systemlib/battery.h

20
src/modules/systemlib/battery.cpp

@ -95,7 +95,7 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre @@ -95,7 +95,7 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre
filterCurrent(current_a);
sumDischarged(timestamp, current_a);
estimateRemaining(voltage_v, current_a, throttle_normalized, armed);
determineWarning();
determineWarning(connected);
computeScale();
if (_voltage_filtered_v > 2.1f) {
@ -222,17 +222,19 @@ Battery::estimateRemaining(float voltage_v, float current_a, float throttle_norm @@ -222,17 +222,19 @@ Battery::estimateRemaining(float voltage_v, float current_a, float throttle_norm
}
void
Battery::determineWarning()
Battery::determineWarning(bool connected)
{
// Smallest values must come first
if (_remaining < _param_emergency_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
if (connected) {
// Smallest values must come first
if (_remaining < _param_emergency_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
} else if (_remaining < _param_crit_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
} else if (_remaining < _param_crit_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
} else if (_remaining < _param_low_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_LOW;
} else if (_remaining < _param_low_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_LOW;
}
}
}

2
src/modules/systemlib/battery.h

@ -100,7 +100,7 @@ private: @@ -100,7 +100,7 @@ private:
void filterCurrent(float current_a);
void sumDischarged(hrt_abstime timestamp, float current_a);
void estimateRemaining(float voltage_v, float current_a, float throttle_normalized, bool armed);
void determineWarning();
void determineWarning(bool connected);
void computeScale();
control::BlockParamFloat _param_v_empty;

Loading…
Cancel
Save