mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
battery: reset current filter when transitioning to FW (#22256)
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.
This commit is contained in:
parent
2ce92a678d
commit
b53d2cdf39
@ -305,19 +305,27 @@ void Battery::computeScale()
|
||||
float Battery::computeRemainingTime(float current_a)
|
||||
{
|
||||
float time_remaining_s = NAN;
|
||||
bool reset_current_avg_filter = false;
|
||||
|
||||
if (_vehicle_status_sub.updated()) {
|
||||
vehicle_status_s vehicle_status;
|
||||
|
||||
if (_vehicle_status_sub.copy(&vehicle_status)) {
|
||||
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
|
||||
|
||||
if (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING && !_vehicle_status_is_fw) {
|
||||
reset_current_avg_filter = true;
|
||||
}
|
||||
|
||||
_vehicle_status_is_fw = (vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING);
|
||||
}
|
||||
}
|
||||
|
||||
_flight_phase_estimation_sub.update();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user