Skip to content

Commit fed0a73

Browse files
Address review findings from automated code review
- Fix randomize_rigid_body_com to pass partial data (env_ids subset) to set_coms_index, matching the pattern used by mass/inertia terms. - Remove dead _default_friction/_default_restitution writes in Newton material implementation (values were written but never read back). - Guard Newton collider offset notification to only fire when params are actually provided. - Fix changelog Sphinx roles for converted function-to-class items.
1 parent ecd79fa commit fed0a73

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

source/isaaclab/docs/CHANGELOG.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ Changed
1818
backend-specific implementations. PhysX uses bucket-based 3-tuple materials via the
1919
tensor API; Newton samples friction and restitution continuously per shape via
2020
view-level attribute bindings.
21-
* Converted :func:`~isaaclab.envs.mdp.randomize_rigid_body_com` from a plain function
22-
to a :class:`~isaaclab.managers.ManagerTermBase` class with repeatable randomization
21+
* Converted ``randomize_rigid_body_com`` from a plain function to a
22+
:class:`~isaaclab.managers.ManagerTermBase` class with repeatable randomization
2323
from cached defaults. Newton passes position-only (vec3); PhysX passes full pose
2424
(pos + quat).
25-
* Converted :func:`~isaaclab.envs.mdp.randomize_rigid_body_collider_offsets` from a
26-
plain function to a :class:`~isaaclab.managers.ManagerTermBase` class with
27-
backend-specific implementations. PhysX uses rest/contact offsets directly; Newton
28-
maps them to ``shape_margin`` and ``shape_gap``.
25+
* Converted ``randomize_rigid_body_collider_offsets`` from a plain function to a
26+
:class:`~isaaclab.managers.ManagerTermBase` class with backend-specific
27+
implementations. PhysX uses rest/contact offsets directly; Newton maps them to
28+
``shape_margin`` and ``shape_gap``.
2929

3030

3131
4.5.30 (2026-04-13)

source/isaaclab/isaaclab/envs/mdp/events.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ def __init__(
293293
self._friction_binding = asset._root_view.get_attribute("shape_material_mu", model)[:, 0] # type: ignore
294294
self._restitution_binding = asset._root_view.get_attribute("shape_material_restitution", model)[:, 0] # type: ignore
295295

296-
# cache defaults
297-
self._default_friction = wp.to_torch(self._friction_binding).clone()
298-
self._default_restitution = wp.to_torch(self._restitution_binding).clone()
299-
300296
def __call__(
301297
self,
302298
env: ManagerBasedEnv,
@@ -328,10 +324,6 @@ def __call__(
328324
restitution_range_t[0], restitution_range_t[1], (len(env_ids), num_shapes), device=device
329325
)
330326

331-
# update cached buffers for the affected env_ids
332-
self._default_friction[env_ids[:, None], shape_idx] = friction_samples
333-
self._default_restitution[env_ids[:, None], shape_idx] = restitution_samples
334-
335327
# write only the affected env_ids to the warp binding
336328
friction_view = wp.to_torch(self._friction_binding)
337329
restitution_view = wp.to_torch(self._restitution_binding)
@@ -750,10 +742,11 @@ def __call__(
750742
coms[env_ids[:, None], body_ids, :3] += rand_samples
751743

752744
# Newton expects position-only (vec3f), PhysX expects the full pose (pos + quat)
745+
# note: pass partial data of shape (len(env_ids), len(body_ids), ...) to match the API
753746
if self._is_newton:
754-
self.asset.set_coms_index(coms=coms[:, body_ids, :3], body_ids=body_ids, env_ids=env_ids)
747+
self.asset.set_coms_index(coms=coms[env_ids[:, None], body_ids, :3], body_ids=body_ids, env_ids=env_ids)
755748
else:
756-
self.asset.set_coms_index(coms=coms[:, body_ids], body_ids=body_ids, env_ids=env_ids)
749+
self.asset.set_coms_index(coms=coms[env_ids[:, None], body_ids], body_ids=body_ids, env_ids=env_ids)
757750

758751

759752
class _RandomizeRigidBodyColliderOffsetsPhysx:
@@ -880,7 +873,8 @@ def __call__(
880873
gap_view = wp.to_torch(self._sim_bind_shape_gap)
881874
gap_view[env_ids] = gap[env_ids]
882875

883-
self._newton_manager.add_model_change(self._notify_shape_properties)
876+
if rest_offset_distribution_params is not None or contact_offset_distribution_params is not None:
877+
self._newton_manager.add_model_change(self._notify_shape_properties)
884878

885879

886880
class randomize_rigid_body_collider_offsets(ManagerTermBase):

0 commit comments

Comments
 (0)