-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parsing mujoco equality connect constraints: default vs zero configuration #22462
Comments
having thought about it a bit today, I think a reasonable way forward would be to add one more optional argument to the |
My first idea was a plant-wide option that set's the "default" configuration mode, but I think per-constraint is a better idea. I still find the MuJoCo doc a bit confusing as written. Did you happen to find a section that would lead a user to the correct conclusion that "in the configuration in which the model is defined." means the zero configuration? I would assume that since the |
Hmm, also does it use the zero configuration when 0 is outside of the limits of a joint? I can't seem to find this information in the docs. |
WIP branch is here fyi: https://github.com/joemasterjohn/drake/tree/constraint_default_state_mode |
I agree that the docs are lacking on both points. The cassie model has been my verification. In that example, both the zero configuration and the default (because it's often zero) are actually outside of some joint limits. But using that zero position (no clamping to the limits) is the only way to make the linkage closed by obvious visual inspection. |
If it's feasible to either read (in code) or explore (with experiments) what Mujoco is actually doing, an ideal next step would be to open a pull request again their docs with a precise specification, which then we could check that both implementation adhere to. I seem to recall that @sherm1 did that for SDFormat specs many years back. Building multibody parsers around a solid, unambiguous specification is really the best option when feasible. Cross-checking with robot species is also helpful, but will be more brittle. |
Ok, I've spent more time with the mujoco docs. The match between MuJoCo concepts and Drake concepts is actually pretty clean, but the naming choices are a bit unfortunate: MuJoCo has three concepts:
Drake has three concepts:
Roughly speaking
My only nagging concern is just how strange the cassie model in the menagerie is. It defines joint limits that do not contain zero, so My current proposal:
fyi @yuvaltassa @kevinzakka . BTW -- I resolved the other texture/material issues with the cassie parsing, so all of the menagerie models now look a lot better in meshcat, cassie included: |
Please excuse the unclear documentation (now updated), |
Thanks @yuvaltassa. But I'm surprised. For the cassie model when I use the ref position to compute the equality connect constraints, the loop is visibly not closed. I thought that the ref position => qpos0, but that could not be the position in which the constraint kinematics were evaluated? |
I'm not sure what you mean. When I load the Cassie and turn on constraint visualisation (red and blue spheres at the two anchor points), the loop is clearly closed at qpos0 and remains that way. Cassie.mp4 |
Thanks @yuvaltassa . I appreciate it. My qpos0 (default position) , with an almost identical gui, looks like this: Apart from my default values being projected onto the joint limits (which only effects the lower leg), the values match. The knee position in your qpos0 corresponds to a left-knee of zero in my parser. I guess it's on me. I'll keep digging. |
thanks. it was when i added parsing support for ref that things went sideways (that was the discussion above). something else is wrong. |
When i take that same model (with the refs in the right light commented out) into mujoco, I get and it's not until I run that I see something different happening in the right leg:So the |
I think I see my error. The text description in https://mujoco.readthedocs.io/en/stable/overview.html#joint-reference says that setting "ref=-45" means that the configuration in the model file should be interpreted as having a joint angle of -45. I implemented it as the model in the mjcf is 0, but you should start instead at 45. That's not a great mapping to how we do things in Drake, but I think I can fix it. Sorry for being slow. |
Looks like you figured it out. As always, if you there is any way we can improve the MJCF reference in a way that would avoid future confusion, please let us know 🤓 |
Resolves RobotLocomotion#22462 (and the extensive discussion therein). MuJoCo's ref doesn't change the posture of the model, it says that the posture in the mjcf should be treated not as zero, but as ref.
I've got the fix coming. The default configuration is nicely resolved now. Thanks! One thing that is still different for me: the default positions of the foot-cranks are outside of the joint limits: |
Nice catch!
|
I'll admit, it's been a while since I've worked on Cassie, so the details are escaping me. I suspect that this isn't an error, it's just that when we exported the models there wasn't a particular effort spent making sure that the zero position was physically meaningful. The MuJoCo model was also created a bit after I moved on from working on Cassie, so I'm not sure if my experience is exactly relevant here. For example, when we zeroed the hardware, the pose was with the toes pointed down, where it looks above like the zero position has the toes pointed up. I can ask around to see if anyone can give any more clarity if you think it would be helpful |
Thanks @danielbennettagility . The model can work as it is, but I do think it would be more elegant to resolve this. Drake's solver takes constraints seriously with the default parameters, so if I drop the model in as-is, depending on which workflow we're using, that inconsistency will either be resolved with a nonlinear optimization or by a large constraint force at time zero. A small fix to that file would allow the developers to choose how it's resolved rather than relying on the solvers. It's not a blocker for me. I just called it out when I saw it (and I wanted to make sure that it wasn't coming from a mistake in Drake's parser!) |
What happened?
After testing more mujoco models with loop joints, it seems that #22446 actually made some of them worse. (even though I think that PR is implemented correctly)
The problem is, perhaps, a bit fundamental. To help parse mujoco constraints, we changed AddBallConstraint to allow
note the default configuration there.
In mujoco, the equality connect doc says
that's equivalent to our "zero" configuration, not our default configuration.
This breaks the cassie model in the mujoco menagerie.
Possible solutions:
@joemasterjohn and others -- wdyt?
Version
No response
What operating system are you using?
No response
What installation option are you using?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: