Skip to content

Move parameters and update load_params - #119

Merged
amacati merged 7 commits into
mainfrom
fix.rearranging_parameters
Sep 19, 2026
Merged

amacati merged 7 commits into
mainfrom
fix.rearranging_parameters

Conversation

@ratheron

Copy link
Copy Markdown
Collaborator

crazyflow/drones/params.toml now only holds the core parameters every drone needs: gravity_vec, mass, J, thrust_min, thrust_max. Everything else moves to the params.toml of the dynamics that uses it, i.e. the first principles coefficients and the platform data now live in crazyflow/dynamics/first_principles/params.toml. Values are unchanged. A commented example at the top of the core file documents the required keys.

This move broke crazyflow.drones.load_params, which used to be the only way to get hardware constants like pwm_max unfiltered. Since those now live in a dynamics file, that loader is removed and crazyflow.dynamics.load_params takes over: given a function it filters to its signature as before, given a Dynamics mode it returns every parameter of the drone for that dynamics.

Why

It was unclear which parameters a new drone actually needs. Now a drone that only runs the fitted models needs five keys, and the first principles section carries real content instead of being an empty marker. This prepares the availability methods PR, which derives available_drones and the supported drone/dynamics pairs from these files, and the X500 PR, the first drone without first principles parameters.

@ratheron
ratheron requested a review from amacati as a code owner September 17, 2026 22:56

@amacati amacati left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for splitting the PRs, this is really helpful.

There are two issues with this PR: First, it is not clear to me why we place some parameters into the first principles model files. Even our docstrings are inconsistent in this regard.

This inconsistency later appears in the second point, the API around load_params. I suspect the current design is forced by the requirement to get some physical parameters that are not in the function signature of the dynamics function. But getting different results for load_params(first_principles_dynamics) and load_params(Dynamics.first_principles) screams "something is off here".

We should come up with a better, more consistent solution.

Comment thread SKILL.md Outdated
Comment thread crazyflow/sim/sim.py
Comment thread examples/control/sampling.py Outdated
Comment thread crazyflow/dynamics/core.py Outdated
Comment thread crazyflow/dynamics/core.py Outdated
Comment thread crazyflow/dynamics/core.py Outdated
Comment thread crazyflow/dynamics/first_principles/params.toml Outdated
Comment thread crazyflow/drones/params.toml Outdated
Comment thread crazyflow/drones/__init__.py Outdated
Comment thread tests/unit/dynamics/test_parametrization.py Outdated
@ratheron
ratheron force-pushed the fix.rearranging_parameters branch from 52ee07d to 634a264 Compare September 18, 2026 18:13

@amacati amacati left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we sure we want the gravity vector like this? Imo it overcomplicates things way too much

Comment thread crazyflow/control/core.py

Args:
fn: The controller function for which to load parameters.
controller: Name of the controller package, e.g. ``"mellinger"``.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For future reference: This should be a StrEnum at some point.

Comment thread crazyflow/drones/__init__.py Outdated
Comment thread crazyflow/dynamics/first_principles/params.toml Outdated
Comment thread crazyflow/dynamics/first_principles/params.toml Outdated
Comment thread crazyflow/dynamics/so_rpy/params.toml Outdated
Comment thread crazyflow/dynamics/so_rpy_rotor_drag/params.toml Outdated
Comment on lines +110 to +111
with open(Path(__file__).parent / "params.toml", "rb") as f:
global_params = tomllib.load(f)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a single parameter from a file we don't expect to grow. I find this a bit strange

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In the future, maybe there will be constants on air viscosity etc. Things that sometimes live in the xml files for MuJoCo.

Comment thread crazyflow/dynamics/params.toml Outdated
Comment on lines +1 to +4
# Global parameters shared by every drone and dynamics model. Drone specific parameters live in
# the params.toml of each model.

gravity_vec = [0.0, 0.0, -9.81] # m/s^2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I find this very odd, especially since we need dedicated machinery just to load and merge this one file. If we don't even share the mass across drones, then why bother with gravity_vec?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did this because gravity is the only param that is not distinct to each drone - it's global/environmental. Other simulators just hard code this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we? Do we gain anything from having this in a config file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Flexibility is what we gain. See comment above - we might want to add things in the future. Also, let's say someone want to build quadrotors for Mars. This is something that belongs into a config in a proper system an not be hard coded imo

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated docstring

Comment thread SKILL.md Outdated
Comment thread SKILL.md Outdated
Co-authored-by: Martin Schuck <57562633+amacati@users.noreply.github.com>
@ratheron
ratheron force-pushed the fix.rearranging_parameters branch from 12e8594 to f6602f7 Compare September 18, 2026 20:37
@amacati
amacati merged commit 9fe6749 into main Sep 19, 2026
6 checks passed
@amacati
amacati deleted the fix.rearranging_parameters branch September 19, 2026 15:20
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.

2 participants