bat_sim: parameter for disabling battery simulator #22710
Merged
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.
Solved Problem
I would like to run a more complex battery simulation in a standalone application. This can currently be achieved by stopping PX4's internal battery simulator after a boot, and then sending BATTERY_STATUS MAVLink messages.
This PR proposes a parameter that controls the startup of the internal battery simulator. When disabling the battery simulator, it removes the extra step necessary after each boot to stop the battery simulator. But it also produces consistent measurements for PX4, since there will then only be the battery messages coming in through MAVLink.
Solution
SIM_BAT_ENABLE
that defaults to 1, but when set to 0 it won't start the internal battery simulatorChangelog Entry
For release notes:
Alternatives
Alternatively custom board configs for SITL would be required, where the battery_simulator is not launched. But that's not maintainable.
Test coverage
make px4_sitl gz_x500
SIM_BAT_ENABLE = 0
, and then sending BATTERY_STATUS via MAVLink to PX4