mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-27 12:10:34 +08:00
battery: make time remaining estimation dependent on level flight cha… (#22401)
* battery: make time remaining estimation dependent on level flight characteristis for FW * battery: fix that FW flight is also correctly detected when vehicle_status is not updated Signed-off-by: Silvan Fuhrer <silvan@auterion.com> * FixedwingPositionControl: Move constant to header file * flight phase estimation: use tecs height rate reference to check for level flight --------- Signed-off-by: Silvan Fuhrer <silvan@auterion.com> Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
@@ -311,16 +311,23 @@ float Battery::computeRemainingTime(float current_a)
|
||||
|
||||
if (_vehicle_status_sub.copy(&vehicle_status)) {
|
||||
_armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
|
||||
_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) {
|
||||
_current_average_filter_a.reset(_params.bat_avrg_current);
|
||||
}
|
||||
|
||||
if (_armed && PX4_ISFINITE(current_a)) {
|
||||
// only update with positive numbers
|
||||
_current_average_filter_a.update(fmaxf(current_a, 0.f));
|
||||
// For FW only update when we are in level flight
|
||||
if (!_vehicle_status_is_fw || ((hrt_absolute_time() - _flight_phase_estimation_sub.get().timestamp) < 2_s
|
||||
&& _flight_phase_estimation_sub.get().flight_phase == flight_phase_estimation_s::FLIGHT_PHASE_LEVEL)) {
|
||||
// only update with positive numbers
|
||||
_current_average_filter_a.update(fmaxf(current_a, 0.f));
|
||||
}
|
||||
}
|
||||
|
||||
// Remaining time estimation only possible with capacity
|
||||
|
||||
Reference in New Issue
Block a user