Skip to content
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

Inconsistency between contact frame and its visualization #2335

Open
2 tasks done
jjyyxx opened this issue Jan 8, 2025 · 1 comment · May be fixed by #2348
Open
2 tasks done

Inconsistency between contact frame and its visualization #2335

jjyyxx opened this issue Jan 8, 2025 · 1 comment · May be fixed by #2348
Labels
bug Something isn't working

Comments

@jjyyxx
Copy link
Contributor

jjyyxx commented Jan 8, 2025

Intro

Hi!

I am a graduate student at HKU, I use MuJoCo for my research on robotic manipulation.

My setup

MuJoCo 3.2.6, Python and C, Linux

What's happening? What did you expect?

Mujoco is using the X axis as the contact normal direction in mjContact.frame, as explicitly stated in the documentation:

Thus, given that MuJoCo uses row-major format, the contact normal axis (which is the X axis of the contact frame by our convention) is in position mjContact.frame[0-2], the Y axis is in [3-5] and the Z axis is in [6-8]. The reason for this arrangement is because ...

However, when visualizing with mjFRAME_CONTACT, the normal direction becomes the Z axis in blue, as explicitly switched in

// mat = contact rotation matrix (normal along z)
mju_copy(tmp, con->frame+3, 6);
mju_copy(tmp+6, con->frame, 3);
mju_transpose(mat, tmp, 3, 3);

Both conventions are perfectly fine for me, but the inconsistency may create confusion during debugging, especially when dealing with anisotropic friction in the way recommended by documentation:

For a predefined contact pair we know the two geom types in advance, and the corresponding collision function always generates contact frames oriented in the same way – which we do not describe here but it can be seen in the visualizer.

Steps for reproduction

Minimal model for reproduction

No response

Code required for reproduction

No response

Confirmations

@jjyyxx jjyyxx added the bug Something isn't working label Jan 8, 2025
@yuvaltassa
Copy link
Collaborator

Ya, that's valid. Do you want to send a PR to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants