-
Notifications
You must be signed in to change notification settings - Fork 46
Move parameters and update load_params #119
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
634a264
Move parameters and update load_params
ratheron 6c2e148
Split load_params into two functions, move all params for fp and gene…
ratheron 89702ad
Adress review comments
ratheron 3951852
Clean up tests and SKILL.md
ratheron ab5f573
Rename function to fn
ratheron f6602f7
Apply batched suggestions from code review
ratheron ab320ac
Fix docstring
ratheron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,16 @@ | ||
| """Hardware descriptions for the supported drone platforms. | ||
|
|
||
| This package bundles the physical assets that define each drone configuration: the MuJoCo MJCF scene | ||
| files, their referenced meshes (``assets/``), and the physical parameters shared across all dynamics | ||
| (``params.toml`` with mass, inertia, thrust and torque curves, …). These describe the *hardware* and | ||
| are independent of the dynamics formulation used to simulate it (see [crazyflow.dynamics][]). | ||
| This package bundles the MuJoCo MJCF scene files that define each drone configuration and their | ||
| referenced meshes (``assets/``). For the physical params, see [crazyflow.dynamics.load_params][]. | ||
|
|
||
| Use ``available_drones`` to enumerate the supported configurations, and ``load_params`` to read all | ||
| physical parameters of a drone. | ||
| Use ``available_drones`` to enumerate the supported configurations. | ||
| """ | ||
|
|
||
| import tomllib | ||
| from pathlib import Path | ||
|
|
||
| # Currently supported platforms: | ||
| # * **cf2x_L250** — Crazyflie 2.x | ||
| # * **cf2x_P250** — Crazyflie 2.x with plus propellers | ||
| # * **cf2x_T350** — Crazyflie 2.x with thrust upgrade kit | ||
| # * **cf21B_500** — Crazyflie 2.1 Brushless with 500 mAh battery | ||
| available_drones: tuple[str, ...] = ("cf2x_L250", "cf2x_P250", "cf2x_T350", "cf21B_500") | ||
|
|
||
| __all__ = ["available_drones", "load_params"] | ||
|
|
||
|
|
||
| def load_params(drone: str) -> dict: | ||
| """Load all physical parameters of a drone from ``params.toml``. | ||
|
|
||
| Returns the raw values (lists/scalars) for the whole drone. | ||
|
|
||
| Args: | ||
| drone: Name of the drone configuration, e.g. ``"cf2x_L250"``. | ||
| """ | ||
| with open(Path(__file__).parent / "params.toml", "rb") as f: | ||
| params = tomllib.load(f) | ||
| if drone not in params or drone not in available_drones: | ||
| raise KeyError(f"Drone `{drone}` not found in drones/params.toml") | ||
| return params[drone] | ||
| __all__ = ["available_drones"] |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
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.