mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 17:41:36 +08:00
Battery: simplify linear voltage relation, currently neglecting the real world voltage drop under load
This commit is contained in:
committed by
ChristophTobler
parent
bc15fdf267
commit
52e2aecaf1
@@ -40,6 +40,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
#include <mathlib/mathlib.h>
|
||||||
|
|
||||||
Battery::Battery() :
|
Battery::Battery() :
|
||||||
SuperBlock(nullptr, "BAT"),
|
SuperBlock(nullptr, "BAT"),
|
||||||
@@ -181,13 +182,10 @@ Battery::estimateRemaining(float voltage_v, float current_a, float throttle_norm
|
|||||||
bat_v_empty_dynamic -= _param_v_load_drop.get() * thr;
|
bat_v_empty_dynamic -= _param_v_load_drop.get() * thr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the range from full to empty is the same for batteries under load and without load,
|
|
||||||
// since the voltage drop applies to both the full and empty state
|
|
||||||
const float voltage_range = (_param_v_full.get() - _param_v_empty.get());
|
|
||||||
|
|
||||||
// remaining battery capacity based on voltage
|
// remaining battery capacity based on voltage
|
||||||
const float rvoltage = (voltage_v - (_param_n_cells.get() * bat_v_empty_dynamic))
|
const float cell_voltage = voltage_v / _param_n_cells.get();
|
||||||
/ (_param_n_cells.get() * voltage_range);
|
const float rvoltage = math::gradual(cell_voltage, _param_v_empty.get(), _param_v_full.get(), 0.f, 1.f);
|
||||||
|
|
||||||
const float rvoltage_filt = _remaining_voltage * 0.99f + rvoltage * 0.01f;
|
const float rvoltage_filt = _remaining_voltage * 0.99f + rvoltage * 0.01f;
|
||||||
|
|
||||||
if (PX4_ISFINITE(rvoltage_filt)) {
|
if (PX4_ISFINITE(rvoltage_filt)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user