Fix set_to_muscle() to accept tuple arguments for timeconst and range#3283
Open
anishesg wants to merge 2 commits into
Open
Fix set_to_muscle() to accept tuple arguments for timeconst and range#3283anishesg wants to merge 2 commits into
anishesg wants to merge 2 commits into
Conversation
The `set_to_muscle()` method in the Python bindings incorrectly declared `timeconst` and `range` parameters as C-style array pointers (`double timeconst[2]`), which prevented Python callers from passing tuples or lists as intended for musculoskeletal modeling. The underlying C function expects 2-element arrays representing min/max pairs, but the pybind11 binding only accepted scalar values. Signed-off-by: anish <anishesg@users.noreply.github.com>
Balint-H
reviewed
May 28, 2026
| self.assertEqual(actuator.gainprm[5], 1.6) | ||
| self.assertEqual(actuator.gainprm[6], 1.5) | ||
| self.assertEqual(actuator.gainprm[7], 1.3) | ||
| self.assertEqual(actuator.gainprm[8], 1.2) |
Collaborator
There was a problem hiding this comment.
Should probably also test biasprm while we are at it
Signed-off-by: anish <anishesg@users.noreply.github.com>
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.
The
set_to_muscle()method in the Python bindings incorrectly declaredtimeconstandrangeparameters as C-style array pointers (double timeconst[2]), which prevented Python callers from passing tuples or lists as intended for musculoskeletal modeling. The underlying C function expects 2-element arrays representing min/max pairs, but the pybind11 binding only accepted scalar values.Changed the lambda signature in
python/mujoco/specs.ccto usestd::array<double, 2>for bothtimeconstandrangeparameters, matching the pattern used inset_to_dcmotor(). Updated the default argument fortimeconstfrom a scalar-1tostd::array<double, 2>{-1, -1}for consistency. The arrays are correctly unpacked using.data()when calling the underlyingmjs_setToMuscle()C function.Added a test in
specs_test.pythat verifies tuple arguments are properly mapped to thedynprmandgainprmarrays, and that muscle actuator types are set correctly.Fixes #3282