Skip to content

Arbitrary motor count - #114

Open
Lagnesh2003 wants to merge 4 commits into
learnsyslab:mainfrom
Lagnesh2003:arbitrary-motor-count
Open

Lagnesh2003 wants to merge 4 commits into
learnsyslab:mainfrom
Lagnesh2003:arbitrary-motor-count

Conversation

@Lagnesh2003

Copy link
Copy Markdown

Derive motor count from mixing_matrix.shape[-1] instead of hardcoding 4, so the simulator is more generalized.

Changes

  • SimState, SimStateDeriv, SimControls (crazyflow/sim/data.py): rotor buffers (rotor_vel, rotor_acc) are now sized by n_motors.
  • Sim.init_data and rotor_vel_limits (crazyflow/sim/sim.py): n_motors is derived from mixing_matrix.shape[-1] and threaded through; thrust limits scale with n_motors instead of 4 *.
  • rotor_vel_control (crazyflow/sim/functional.py): the per-motor shape assertion now reads the motor count off data.states.rotor_vel instead of asserting a fixed 4.
  • action_space (crazyflow/envs/drone_env.py): attitude-mode thrust bounds now scale with n_motors instead of * 4.
  • Mellinger controller (crazyflow/control/mellinger/control.py): force_torque2rotor_vel and _attitude2force_torque divide by mixing_matrix.shape[-1] instead of 4; state2attitude now takes mixing_matrix as a keyword-only parameter (auto-bound via load_params/parametrize) instead of hardcoding * 4.
  • Added tests/unit/test_arbitrary_motor_count.py: 6 regression tests exercising every changed function directly with a synthetic 6-motor mixing_matrix/SimData, without registering a full hexacopter drone. Verified each test fails against the pre-fix code and passes against the fix.

Fixes #104

Test plan

  • pytest -v tests — 656 passed (650 existing + 6 new)
  • pytest --markdown-docs ... (doctests/docs examples) — 101 passed
  • ruff check crazyflow/ tests/ — clean
  • New regression tests confirmed to fail on pre-fix code, pass on fixed code

Lagnesh2003 added 4 commits September 15, 2026 07:41
Derive motor count from mixing_matrix.shape[-1] instead of hardcoding 4
in SimState/SimStateDeriv/SimControls buffers, rotor_vel_limits, and the
Mellinger power-distribution stages.
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.

Support multicopters with arbitrary motor counts

1 participant