Arbitrary motor count - #114
Open
Lagnesh2003 wants to merge 4 commits into
Open
Lagnesh2003 wants to merge 4 commits into
Lagnesh2003 wants to merge 4 commits into
Conversation
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.
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.
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 byn_motors.Sim.init_dataandrotor_vel_limits(crazyflow/sim/sim.py):n_motorsis derived frommixing_matrix.shape[-1]and threaded through; thrust limits scale withn_motorsinstead of4 *.rotor_vel_control(crazyflow/sim/functional.py): the per-motor shape assertion now reads the motor count offdata.states.rotor_velinstead of asserting a fixed 4.action_space(crazyflow/envs/drone_env.py): attitude-mode thrust bounds now scale withn_motorsinstead of* 4.crazyflow/control/mellinger/control.py):force_torque2rotor_veland_attitude2force_torquedivide bymixing_matrix.shape[-1]instead of4;state2attitudenow takesmixing_matrixas a keyword-only parameter (auto-bound viaload_params/parametrize) instead of hardcoding* 4.tests/unit/test_arbitrary_motor_count.py: 6 regression tests exercising every changed function directly with a synthetic 6-motormixing_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 passedruff check crazyflow/ tests/— clean