Reintegrate drone_models and drone_controllers into crazyflow#71
Reintegrate drone_models and drone_controllers into crazyflow#71amacati wants to merge 24 commits into
drone_models and drone_controllers into crazyflow#71Conversation
7afd420 to
e53f1e5
Compare
drone_models into crazyflow & unify namingdrone_models and drone_controllers into crazyflow
ratheron
left a comment
There was a problem hiding this comment.
Thanks for working on this integration! This will make the entry to Crazyflow easier
| \[ | ||
| \begin{aligned} | ||
| \dot{\mathbf{p}} &= \mathbf{v}, \\ | ||
| \dot{\mathbf{q}} &= \tfrac{1}{2} | ||
| \begin{bmatrix}0 \\ {}^{\mathcal{B}}\boldsymbol{\omega}\end{bmatrix} | ||
| \otimes \mathbf{q}, \\ | ||
| m\dot{\mathbf{v}} &= m\mathbf{g} | ||
| + (c_{\mathrm{acc}} + c_f F_{\mathrm{cmd}})\,R\,\mathbf{e}_z, \\ | ||
| \ddot{\boldsymbol{\psi}} &= | ||
| c_{\psi}\,\boldsymbol{\psi} | ||
| + c_{\dot{\psi}}\,\dot{\boldsymbol{\psi}} | ||
| + c_u\,\mathbf{u}_{\mathrm{rpy}}, | ||
| \end{aligned} | ||
| \] |
There was a problem hiding this comment.
Is there a way to preview the output to double check this nicely?
There was a problem hiding this comment.
https://www.tuhh.de/MathJax/test/sample-dynamic-2.html, but it requires copy+paste. Other than that, only running it locally with pixi run docs-serve
There was a problem hiding this comment.
Fixed the rotation direction of the quaternion and the ordering of entries
There was a problem hiding this comment.
Why is there a q in the equation? The core model only has psi as state. While it get's transformed to fit the Crazyflow states, I think adding this is conversion is more confusing
|
Latest changes are all in and ready for another review |
ratheron
left a comment
There was a problem hiding this comment.
Looks like you found a clean solution for the parameterize after all. I like it!
Left some minor comments
| \[ | ||
| \begin{aligned} | ||
| \dot{\mathbf{p}} &= \mathbf{v}, \\ | ||
| \dot{\mathbf{q}} &= \tfrac{1}{2} | ||
| \begin{bmatrix}0 \\ {}^{\mathcal{B}}\boldsymbol{\omega}\end{bmatrix} | ||
| \otimes \mathbf{q}, \\ | ||
| m\dot{\mathbf{v}} &= m\mathbf{g} | ||
| + (c_{\mathrm{acc}} + c_f F_{\mathrm{cmd}})\,R\,\mathbf{e}_z, \\ | ||
| \ddot{\boldsymbol{\psi}} &= | ||
| c_{\psi}\,\boldsymbol{\psi} | ||
| + c_{\dot{\psi}}\,\dot{\boldsymbol{\psi}} | ||
| + c_u\,\mathbf{u}_{\mathrm{rpy}}, | ||
| \end{aligned} | ||
| \] |
There was a problem hiding this comment.
Why is there a q in the equation? The core model only has psi as state. While it get's transformed to fit the Crazyflow states, I think adding this is conversion is more confusing
ratheron
left a comment
There was a problem hiding this comment.
Looks like you found a clean solution for the parameterize after all. I like it!
Left some minor comments
345e1cb to
f22b001
Compare
drone-modelsPrevious state
Drone definitions and dynamics lived in a separate
drone-modelspackage, pulled in as a PyPI dependency / git submodule (submodules/drone-models,import drone_models). The MJCF files, meshes and parameters were resolved viadrone_models.__file__, and the dynamics were imported intocrazyflow/sim/physics.py.Naming ambiguities
"Model" was overloaded three ways — the MuJoCo MJX model, the dynamics formulation, and the drone hardware. "models", "physics" and "dynamics" were often used interchangeably. These disambiguities have been fixed in the same step:
Physics/models/dynamicsDynamics/dynamicsdrone_model(param/attr)dronemodel(spec, file name)mjx_modelProposed naming scheme
cf2x_L250,cf21B_500, …).first_principles,so_rpy,so_rpy_rotor,so_rpy_rotor_drag), selected via theDynamicsenum.We avoid the use of
modelwhere possible because it is ambiguous.Package split
The vendored package is split by what the files are:
crazyflow/drones/— hardware descriptions: MJCF*.xml, meshes (assets/), and sharedparams.toml(mass, inertia, thrust/torque curves).available_dronesenumerates platforms.crazyflow/dynamics/— the dynamics themselves: one subpackage per fidelity level (each withdynamics.py+params.toml), pluscore.py(Dynamics,parametrize),symbols.py,transform.py, andutils/. Written backend-agnostic (Array API: NumPy/JAX/PyTorch) and CasADi-symbolic, so the dynamics stay usable standalone for estimation/control.available_dynamics/dynamics_featuresenumerate and introspect them.Other resulting changes
drone-modelsdependency and submodule and added package-data globs for the vendored XML/STL/TOML.crazyflow/sim/physics.py; dynamics selection now lives incrazyflow/dynamics.crazyflow/_typing.py(Array/ArrayLikeshim until array-api typing lands).physics→dynamics,drone_model→drone);docs/user-guide/physics-models.md→dynamics-models.md.Follow-up (separate PR)
to_xp(crazyflow/dynamics/utils/__init__.py) to the generalcrazyflow/utils.py. It's a generic Array-API helper, not dynamics-specific.crazyflow/dynamics/transform.py,crazyflow/dynamics/utils/rotation.py). Several are general-purpose and may belong in shared utils.drone-controllersPrevious state
Controllers lived in a separate
drone-controllerspackage, pulled in as a PyPI dependency and git submodule (submodules/drone-controllers,import drone_controllers).Package move
Vendored into
crazyflow/control/, mirroringcrazyflow/dynamics/:mellinger/subpackage (controller functions +params.toml),core.py(parametrize, param loaders),control.py(Controlenum),transform.py.Unification
Previously the controller functions, the sim data structs, and the controller-to-
SimDataadapters were split across packages. They now live together incrazyflow/control/mellinger/control.py, the same way each dynamics module co-locatesdynamics+Params+sim_dynamics.API changes
drone_modelparam renamed todrone(consistent with dynamics).load_paramssplit intoload_params(controller, drone)(raw, name-keyed loader) andload_fn_params(fn, drone)(per-function selection + signature filter).pos_err_i,r_int_error) instead of a genericctrl_errorstuple.control_<stage>and registered in the step pipeline under explicit role-based stage names (state_controller,attitude_controller,force_torque_controller,commit_attitude), so the pipeline is readable and the names are a stable insertion API.Other resulting changes
drone-controllersdependency and submodule.array-api-compatandarray-api-extraas direct dependencies (were transitive via the package).tests/unit/control/) and docs (docs/user-guide/control/).