Skip to content

Commit 268b94f

Browse files
committed
address comment
1 parent 8473020 commit 268b94f

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

source/isaaclab_newton/docs/CHANGELOG.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ Added
1010
* Added ``set_friction_index/mask`` and ``set_restitution_index/mask`` methods to
1111
Newton assets for native material property randomization.
1212

13-
Changed
14-
^^^^^^^
15-
16-
* Removed ``shape_material_mu`` and ``shape_material_restitution`` data properties.
17-
* Removed hardcoded ``default_body_armature`` from Newton cloner. Use
18-
:class:`~isaaclab.envs.mdp.randomize_rigid_body_inertia` event term instead.
19-
2013

2114
0.5.10 (2026-04-05)
2215
~~~~~~~~~~~~~~~~~~~

source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,10 +3909,10 @@ def _resolve_shape_ids(self, shape_ids: Sequence[int] | torch.Tensor | wp.array
39093909
Returns:
39103910
A warp array of shape indices or a tensor of shape indices.
39113911
"""
3912-
if isinstance(shape_ids, list):
3913-
return wp.array(shape_ids, dtype=wp.int32, device=self.device)
39143912
if (shape_ids is None) or (shape_ids == slice(None)):
39153913
return self._ALL_SHAPE_INDICES
3914+
elif isinstance(shape_ids, list):
3915+
return wp.array(shape_ids, dtype=wp.int32, device=self.device)
39163916
return shape_ids
39173917

39183918
def _resolve_fixed_tendon_ids(

source/isaaclab_physx/test/assets/test_rigid_object.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,44 @@ def test_rigid_body_set_material_properties(num_cubes, device):
604604
torch.testing.assert_close(materials_to_check.reshape(num_cubes, 3), materials)
605605

606606

607+
@pytest.mark.parametrize("num_cubes", [1, 2])
608+
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
609+
@pytest.mark.isaacsim_ci
610+
def test_set_material_properties_index(num_cubes, device):
611+
"""Test setting material properties using the set_material_properties_index API."""
612+
with build_simulation_context(
613+
device=device, gravity_enabled=True, add_ground_plane=True, auto_add_lighting=True
614+
) as sim:
615+
sim._app_control_on_stop_handle = None
616+
# Generate cubes scene
617+
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device)
618+
619+
# Play sim
620+
sim.reset()
621+
622+
# Get number of shapes
623+
max_shapes = cube_object.root_view.max_shapes
624+
625+
# Generate random material properties: (static_friction, dynamic_friction, restitution)
626+
materials = torch.empty(num_cubes, max_shapes, 3, device="cpu").uniform_(0.0, 1.0)
627+
# Ensure dynamic friction <= static friction
628+
materials[..., 1] = torch.min(materials[..., 0], materials[..., 1])
629+
630+
# Use the new set_material_properties_index API
631+
env_ids = torch.arange(num_cubes, dtype=torch.int32)
632+
cube_object.set_material_properties_index(materials=materials, env_ids=env_ids)
633+
634+
# Simulate physics
635+
sim.step()
636+
cube_object.update(sim.cfg.dt)
637+
638+
# Get material properties from simulation
639+
materials_check = wp.to_torch(cube_object.root_view.get_material_properties())
640+
641+
# Check if material properties are set correctly
642+
torch.testing.assert_close(materials_check, materials)
643+
644+
607645
@pytest.mark.parametrize("num_cubes", [1, 2])
608646
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
609647
@pytest.mark.isaacsim_ci

0 commit comments

Comments
 (0)