Skip to content

core: ardupilot_manager: use SIM_OPOS_* defaults instead of --home for SITL#3986

Merged
patrickelectric merged 2 commits into
bluerobotics:masterfrom
hfujikawa77:sitl-home-via-sim-opos
Jul 14, 2026
Merged

core: ardupilot_manager: use SIM_OPOS_* defaults instead of --home for SITL#3986
patrickelectric merged 2 commits into
bluerobotics:masterfrom
hfujikawa77:sitl-home-via-sim-opos

Conversation

@hfujikawa77

@hfujikawa77 hfujikawa77 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

The built-in SITL spawn location is hardcoded via --home in start_sitl(). Because --home sets home_is_set on the ArduPilot side, the standard SIM_OPOS_* parameters are never read (SIM_Aircraft.cpp::update_home() only falls back to them when --home is absent), so there is currently no way to change where SITL spawns — not via parameters, API, or UI.

Solution

Stop passing --home and instead provide the same default location (Florianópolis) as parameter defaults, via a generated --defaults file setting SIM_OPOS_LAT/LNG/ALT/HDG.

Since user-stored parameter values take precedence over defaults, the spawn location becomes configurable from any GCS (QGC parameter editor, MAVProxy param set, …) and persists across restarts, while the location itself is resolved entirely by ArduPilot's parameter system:

State Spawn location
SIM_OPOS_* never set (or reset) Florianópolis — identical to current behavior
SIM_OPOS_* set by the user The user's location

No UI, API, or settings changes are needed, and there is zero behavior change for existing users. This also follows the existing --defaults usage for physical Linux boards (get_default_params_cmdline() in start_linux_board()).

Testing

Verified on a Raspberry Pi running BlueOS master with the distributed ArduCopter SITL binary (--model quad, ardupilot_sitl_arm_linux_gnueabihf):

  • The distributed SITL binary supports --defaults, and the file is layered on top of the embedded per-frame defaults: Loaded defaults from @ROMFS/default_params/copter.parm,.../sitl_defaults.parm
  • With no user-set parameters, SITL spawns at the previous default: Home: -27.563000 -48.459000 alt=0.000000m hdg=270.000000
  • Setting SIM_OPOS_LAT/LNG via GCS and restarting the autopilot spawns the vehicle at the new location, persisting across restarts

Note

This change was developed with AI assistance (Claude Code) and reviewed, tested, and committed by me. I'm aware of the recent block-ai-commits.yml workflow — happy to discuss or rework the contribution if AI-assisted changes are not acceptable.

Summary by Sourcery

Enhancements:

  • Generate a sitl_defaults.parm file with default SIM_OPOS_LAT/LNG/ALT/HDG values matching the previous Florianópolis home location and pass it via --defaults when starting SITL.

@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider handling potential I/O errors when writing sitl_defaults.parm (e.g., missing or unwritable firmware_folder) so that a failure to create the defaults file doesn't result in a confusing SITL startup failure.
  • Because start_sitl is async and could theoretically be called multiple times, it may be worth ensuring that concurrent calls won't race on writing sitl_defaults.parm (for example by reusing an existing file or adding a simple guard).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider handling potential I/O errors when writing `sitl_defaults.parm` (e.g., missing or unwritable `firmware_folder`) so that a failure to create the defaults file doesn't result in a confusing SITL startup failure.
- Because `start_sitl` is async and could theoretically be called multiple times, it may be worth ensuring that concurrent calls won't race on writing `sitl_defaults.parm` (for example by reusing an existing file or adding a simple guard).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@patrickelectric patrickelectric merged commit 76ff3da into bluerobotics:master Jul 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants