mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 22:58:10 +08:00
battery: connected check outside of determineWarning()
This commit is contained in:
+12
-14
@@ -137,8 +137,8 @@ void Battery::updateBatteryStatus(const hrt_abstime ×tamp, float voltage_v,
|
||||
estimateStateOfCharge(_voltage_filter_v.getState(), _current_filter_a.getState(), _throttle_filter.getState());
|
||||
computeScale();
|
||||
|
||||
if (_battery_initialized) {
|
||||
determineWarning(connected);
|
||||
if (connected && _battery_initialized) {
|
||||
determineWarning();
|
||||
}
|
||||
|
||||
if (_voltage_filter_v.getState() > 2.1f) {
|
||||
@@ -239,22 +239,20 @@ void Battery::estimateStateOfCharge(const float voltage_v, const float current_a
|
||||
}
|
||||
}
|
||||
|
||||
void Battery::determineWarning(bool connected)
|
||||
void Battery::determineWarning()
|
||||
{
|
||||
if (connected) {
|
||||
// propagate warning state only if the state is higher, otherwise remain in current warning state
|
||||
if (_state_of_charge < _params.emergen_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
|
||||
// propagate warning state only if the state is higher, otherwise remain in current warning state
|
||||
if (_battery_status.remaining < _params.emergen_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
|
||||
|
||||
} else if (_state_of_charge < _params.crit_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
} else if (_battery_status.remaining < _params.crit_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||
|
||||
} else if (_state_of_charge < _params.low_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
||||
} else if (_battery_status.remaining < _params.low_thr) {
|
||||
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
||||
|
||||
} else {
|
||||
_warning = battery_status_s::BATTERY_WARNING_NONE;
|
||||
}
|
||||
} else {
|
||||
_warning = battery_status_s::BATTERY_WARNING_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ protected:
|
||||
private:
|
||||
void sumDischarged(const hrt_abstime ×tamp, float current_a);
|
||||
void estimateStateOfCharge(const float voltage_v, const float current_a, const float throttle);
|
||||
void determineWarning(bool connected);
|
||||
void determineWarning();
|
||||
void computeScale();
|
||||
|
||||
uORB::PublicationMulti<battery_status_s> _battery_status_pub{ORB_ID(battery_status)};
|
||||
|
||||
Reference in New Issue
Block a user