Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5676dd1
Add resolve_ids next to resolve_1d_mask as the shared id and mask hel…
hujc7 Oct 26, 2026
97e5662
Resolve sensor, camera and wrench composer selections through the sha…
hujc7 Oct 26, 2026
92590d0
Fix the deformable mask writers that raised on any env mask
hujc7 Oct 26, 2026
f044c92
Resolve Newton selections through the shared helpers and write its ma…
hujc7 Oct 26, 2026
7b48c38
Resolve OVPhysX selections through the shared helpers
hujc7 Oct 26, 2026
3d3661f
Resolve PhysX selections through the shared helpers
hujc7 Oct 26, 2026
b2c2d5d
Write the PhysX tendon mask setters through the masks
hujc7 Oct 26, 2026
43bb968
Merge remote-tracking branch 'upstream/main' into jichuanh/id-mask
hujc7 Oct 26, 2026
e390289
Trim duplicate id-resolution and mask-writer tests
hujc7 Oct 27, 2026
e3ba511
Merge the tendon target scheduling tests
hujc7 Oct 27, 2026
60581b8
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 27, 2026
e031e5e
Reject PhysX tendon masks whose length differs from the axis
hujc7 Oct 27, 2026
223f124
Accept strided torch limits in the PhysX tendon position limit mask s…
hujc7 Oct 27, 2026
10def58
Move the masked 2-D buffer writer to the core Warp kernels
hujc7 Oct 27, 2026
86be015
Compute the PhysX masked tendon target offset into a preallocated buffer
hujc7 Oct 27, 2026
13ec11c
Accept every id form main accepted in resolve_1d_mask
hujc7 Oct 27, 2026
784b0a2
Refresh the solver on every replay of the Newton tendon mask writer
hujc7 Oct 27, 2026
6a4f173
Tidy the mask writers, their docs and the selection tests
hujc7 Oct 27, 2026
bc9a8bb
Reject Newton masks whose length differs from the asset dimension
hujc7 Oct 27, 2026
981e3a4
Accept strided torch limits in the Newton tendon position limit mask …
hujc7 Oct 27, 2026
cff8f86
Run the tendon replay test before the module's shared scene opens
hujc7 Oct 27, 2026
bbb5104
Revert "Reject Newton masks whose length differs from the asset dimen…
hujc7 Oct 27, 2026
029ee47
Resolve the Newton collection writer masks inline again
hujc7 Oct 27, 2026
bba987b
Revert "Reject PhysX tendon masks whose length differs from the axis"
hujc7 Oct 27, 2026
551e508
Launch the rewritten Newton mask writers over the mask lengths
hujc7 Oct 27, 2026
cf2689b
Launch the PhysX tendon mask writers over the mask lengths
hujc7 Oct 27, 2026
86ce1c9
Write the rewritten Newton mask writers through a core masked write
hujc7 Oct 27, 2026
6dbeab5
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 27, 2026
a9336ff
Write the PhysX tendon mask setters through the core masked write
hujc7 Oct 27, 2026
b37d231
Merge upstream main 6ef40d19a6f into jichuanh/id-mask
hujc7 Oct 28, 2026
4df36b0
Merge jichuanh/id-mask (upstream main 6ef40d19a6f) into jichuanh/phys…
hujc7 Oct 28, 2026
dc2aba6
Align resolve_ids and write_2d_with_mask with the shared memory helpers
hujc7 Oct 29, 2026
1261924
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 29, 2026
cd86460
Resolve ids and masked writes without a device argument
hujc7 Oct 29, 2026
92a413e
Write strided vector components through scalar views instead of copyi…
hujc7 Oct 29, 2026
b75faf3
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 29, 2026
efee1b9
Update camera poses on reset through the resolved mask
hujc7 Oct 29, 2026
8af17a5
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 29, 2026
b7d5295
Merge remote-tracking branch 'upstream/main' into jichuanh/id-mask
hujc7 Oct 29, 2026
48ebd39
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Oct 29, 2026
90afb2f
Pass the tendon test masks as explicit keyword arguments
hujc7 Nov 2, 2026
c5299e5
Pass the short test mask as an explicit env_mask keyword
hujc7 Nov 2, 2026
5caa746
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Nov 2, 2026
3635089
Merge remote-tracking branch 'upstream/main' into jichuanh/id-mask
hujc7 Nov 2, 2026
12a29dc
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Nov 2, 2026
ddcd317
Merge remote-tracking branch 'upstream/main' into jichuanh/id-mask
hujc7 Nov 2, 2026
c3d1227
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Nov 2, 2026
12270ab
Describe the Newton collection and FK changes after the main merge
hujc7 Nov 2, 2026
c471391
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Nov 2, 2026
22b9aed
Merge main 299af193136 into jichuanh/id-mask
hujc7 Nov 9, 2026
c94a9f3
Restore main's FK launch size
hujc7 Nov 9, 2026
6afa0a2
Pass every selection form on and let each consumer pick its own
hujc7 Nov 9, 2026
47b5499
Describe resolve_ids' slice(None) all_ids in the changelog
hujc7 Nov 9, 2026
b75b5a8
Register tendon property writes as a model change as main does
hujc7 Nov 9, 2026
e4e5686
Merge jichuanh/id-mask into jichuanh/physx-tendon-mask-setters
hujc7 Nov 9, 2026
2a65a30
Merge main 2742c2d5e6b into jichuanh/id-mask
hujc7 Nov 10, 2026
16af6de
Merge jichuanh/id-mask into jichuanh/physx-tendon-mask-setters
hujc7 Nov 10, 2026
84470f4
Drop the invalidate_fk changelog line: its launch size is main's again
hujc7 Nov 10, 2026
2fbbcc5
Merge jichuanh/id-mask into jichuanh/physx-tendon-mask-setters
hujc7 Nov 10, 2026
11d840a
Reject masks longer than the destination and leave the slice(None) al…
hujc7 Nov 10, 2026
18a69ef
Merge branch 'jichuanh/id-mask' into jichuanh/physx-tendon-mask-setters
hujc7 Nov 10, 2026
f522b47
Merge main 616f517707d into jichuanh/id-mask
hujc7 Nov 12, 2026
e6e178c
Refresh the solver on every replay of a captured model-property write
hujc7 Nov 12, 2026
f5b7b18
Merge remote-tracking branch 'origin/jichuanh/id-mask' into jichuanh/…
hujc7 Nov 13, 2026
e943308
Merge remote-tracking branch 'upstream/main' into jichuanh/physx-tend…
hujc7 Nov 13, 2026
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
4 changes: 4 additions & 0 deletions source/isaaclab/changelog.d/jichuanh-id-mask.added.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Added :func:`~isaaclab.utils.warp.memory.resolve_ids`, which resolves an index selection given as ids or as a
boolean mask to ids on a device, as :func:`~isaaclab.utils.warp.memory.resolve_1d_mask` does to a mask.
* Added :func:`~isaaclab.utils.warp.memory.write_2d_with_mask`, which writes 2-D data or one scalar into a Warp array
where a row mask and a column mask are both true, launching over the mask lengths.
11 changes: 11 additions & 0 deletions source/isaaclab/changelog.d/jichuanh-id-mask.changed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* Changed the env selection helpers of :class:`~isaaclab.utils.wrench_composer.WrenchComposer` and
:class:`~isaaclab.sensors.Camera` to resolve ``env_ids`` and ``env_mask`` through
:func:`~isaaclab.utils.warp.memory.resolve_ids` and :func:`~isaaclab.utils.warp.memory.resolve_1d_mask`.
Any integer sequence and slices with a negative step are accepted, ids on another device are moved to the owner's
device, and a :class:`~isaaclab.utils.warp.ProxyArray` is rejected with a :class:`TypeError`. The
:class:`~isaaclab.sensors.Camera` now rejects floating-point ``env_ids`` with a :class:`TypeError` and
multi-dimensional ``env_ids`` with a :class:`ValueError` instead of casting and flattening them.
* Changed :class:`~isaaclab.utils.wrench_composer.WrenchComposer` to resolve ``body_ids`` through
:func:`~isaaclab.utils.warp.memory.resolve_ids` as well, so slices other than ``slice(None)`` are accepted.
* Changed :func:`~isaaclab.utils.warp.memory.resolve_1d_mask` to make ``scratch_mask`` optional for callers that never
pass ids. Their masks are returned as given. Ids without a ``scratch_mask`` raise a :class:`ValueError`.
4 changes: 4 additions & 0 deletions source/isaaclab/changelog.d/jichuanh-id-mask.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Fixed the ``write_nodal_*_to_sim_mask`` methods of :class:`~isaaclab.assets.BaseDeformableObject`, which the
OVPhysX deformable object inherits, raising a :class:`RuntimeError` whenever ``env_mask`` was given.
* Fixed :meth:`~isaaclab.sensors.Camera.reset` with an ``env_mask`` on another device than the camera: the camera
poses are now updated through the mask resolved on the camera's device, like the timestamps and buffers.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from ...utils import math as math_utils
from ...utils.warp import ProxyArray
from ...utils.warp.memory import resolve_ids
from ..asset_base import AssetBase

if TYPE_CHECKING:
Expand Down Expand Up @@ -200,6 +201,9 @@ def write_nodal_kinematic_target_to_sim_index(

"""
Operations - Write to simulation (mask variants).

These convert the mask to ids, which waits for the device, and call the index variants.
Backends with a mask write path override them.
"""

def write_nodal_state_to_sim_mask(
Expand All @@ -214,10 +218,7 @@ def write_nodal_state_to_sim_mask(
Shape is (num_instances, max_sim_vertices_per_body, 6).
env_mask: Environment mask. If None, then all indices are used.
"""
if env_mask is not None:
env_ids = wp.nonzero(env_mask)
else:
env_ids = self._ALL_INDICES
env_ids = resolve_ids(mask=env_mask, all_ids=self._ALL_INDICES)
self.write_nodal_state_to_sim_index(nodal_state, env_ids=env_ids, full_data=True)

def write_nodal_pos_to_sim_mask(
Expand All @@ -232,10 +233,7 @@ def write_nodal_pos_to_sim_mask(
Shape is (num_instances, max_sim_vertices_per_body, 3).
env_mask: Environment mask. If None, then all indices are used.
"""
if env_mask is not None:
env_ids = wp.nonzero(env_mask)
else:
env_ids = self._ALL_INDICES
env_ids = resolve_ids(mask=env_mask, all_ids=self._ALL_INDICES)
self.write_nodal_pos_to_sim_index(nodal_pos, env_ids=env_ids, full_data=True)

def write_nodal_velocity_to_sim_mask(
Expand All @@ -250,10 +248,7 @@ def write_nodal_velocity_to_sim_mask(
Shape is (num_instances, max_sim_vertices_per_body, 3).
env_mask: Environment mask. If None, then all indices are used.
"""
if env_mask is not None:
env_ids = wp.nonzero(env_mask)
else:
env_ids = self._ALL_INDICES
env_ids = resolve_ids(mask=env_mask, all_ids=self._ALL_INDICES)
self.write_nodal_velocity_to_sim_index(nodal_vel, env_ids=env_ids, full_data=True)

def write_nodal_kinematic_target_to_sim_mask(
Expand All @@ -268,10 +263,7 @@ def write_nodal_kinematic_target_to_sim_mask(
Shape is (num_instances, max_sim_vertices_per_body, 4).
env_mask: Environment mask. If None, then all indices are used.
"""
if env_mask is not None:
env_ids = wp.nonzero(env_mask)
else:
env_ids = self._ALL_INDICES
env_ids = resolve_ids(mask=env_mask, all_ids=self._ALL_INDICES)
self.write_nodal_kinematic_target_to_sim_index(targets, env_ids=env_ids, full_data=True)

"""
Expand Down
25 changes: 3 additions & 22 deletions source/isaaclab/isaaclab/sensors/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
quat_from_matrix,
)
from ...utils.warp import ProxyArray
from ...utils.warp.memory import resolve_1d_indices, resolve_ids
from ..sensor_base import SensorBase
from .camera_data import CameraData, RenderBufferKind

Expand Down Expand Up @@ -664,7 +665,7 @@ def reset(self, env_ids: Sequence[int] | slice | None = None, env_mask: wp.array
# reset the data
# note: this recomputation is useful if one performs events such as randomizations on the camera poses.
if env_mask is not None:
self._update_poses(env_mask=env_mask, frame_op=2)
self._update_poses(env_mask=reset_mask, frame_op=2)
elif env_ids is None:
self._update_poses(frame_op=2)
else:
Expand Down Expand Up @@ -1028,27 +1029,7 @@ def _resolve_env_ids_wp(self, env_ids: Sequence[int] | torch.Tensor | wp.array |
"""Resolve camera indices to a Warp ``int32`` array."""
if env_ids is None:
return None
if isinstance(env_ids, wp.array):
if env_ids.dtype != wp.int32:
raise TypeError(f"Unsupported wp.array dtype for env_ids: {env_ids.dtype}. Expected wp.int32.")
if env_ids.ndim != 1:
raise ValueError("Warp camera indices must be a one-dimensional array.")
if str(env_ids.device) == str(self._device):
return env_ids
return env_ids.to(self._device)
elif isinstance(env_ids, torch.Tensor):
env_ids = env_ids.to(device=self._device, dtype=torch.int32).reshape(-1)
if not env_ids.is_contiguous():
env_ids = env_ids.contiguous()
return wp.from_torch(env_ids, dtype=wp.int32)
elif isinstance(env_ids, slice) and (env_ids.step or 1) > 0:
return wp.from_torch(wp.to_torch(self._ALL_INDICES)[env_ids])
elif isinstance(env_ids, slice):
# Torch cannot slice with a negative step.
env_ids = np.arange(self._view.count, dtype=np.int32)[env_ids]
else:
env_ids = np.asarray(env_ids, dtype=np.int32).reshape(-1)
return wp.array(env_ids, dtype=wp.int32, device=self._device)
return resolve_1d_indices(resolve_ids(ids=env_ids, all_ids=self._ALL_INDICES))

def _env_mask_has_any(self, env_mask: wp.array) -> bool:
"""Return whether the mask selects any camera."""
Expand Down
115 changes: 107 additions & 8 deletions source/isaaclab/isaaclab/utils/warp/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import warp as wp

from .index_kernel import selector_dtype
from .proxy_array import ProxyArray

_CONCAT_TILE_SIZE = 32

Expand Down Expand Up @@ -290,6 +291,37 @@ def fill(
return fill


def write_2d_with_mask(
data: "float | torch.Tensor | wp.array",
row_mask: wp.array,
column_mask: wp.array,
out: wp.array,
) -> None:
"""Write ``data`` into ``out`` where both masks are true, launching over the mask lengths.

A mask shorter than ``out`` writes only the rows or columns it covers. Callers resolve the masks and check the
data shape.

Args:
data: Values of shape ``(row_mask.shape[0], column_mask.shape[0])`` in the dtype of ``out``, as a ``wp.array``
or a ``torch.Tensor`` with the dtype's trailing dimensions, or one scalar for every selected entry.
row_mask: Boolean mask over the first dimension of ``out``.
column_mask: Boolean mask over the second dimension of ``out``.
out: Output array. The launch runs on its device.
"""
dim = (row_mask.shape[0], column_mask.shape[0])
if isinstance(data, (int, float)):
kernel = make_masked_fill(out.dtype, 2)
elif isinstance(data, torch.Tensor) and data.ndim > 2 and data.stride(-1) != 1:
# a vector-typed argument needs packed components; copy strided ones through scalar views instead
scalar = out.dtype._wp_scalar_type_
kernel, dim = make_masked_copy(scalar, 3), (*dim, data.shape[-1])
data, out = wp.from_torch(data, dtype=scalar), out.view(scalar)
else:
kernel = make_masked_copy(out.dtype, 2)
wp.launch(kernel, dim=dim, inputs=[data, row_mask, column_mask], outputs=[out], device=out.device)


@cache
def _make_populate_mask(dtype) -> wp.Kernel:
@wp.kernel(module="unique")
Expand All @@ -316,7 +348,7 @@ def resolve_1d_mask(
ids: "Sequence[int] | slice | torch.Tensor | wp.array | None" = None,
mask: "wp.array | torch.Tensor | None" = None,
all_mask: wp.array,
scratch_mask: wp.array,
scratch_mask: wp.array | None = None,
) -> wp.array:
"""Resolve a selection using caller-owned boolean storage on its device.

Expand All @@ -331,19 +363,26 @@ def resolve_1d_mask(
preallocated device selectors avoid this synchronization.
Integer widths and strides are preserved. Masks must have the destination shape
and boolean dtype. The returned scratch storage is reused, so this is not reentrant.
Callers that never select by ids may omit ``scratch_mask``; their masks are then
returned as given, and the callers launch over the mask lengths.

Raises:
ValueError: If ids or a slice select a subset of elements and no ``scratch_mask`` is given.
"""
device = scratch_mask.device
if scratch_mask.ndim != 1 or scratch_mask.dtype != wp.bool:
raise ValueError("scratch_mask must be a rank-1 boolean Warp array")
if all_mask.shape != scratch_mask.shape or all_mask.dtype != wp.bool or all_mask.device != device:
raise ValueError("all_mask must match scratch_mask shape, dtype and device")
device = all_mask.device
if scratch_mask is not None:
if scratch_mask.ndim != 1 or scratch_mask.dtype != wp.bool:
raise ValueError("scratch_mask must be a rank-1 boolean Warp array")
if all_mask.shape != scratch_mask.shape or all_mask.dtype != wp.bool or all_mask.device != scratch_mask.device:
raise ValueError("all_mask must match scratch_mask shape, dtype and device")

temporary_input = False
selection = mask if mask is not None else ids
if selection is None or (isinstance(selection, slice) and selection == slice(None)):
return all_mask
if isinstance(selection, slice):
start, stop, step = selection.indices(scratch_mask.shape[0])
start, stop, step = selection.indices(all_mask.shape[0])
scratch_mask = _require_scratch_mask(scratch_mask)
scratch_mask.zero_()
count = len(range(start, stop, step))
if count:
Expand Down Expand Up @@ -381,11 +420,12 @@ def resolve_1d_mask(
if selection.ndim != 1:
raise ValueError("Selectors must be rank-1 arrays")
if mask is not None or selection.dtype == wp.bool:
if selection.dtype != wp.bool or selection.shape != scratch_mask.shape:
if selection.dtype != wp.bool or (scratch_mask is not None and selection.shape != scratch_mask.shape):
raise ValueError("Boolean masks must match the destination shape and dtype")
return selection
if selection.dtype not in (wp.int32, wp.int64):
raise TypeError("Index arrays must use signed int32 or int64 values")
scratch_mask = _require_scratch_mask(scratch_mask)
scratch_mask.zero_()
if selection.size:
wp.launch(
Expand All @@ -395,3 +435,62 @@ def resolve_1d_mask(
# Eager uploads must outlive scatter even on imported nonblocking CUDA streams.
wp.synchronize_stream(wp.get_stream(device))
return scratch_mask


def _require_scratch_mask(scratch_mask: wp.array | None) -> wp.array:
"""The scratch mask :func:`resolve_1d_mask` writes ids into."""
if scratch_mask is None:
raise ValueError("resolve_1d_mask needs a scratch_mask to write ids into.")
return scratch_mask


def resolve_ids(
*,
ids: "Sequence[int] | slice | torch.Tensor | wp.array | None" = None,
mask: "wp.array | torch.Tensor | None" = None,
all_ids: wp.array,
) -> "wp.array | torch.Tensor":
"""Resolve ids/mask into ids on the device of ``all_ids``. The mask takes precedence over the ids.

Pass the result to :func:`resolve_1d_indices` where contiguous int32 ids are needed.

Args:
ids: Index ids. Accepts ``Sequence[int]``, ``slice``, ``torch.Tensor``, ``wp.array``,
or ``None`` (all elements). Tensors and warp arrays keep their integer dtype.
mask: Boolean mask. Its ids are found with :func:`torch.nonzero`, which waits for
the device.
all_ids: Pre-allocated ids of every element, returned as-is when *ids* and *mask*
select every element.

Returns:
``all_ids``, a ``torch.Tensor`` or a ``wp.array`` of ids on the device of ``all_ids``.
A mask resolves to an int64 ``torch.Tensor``; lists and slices resolve to ``wp.int32``.

Raises:
TypeError: If *ids* is a :class:`ProxyArray`, which is output-only, or *mask* is
neither a ``wp.array`` nor a ``torch.Tensor``.
"""
device = all_ids.device
if mask is not None:
if isinstance(mask, wp.array):
mask = wp.to_torch(mask)
elif not isinstance(mask, torch.Tensor):
raise TypeError(f"Unsupported mask type: {type(mask)}")
return torch.nonzero(mask.to(wp.device_to_torch(device))).squeeze(-1)
if isinstance(ids, torch.Tensor):
return ids if str(ids.device) == str(device) else ids.to(wp.device_to_torch(device))
if ids is None:
return all_ids
if isinstance(ids, wp.array):
return ids if ids.device == device else ids.to(device)
if isinstance(ids, ProxyArray):
raise TypeError("ProxyArray is output-only; pass .warp or .torch explicitly.")
if isinstance(ids, slice):
if ids == slice(None):
return all_ids
start, stop, step = ids.indices(all_ids.shape[0])
if step > 0:
# a strided view of the caller's all-ids, no copy
return wp.from_torch(wp.to_torch(all_ids)[start:stop:step])
return wp.array(list(range(start, stop, step)), dtype=wp.int32, device=device)
return wp.array(list(ids), dtype=wp.int32, device=device)
38 changes: 5 additions & 33 deletions source/isaaclab/isaaclab/utils/wrench_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from .warp import ProxyArray
from .warp.index_kernel import selector_dtype
from .warp.memory import resolve_ids
from .warp.wrench import (
add_raw_wrench_buffers,
compose_wrench_to_body_frame,
Expand Down Expand Up @@ -672,24 +673,9 @@ def _resolve_env_ids(self, env_ids: wp.array | torch.Tensor | list | slice | Non
Environment indices.

Raises:
TypeError: If ``env_ids`` is an unsupported type.
TypeError: If ``env_ids`` is a :class:`~isaaclab.utils.warp.ProxyArray`.
"""
if env_ids is None:
return self._ALL_ENV_INDICES
# Check tensor types before slice comparison (tensor == slice crashes)
if isinstance(env_ids, torch.Tensor):
return env_ids
if isinstance(env_ids, wp.array):
return env_ids
if env_ids == slice(None):
return self._ALL_ENV_INDICES
if isinstance(env_ids, slice):
return wp.from_torch(wp.to_torch(self._ALL_ENV_INDICES)[env_ids])
if isinstance(env_ids, list):
return wp.array(env_ids, dtype=wp.int32, device=self.device)
raise TypeError(
f"env_ids must be None, slice(None), list, torch.Tensor, or wp.array, got {type(env_ids).__name__}"
)
return resolve_ids(ids=env_ids, all_ids=self._ALL_ENV_INDICES)

def _resolve_body_ids(
self, body_ids: Sequence[int] | torch.Tensor | wp.array | slice | None
Expand All @@ -703,23 +689,9 @@ def _resolve_body_ids(
Body indices.

Raises:
TypeError: If ``body_ids`` is an unsupported type.
TypeError: If ``body_ids`` is a :class:`~isaaclab.utils.warp.ProxyArray`.
"""
if body_ids is None:
return self._ALL_BODY_INDICES
if isinstance(body_ids, ProxyArray):
raise TypeError("ProxyArray is output-only; pass .warp or .torch explicitly.")
if isinstance(body_ids, torch.Tensor):
return body_ids
if isinstance(body_ids, wp.array):
return body_ids
if body_ids == slice(None):
return self._ALL_BODY_INDICES
if isinstance(body_ids, Sequence):
return wp.array(body_ids, dtype=wp.int32, device=self.device)
raise TypeError(
f"body_ids must be None, slice(None), a sequence, torch.Tensor, or wp.array, got {type(body_ids).__name__}"
)
return resolve_ids(ids=body_ids, all_ids=self._ALL_BODY_INDICES)

def _ensure_composed(self):
"""Compose input buffers into output buffers if dirty."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def _physx_articulation(N, J, B, FT, ST, device, is_fixed_base, joint_ordering,
articulation._ALL_JOINT_INDICES = indices(J, device)
articulation._ALL_FIXED_TENDON_INDICES = indices(FT, device)
articulation._ALL_SPATIAL_TENDON_INDICES = indices(ST, device)
articulation._ALL_ENV_MASK = wp.ones(N, dtype=wp.bool, device=device)
articulation._ALL_FIXED_TENDON_MASK = wp.ones(FT, dtype=wp.bool, device=device)
articulation._ALL_SPATIAL_TENDON_MASK = wp.ones(ST, dtype=wp.bool, device=device)
for name in ("joint_pos_target", "joint_vel_target", "joint_effort_target", "body_wrench_force"):
setattr(articulation, f"_{name}_backend", None)
articulation._body_wrench_torque_backend = None
Expand Down Expand Up @@ -237,6 +240,7 @@ def _newton_articulation(N, J, B, FT, ST, device, is_fixed_base, joint_ordering,
articulation._ALL_BODY_INDICES = indices(B, device)
articulation._ALL_JOINT_INDICES = indices(J, device)
articulation._ALL_ENV_MASK = wp.ones((N,), dtype=wp.bool, device=device)
articulation._scratch_env_mask = wp.zeros((N,), dtype=wp.bool, device=device)
articulation._ALL_BODY_MASK = wp.ones((B,), dtype=wp.bool, device=device)
articulation._ALL_JOINT_MASK = wp.ones((J,), dtype=wp.bool, device=device)
articulation._resolve_and_install_ordering_maps()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def _newton_collection(num_instances: int, num_bodies: int, device: str, monkeyp
collection._ALL_BODY_INDICES = indices(num_bodies, device)
collection._ALL_ENV_MASK = wp.ones((num_instances,), dtype=wp.bool, device=device)
collection._ALL_BODY_MASK = wp.ones((num_bodies,), dtype=wp.bool, device=device)
collection._scratch_body_mask = wp.zeros((num_bodies,), dtype=wp.bool, device=device)
return collection, view


Expand Down
Loading
Loading