Skip to content

Conversation

@YilingQiao
Copy link
Collaborator

@YilingQiao YilingQiao commented Jan 8, 2026

Adds support for attaching MPM particles to rigid links using soft constraints, similar to the existing FEM vertex constraint system.

mpm_attachment.mp4

Changes

genesis/options/solvers.py

  • Add enable_particle_constraints option to MPMOptions (default: False)

genesis/engine/solvers/mpm_solver.py

  • Add particle_constraint_info struct for constraint data
  • Add init_constraints() for lazy field initialization
  • Add _kernel_set_particle_constraints() and _kernel_remove_particle_constraints() kernels
  • Add apply_particle_constraints() kernel with ti.static branching for zero overhead when disabled
  • Call constraint kernel in substep_post_coupling() after G2P

genesis/engine/entities/mpm_entity.py

  • Add get_particles_in_bbox() helper to find particles in a region
  • Add set_particle_constraints() to attach particles to a rigid link
  • Add remove_particle_constraints() to detach particles

Usage

scene = gs.Scene(
    mpm_options=gs.options.MPMOptions(
        enable_particle_constraints=True,
        ...
    )
)

# Find particles in attachment region
particles = mpm_entity.get_particles_in_bbox(bbox_min, bbox_max)

# Attach to rigid link with spring stiffness
mpm_entity.set_particle_constraints(particles, link=robot.links[0], stiffness=1e5)

Tests

  • tests/test_mpm.py: Unit tests for constraint API and behavior

Example

  • examples/coupling/rigid_mpm_attachment.py: Demo of MPM cube attached to oscillating rigid box

Screenshots (if appropriate):

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@YilingQiao YilingQiao marked this pull request as ready for review January 9, 2026 07:19
@YilingQiao YilingQiao requested a review from duburcqa as a code owner January 9, 2026 07:19
Comment on lines +249 to +225
@pytest.mark.required
def test_mpm_particle_constraints(show_viewer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should flag this test as slow if it is (>200s). Beware that it means that it will only run on production CI, so only do this if necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's not slow on my machine, but I'm happy to add the tag to make our generic CI not too slow

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's not slow on my machine, but I'm happy to add the tag to make our generic CI not too slow

The speed must be benched on the generic CI runners. Not your machine. So you need to run the entire CI pipeline without "slow" mark at least once, otherwise you will never know since it will be skipped.

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

⚠️ Abnormal Benchmark Result Detected ➡️ Report

@YilingQiao
Copy link
Collaborator Author

Comments are addressed

duburcqa
duburcqa previously approved these changes Jan 10, 2026
@duburcqa duburcqa changed the title [FEATURE] MPM rigid attachment [FEATURE] Adds support for attaching MPM particles to rigid links. Jan 10, 2026
@duburcqa
Copy link
Collaborator

Note that you are still not using zero-copy but I will let that slip in I don't think it is a bottleneck.

YilingQiao and others added 8 commits January 10, 2026 09:01
Removed slow marker from test_mpm_particle_constraints.
Updated particle constraint size check to include a multiplier for dimensions and improved error message.
Refactor particles_mask handling for constraint removal.
@duburcqa duburcqa force-pushed the yiling/260107_mpm_attachment branch from 3686057 to 858d511 Compare January 10, 2026 08:01
@duburcqa duburcqa merged commit 71b4f23 into Genesis-Embodied-AI:main Jan 10, 2026
19 of 22 checks passed
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.

2 participants