Skip to content

[Bug]: MeshSet particle sampling ignores member rotations #3169

Description

@prexhu

Bug Description

Particles sampled for gs.morphs.MeshSet do not receive the rotation specified by each member's eulers. Only the translation in poss is applied.

The visual mesh receives the complete rotation and translation, causing the rendered mesh and its physical particles to have different orientations. This also affects Hybrid entities generated from URDF links: particles belonging to rotated links remain aligned with the original local axes.

Steps to Reproduce

import numpy as np
import trimesh

import genesis as gs


gs.init(backend=gs.cpu)

pos = np.array((0.2, 0.1, 0.2))
mesh = trimesh.creation.box(extents=(0.04, 0.12, 0.04))

scene = gs.Scene(
    mpm_options=gs.options.MPMOptions(
        lower_bound=(-0.5, -0.5, -0.5),
        upper_bound=(0.5, 0.5, 0.5),
        particle_size=0.01,
    ),
    show_viewer=False,
)

entity = scene.add_entity(
    morph=gs.morphs.MeshSet(
        files=(mesh,),
        poss=(pos,),
        eulers=((0.0, 0.0, 90.0),),
    ),
    material=gs.materials.MPM.Elastic(sampler="regular"),
)

particle_extents = np.ptp(entity.init_particles, axis=0)
print("Particle extents:", particle_extents)

np.testing.assert_allclose(
    particle_extents,
    (0.11, 0.03, 0.03),
    atol=1e-6,
)

Expected Behavior

The 90-degree rotation around the Z axis should rotate the box's long axis from Y to X. The particle extents should therefore be approximately: [0.11, 0.03, 0.03]

The physical particles and visual mesh should have the same orientation.

Screenshots/Videos

I have also written a URDF file to test the particle rotation.

Error: Particle rotation.

Image

Which should be like:

Image

Environment

  • OS: Ubuntu 22.04.5 LTS, x86_64
  • CPU: AMD Ryzen 9 9950X 16-Core Processor
  • GPU-driver version: N/A
  • CUDA / CUDA-toolkit version: N/A

Release version or Commit ID

genesis-world 1.3.1
e4e8013

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions