core: ardupilot_manager: use SIM_OPOS_* defaults instead of --home for SITL#3986
Merged
patrickelectric merged 2 commits intoJul 14, 2026
Merged
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider handling potential I/O errors when writing
sitl_defaults.parm(e.g., missing or unwritablefirmware_folder) so that a failure to create the defaults file doesn't result in a confusing SITL startup failure. - Because
start_sitlis async and could theoretically be called multiple times, it may be worth ensuring that concurrent calls won't race on writingsitl_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).Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
patrickelectric
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The built-in SITL spawn location is hardcoded via
--homeinstart_sitl(). Because--homesetshome_is_seton the ArduPilot side, the standardSIM_OPOS_*parameters are never read (SIM_Aircraft.cpp::update_home()only falls back to them when--homeis absent), so there is currently no way to change where SITL spawns — not via parameters, API, or UI.Solution
Stop passing
--homeand instead provide the same default location (Florianópolis) as parameter defaults, via a generated--defaultsfile settingSIM_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:SIM_OPOS_*never set (or reset)SIM_OPOS_*set by the userNo UI, API, or settings changes are needed, and there is zero behavior change for existing users. This also follows the existing
--defaultsusage for physical Linux boards (get_default_params_cmdline()instart_linux_board()).Testing
Verified on a Raspberry Pi running BlueOS
masterwith the distributed ArduCopter SITL binary (--model quad,ardupilot_sitl_arm_linux_gnueabihf):--defaults, and the file is layered on top of the embedded per-frame defaults:Loaded defaults from @ROMFS/default_params/copter.parm,.../sitl_defaults.parmHome: -27.563000 -48.459000 alt=0.000000m hdg=270.000000SIM_OPOS_LAT/LNGvia GCS and restarting the autopilot spawns the vehicle at the new location, persisting across restartsNote
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.ymlworkflow — happy to discuss or rework the contribution if AI-assisted changes are not acceptable.Summary by Sourcery
Enhancements: