Skip to content

Tools: break callisto SITL config to a common method#32828

Open
Ryanf55 wants to merge 1 commit intoArduPilot:masterfrom
Ryanf55:copter-autotest-reduce-callisto-duplication
Open

Tools: break callisto SITL config to a common method#32828
Ryanf55 wants to merge 1 commit intoArduPilot:masterfrom
Ryanf55:copter-autotest-reduce-callisto-duplication

Conversation

@Ryanf55
Copy link
Copy Markdown
Contributor

@Ryanf55 Ryanf55 commented Apr 18, 2026

Summary

  • Reduces code duplication of SITL setup for Callisto in the autotest suite

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request
./Tools/autotest/autotest.py  test.CopterTests2b.PeriphMultiUARTTunnel test.CopterTests1c.BaroWindCorrection test.CopterTests2b.LUAConfigProfile test.CopterTests1c.BaroWindCorrection

Description

Pull out the args needed for callisto into a function that returns kwargs.
You can then use the ** operator to unpack the kwargs nicely.

* Reduces code duplication

Signed-off-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@hunt0r hunt0r left a comment

Choose a reason for hiding this comment

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

Hurray DRY code!

Opinion: Dicts are most appropriate when the structure of their information is not known in advance. In cases like this one, it's less convenient, but slightly stronger, to use a more structured alternative (e.g. namedtuple, dataclass).

I'm happy to say more if anyone is interested... but it's a minor improvement and definitely not something I'd block over. This is great as-is.

@Ryanf55
Copy link
Copy Markdown
Contributor Author

Ryanf55 commented Apr 18, 2026

Hurray DRY code!

Opinion: Dicts are most appropriate when the structure of their information is not known in advance. In cases like this one, it's less convenient, but slightly stronger, to use a more structured alternative (e.g. namedtuple, dataclass).

I'm happy to say more if anyone is interested... but it's a minor improvement and definitely not something I'd block over. This is great as-is.

I like named tuples. I'm actually the only person to use that object in the entire Tools folder.
image

I don't know if that would be allowed in autotest.
Open to maintainer's options, or happy to bump usage of NamedTuple replacing known dictionary contents to another follow up! I was hoping for a quick merge on this :)

defaults_filepath=self.model_defaults_filepath('Callisto'),
model="octa-quad:@ROMFS/models/Callisto.json",
**self.callisto_sitl_kwargs(),
wipe=True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better swipe this one too - but add a comment that we do wipe the parameters....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants