Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the project to use drone-controllers==0.2.0 and adapts Crazyflow’s Mellinger control integration, simulation pipeline calls, and tests to the updated controller APIs/parameter-loading approach.
Changes:
- Bump
drone-controllersdependency to0.2.0and refresh the Pixi lockfile accordingly. - Update Mellinger controller wiring to load controller params via
drone_controllers.core.load_paramsand pass params as dictionaries. - Adjust simulation/controller call sites and tests to match the updated controller function signatures, and add a fused-model smoke test.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_sim.py | Adds dict handling in commit-check helper and introduces a fused model smoke test. |
| tests/integration/test_interfaces.py | Updates state2attitude invocation to the new signature in the attitude interface test. |
| pyproject.toml | Bumps drone-controllers to 0.2.0. |
| pixi.lock | Lockfile refresh reflecting updated dependency graph (incl. drone-controllers 0.2.0). |
| crazyflow/utils.py | Removes named_tuple2device helper now superseded by controller param loading. |
| crazyflow/sim/sim.py | Updates controller step functions to pass updated inputs and unpack dict params. |
| crazyflow/envs/drone_env.py | Updates attitude action space bounds to use load_params(...) and dict keys. |
| crazyflow/control/mellinger.py | Switches controller param storage/loading to load_params(...) with dict-based params. |
Comments suppressed due to low confidence (1)
tests/integration/test_interfaces.py:54
- These integration tests create
Sim(...)instances but never callsim.close(). This can leave MuJoCo/JAX resources alive across tests and cause interference/flakiness. Consider addingsim.close()in afinallyblock (or using a fixture) to ensure cleanup even if assertions fail.
def test_attitude_interface(physics: Physics):
sim = Sim(physics=physics, control=Control.attitude)
target_pos = np.array([0.0, 0.0, 1.0])
jit_state2attitude = jax.jit(parametrize(state2attitude, drone_model="cf2x_L250"))
i_error = np.zeros((1, 1, 3))
cmd = np.zeros((1, 1, 13))
cmd[0, 0, 2] = 1.0 # Set z position target to 1.0
for _ in range(int(2 * sim.control_freq)): # Run simulation for 2 seconds
pos, vel, quat = sim.data.states.pos, sim.data.states.vel, sim.data.states.quat
rpyt, i_error = jit_state2attitude(pos, quat, vel, cmd, (i_error,), ctrl_freq=100)
sim.attitude_control(rpyt)
sim.step(sim.freq // sim.control_freq)
# Check if drone maintained hover position
dpos = sim.data.states.pos[0, 0] - target_pos
distance = np.linalg.norm(dpos)
assert distance < 0.05, f"Failed to maintain hover with {physics} ({dpos})"
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.
No description provided.