Skip to content

Capsule-box collision #135

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

camevor
Copy link
Collaborator

@camevor camevor commented Apr 9, 2025

Capsule-box collision based on mjc

includes / depends on #129 and resolves #77

camevor added 6 commits April 9, 2025 17:51
Originally, the capsule axis was at a 45 deg angle and intersected the
cube, with the symmetry being broken differently from mjc (contact with
same distance but different position & frame).
Copy link
Collaborator

@adenzler-nvidia adenzler-nvidia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 comment, but deferring the full review to someone who knows the ins-and-outs of the C implementation. @yuvaltassa probably?

Copy link
Collaborator

@adenzler-nvidia adenzler-nvidia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments. This it pretty tricky code, I'm not sure I can find issues here. But generally looks good, and if it follows MJC it should be fine.


secondpos *= wp.float32(mul)

# skip:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the skip comment refer to?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately: https://github.com/google-deepmind/mujoco/blob/main/src/engine/engine_collision_box.c#L425

This is my least favorite bit of C MuJoCo. I have promised @kbayes untold riches the day we delete these gotos.

Cursory scan of this code looks like @camevor has correctly undone the gotos - agree might be worth deleting this comment or otherwise adding # goto skip; comments elsewhere to situate this comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this in to provide an anchor when comparing against the mjc implementation, but I agree that it's confusing more than anything else. I'll do a cleanup pass over all the comments.

Copy link
Collaborator

@erikfrey erikfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM but let's add one or two more test fixtures to fully exercise this complex kernel.


secondpos *= wp.float32(mul)

# skip:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately: https://github.com/google-deepmind/mujoco/blob/main/src/engine/engine_collision_box.c#L425

This is my least favorite bit of C MuJoCo. I have promised @kbayes untold riches the day we delete these gotos.

Cursory scan of this code looks like @camevor has correctly undone the gotos - agree might be worth deleting this comment or otherwise adding # goto skip; comments elsewhere to situate this comment.

</worldbody>
</mujoco>
""",
"capsule_box_edge": """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capsule box is complicated! Is this also testing capsule on box corner? If not, let's add it. Generally speaking, please add a few more fixtures to fully exercise that kernel logic which is pretty complex.

Copy link
Collaborator Author

@camevor camevor Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! I added a two more fixtures (capsule on corner and capsule flat on face -> requires 2 contacts) and more strict contact checking in the test.

@camevor
Copy link
Collaborator Author

camevor commented Apr 24, 2025

Thanks for your reviews and comments! Added some more test fixtures and cleaned up the comments in the code.

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.

Capsule <> Box
3 participants