Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import isaaclab_ovphysx.tensor_types as TT
from isaaclab_ovphysx.physics import OvPhysxManager
from isaaclab_ovphysx.sim.views.ovphysx_view import OvPhysxView

from .contact_sensor_data import ContactSensorData
from .kernels import (
Expand Down Expand Up @@ -92,6 +93,9 @@ def __init__(self, cfg: ContactSensorCfg):
self._physx_instance: Any = None
self._contact_binding: Any = None
self._pose_binding: Any = None
# The pose binding (track_pose only) is managed by an OvPhysxView; the ContactBinding
# is a separate wheel API the view does not wrap.
self._root_view: OvPhysxView | None = None
# Pre-allocated read buffers, populated in _create_buffers.
self._net_forces_flat_buf: wp.array | None = None
self._force_matrix_flat_buf: wp.array | None = None
Expand Down Expand Up @@ -281,10 +285,8 @@ def has_contact_report(prim) -> bool:
"per body."
)
single_pose_pattern = f"{base_glob}/{body_names[0]}"
self._pose_binding = physx_instance.create_tensor_binding(
pattern=single_pose_pattern,
tensor_type=TT.RIGID_BODY_POSE,
)
self._root_view = OvPhysxView(physx_instance, pattern=single_pose_pattern, device=self._device)
self._pose_binding = self._root_view.binding_for(TT.RIGID_BODY_POSE)
if self._pose_binding.count != self._contact_binding.sensor_count:
raise RuntimeError(
"RIGID_BODY_POSE binding count mismatch."
Expand Down Expand Up @@ -378,7 +380,7 @@ def _update_buffers_impl(self, env_mask: wp.array | None = None) -> None:

if self.cfg.track_pose:
# Read pose into [num_envs * num_sensors, 7] float32 -> view as transformf.
self._pose_binding.read(self._poses_flat_buf)
self._root_view.read_into(TT.RIGID_BODY_POSE, self._poses_flat_buf)
poses_flat = self._poses_flat_buf.view(wp.transformf)
wp.launch(
split_flat_pose_to_pos_quat,
Expand Down Expand Up @@ -518,4 +520,7 @@ def _invalidate_initialize_callback(self, event) -> None:
with contextlib.suppress(Exception):
self._pose_binding.destroy()
self._pose_binding = None
# Drop the view too: it caches the same (now-destroyed) pose binding, so leaving it set
# would keep a destroyed handle reachable. _initialize_impl rebuilds a fresh view on play.
self._root_view = None
self._physx_instance = None
Loading