mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 05:21:35 +08:00
Commander: Fix dynamic battery scaling, proposed by @orangelynx. Fixes #2523.
This commit is contained in:
@@ -382,8 +382,12 @@ float battery_remaining_estimate_voltage(float voltage, float discharged, float
|
|||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
/* remaining charge estimate based on voltage and internal resistance (drop under load) */
|
/* remaining charge estimate based on voltage and internal resistance (drop under load) */
|
||||||
float bat_v_full_dynamic = bat_v_full - (bat_v_load_drop * throttle_normalized);
|
float bat_v_empty_dynamic = bat_v_empty - (bat_v_load_drop * throttle_normalized);
|
||||||
float remaining_voltage = (voltage - (bat_n_cells * bat_v_empty)) / (bat_n_cells * (bat_v_full_dynamic - bat_v_empty));
|
/* 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
|
||||||
|
*/
|
||||||
|
float voltage_range = (bat_v_full - bat_v_empty)
|
||||||
|
float remaining_voltage = (voltage - (bat_n_cells * bat_v_empty_dynamic)) / (bat_n_cells * voltage_range);
|
||||||
|
|
||||||
if (bat_capacity > 0.0f) {
|
if (bat_capacity > 0.0f) {
|
||||||
/* if battery capacity is known, use discharged current for estimate, but don't show more than voltage estimate */
|
/* if battery capacity is known, use discharged current for estimate, but don't show more than voltage estimate */
|
||||||
|
|||||||
Reference in New Issue
Block a user