forked from Archive/PX4-Autopilot
battery: reset current filter when transitioning to FW
VTOLs consume a lot more power in hover copared to fixed-wing fligt. The remaining flight time thus should reset if one switches from MC to FW, as otherwise it takes several minutes until the estimate goes down. Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
parent
f68f88b97c
commit
1e223b21eb
|
@ -287,16 +287,27 @@ void Battery::computeScale()
|
||||||
float Battery::computeRemainingTime(float current_a)
|
float Battery::computeRemainingTime(float current_a)
|
||||||
{
|
{
|
||||||
float time_remaining_s = NAN;
|
float time_remaining_s = NAN;
|
||||||
|
bool reset_current_avg_filter = false;
|
||||||
|
|
||||||
if (_vehicle_status_sub.updated()) {
|
if (_vehicle_status_sub.updated()) {
|
||||||
vehicle_status_s vehicle_status;
|
vehicle_status_s vehicle_status;
|
||||||
|
|
||||||
if (_vehicle_status_sub.copy(&vehicle_status)) {
|
if (_vehicle_status_sub.copy(&vehicle_status)) {
|
||||||
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
|
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
|
||||||
|
|
||||||
|
if (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING && _vtol_was_in_mc_mode) {
|
||||||
|
reset_current_avg_filter = true;
|
||||||
|
_vtol_was_in_mc_mode = false;
|
||||||
|
|
||||||
|
} else if (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) {
|
||||||
|
_vtol_was_in_mc_mode = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PX4_ISFINITE(_current_average_filter_a.getState()) || _current_average_filter_a.getState() < FLT_EPSILON) {
|
// reset filter if not feasible, negative or we did a VTOL transition to FW mode
|
||||||
|
if (!PX4_ISFINITE(_current_average_filter_a.getState()) || _current_average_filter_a.getState() < FLT_EPSILON ||
|
||||||
|
reset_current_avg_filter) {
|
||||||
_current_average_filter_a.reset(_params.bat_avrg_current);
|
_current_average_filter_a.reset(_params.bat_avrg_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,4 +178,5 @@ private:
|
||||||
hrt_abstime _last_timestamp{0};
|
hrt_abstime _last_timestamp{0};
|
||||||
bool _armed{false};
|
bool _armed{false};
|
||||||
hrt_abstime _last_unconnected_timestamp{0};
|
hrt_abstime _last_unconnected_timestamp{0};
|
||||||
|
bool _vtol_was_in_mc_mode{false};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue