Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bat_sim: parameter for disabling battery simulator #22710

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

potaito
Copy link
Contributor

@potaito potaito commented Feb 1, 2024

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

  • New parameter SIM_BAT_ENABLE that defaults to 1, but when set to 0 it won't start the internal battery simulator

Changelog Entry

For release notes:

Feature Parameter for enabling/disabling PX4's internal battery simulator in SITL
New parameter: SIM_BAT_ENABLE

Alternatives

Alternatively custom board configs for SITL would be required, where the battery_simulator is not launched. But that's not maintainable.

Test coverage

  • Tested in simulation with make px4_sitl gz_x500
  • Tested external battery simulator by setting SIM_BAT_ENABLE = 0, and then sending BATTERY_STATUS via MAVLink to PX4

@potaito potaito self-assigned this Feb 1, 2024
@potaito potaito requested a review from dagar February 1, 2024 13:27
@potaito potaito added the Sim: SITL software in the loop simulation label Feb 2, 2024

if param compare SIM_BAT_ENABLE 1
then
battery_simulator start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dagar dagar merged commit a6fcb8e into main Feb 6, 2024
89 of 91 checks passed
@dagar dagar deleted the potaito/optional-battery-simulator branch February 6, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sim: SITL software in the loop simulation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants