Use filtered throttle for battery voltage compensation #9055
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an internal resistance for the battery has not been selected the firmware uses throttle and the
BAT_V_LOAD_DROP
parameter to compensate for the voltage drop due to load on the battery. The battery voltage has a delayed response to a change in load and it is further filtered to get rid of high-frequency noise. However the throttle value that is used in the calculation can change immediately, this means that when the throttle changes suddenly the compensation will be way off until the filtered voltage has had time to stabilize.This issue can be seen at 18:24.75 in this log:
https://review.px4.io/plot_app?log=53b9938b-ad16-453a-b6f5-e0d5637eba66
When the quadcopter is switched from manual mode to position mode the throttle jumps from 100% to 6%. This causes the battery estimation to drop from ~40% down to 0%. It then slowly recovers back to 40% as the voltage rises.
This pull request replaces the battery voltage drop compensation's raw throttle value with a value that has been filtered at the same time constant as the battery voltage. This prevents the compensation from overshooting during sudden changes of throttle.