Skip to content

[Core] Refactor and cleanup core subpackage for 3.0 [13/N] - #8095

Merged
StafaH merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/13-assets-sensors-misc
Sep 28, 2026
Merged

StafaH merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/13-assets-sensors-misc

Conversation

@StafaH

@StafaH StafaH commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part 13 of the split of #7949. It cleans up the asset and sensor base classes, the ray casters and camera, and a few device, marker, UI, and visualizer helpers. It changes no public API. The deprecation-warning refactor from #7949 is not included.

  • Asset / sensor base:
    • AssetBase and SensorBase now clear their debug-vis callback through one _clear_debug_vis_handle() helper. It replaces three copies of the same code in each class.
    • AssetBase.num_instances and AssetBase.data now raise NotImplementedError instead of returning it.
    • Removed the pass-through __init__ methods from the base cable, deformable, rigid object, frame transformer, IMU, joint wrench, and PVA classes.
    • Removed the no-op _invalidate_initialize_callback overrides from the contact sensor and frame transformer bases. This drops the stale TODO in the contact sensor override.
  • Camera: positions, orientations, eyes, and targets now go through one _as_device_tensor() helper. env_ids handling is unchanged.
  • Ray casters:
    • The multi-mesh ray caster finds the rigid-body ancestor with sim_utils.get_first_matching_ancestor_prim.
    • Inlined single-use kernel-argument locals.
    • Simplified the debug-vis code.
    • Removed an unreachable "No meshes found" check. The loop already raises for an invalid path, and only one mesh path is allowed.
    • Fixed the frame return annotation (torch.Tensor).
  • Devices:
    • Fixed the gamepad and keyboard __init__ docstrings, which listed parameters that don't exist.
    • Simplified the Haply force clipping.
  • Markers / UI / visualizers:
    • Device moves are done in one expression.
    • Added a _has_implementation helper and fixed docstrings and a typo.
    • The env-camera regex is precompiled.
    • Simplified how the live-plot source list is built.
  • isaaclab/__init__.py: pip_prebundle is folded into the fragment tuple, and one partition helper is shared by sys.path and PYTHONPATH.

Small behavior notes:

  • SensorBase.__init__ now sets its callback and debug-vis handles to None before anything that can fail, so __del__ no longer raises AttributeError when construction fails early (e.g. in validate(cfg)).
  • Se2SpaceMouse sets _thread = None first and __del__ joins it only when it was started, so a failed construction (e.g. no device found) no longer raises in __del__.
  • The Haply WebSocket receive-loop error is reported with logger.error instead of print.

Type of change

  • Refactor, plus small teardown robustness fixes (see the behavior notes)

Verification

  • Equivalence scripts comparing develop and this branch, with seeded random inputs:
    • Prebundle path demotion (2000 sys.path / PYTHONPATH cases): identical.
    • Haply force selection and clipping (1000 cases, CPU and CUDA): identical.
    • Camera array-like conversion (numpy, lists, tensors; CPU and CUDA): bitwise identical, with the same dtype, device, and shape.
  • Tests, all passed:
    • Sensors: test_sensor_base, test_sensor_destructors, test_ray_caster_patterns, test_ray_caster_kernels, test_ray_caster_sensor, test_ray_caster_camera, test_multi_mesh_ray_caster, test_multi_mesh_ray_caster_camera, test_camera_pose_write_across_backends.
    • Devices: test_device_constructors.
    • Markers: test_visualization_markers, test_vis_marker_registry.
    • Visualizers: test_visualizer.
    • Assets: test_articulation_iface, test_rigid_object_iface, test_rigid_object_collection_iface.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<package>/changelog.d/ for each changed package (see Changelog)
  • If this is a user-visible change, the fragment clearly describes it

Release backport

  • Backport this pull request to the active release branch after it merges into develop

@StafaH
StafaH requested a review from a team September 27, 2026 23:16
@github-actions github-actions Bot added isaac-mimic Related to Isaac Mimic team isaac-lab Related to Isaac Lab team labels Sep 27, 2026
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors core asset, sensor, and device classes with bug fixes.

The PR appears safe to merge based on the reviewed changes.

Summary

This PR consolidates asset and sensor cleanup, simplifies camera and ray-caster helpers, and makes selected device teardown paths more tolerant of incomplete initialization. No actionable regression was established.

Reviews (1) · Last reviewed commit: "Use a Fixed changelog fragment for senso..."

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

The lifecycle cleanup generally centralizes debug-visualization teardown and preserves the reviewed public interfaces. One maintainability fix remains in SensorBase._clear_callbacks: its new string-based reflective handle loop conflicts with the repository rule against reflective assignment used merely to shorten code.

  • Design and architecture: Moving repeated debug-visualization cleanup into _clear_debug_vis_handle and removing pass-through constructors and no-op invalidation overrides appropriately centralizes lifecycle behavior within the asset and sensor base hierarchies.
  • API: The reviewed public signatures and input-handling surfaces remain unchanged, while the ray-caster camera frame annotation is corrected to torch.Tensor. The proposed concern about the Asset documentation cross-reference is not sufficiently established by the supplied repository context.
  • Implementation: Camera tensor normalization, Haply force selection, marker device moves, path partitioning, and ray-caster simplifications are supported by the changed paths and context. However, SensorBase._clear_callbacks now iterates string attribute names with getattr and setattr; replace this with explicit missing-safe blocks for each callback handle, matching AssetBase and preserving static visibility of lifecycle fields.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

self._prim_deletion_handle = None
# Clear debug visualization
"""Clears the callbacks. Handles may be missing if ``__init__`` failed before registering them."""
for name in ("_initialize_handle", "_invalidate_initialize_handle", "_prim_deletion_handle"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Suggestion · Implementation — Reflective handle clearing conflicts with style rule

Clearing the three handles by iterating attribute-name strings with getattr/setattr is the reflective assignment purely for brevity that the repository style rules disallow, and it diverges from AssetBase._clear_callbacks, which keeps explicit per-handle blocks. String-named attributes also hide these lifecycle fields from renames and static analysis. Keep the missing-handle tolerance but write three explicit if getattr(self, ...) is not None blocks.

@StafaH

StafaH commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 28, 2026
@StafaH
StafaH merged commit 2d6ebcc into isaac-sim:develop Sep 28, 2026
53 checks passed
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 28, 2026
# Description

Part 13 of the split of #7949. It cleans up the asset and sensor base
classes, the ray casters and camera, and a few device, marker, UI, and
visualizer helpers. It changes no public API. The deprecation-warning
refactor from #7949 is not included.

- **Asset / sensor base:**
- `AssetBase` and `SensorBase` now clear their debug-vis callback
through one `_clear_debug_vis_handle()` helper. It replaces three copies
of the same code in each class.
- `AssetBase.num_instances` and `AssetBase.data` now `raise
NotImplementedError` instead of returning it.
- Removed the pass-through `__init__` methods from the base cable,
deformable, rigid object, frame transformer, IMU, joint wrench, and PVA
classes.
- Removed the no-op `_invalidate_initialize_callback` overrides from the
contact sensor and frame transformer bases. This drops the stale TODO in
the contact sensor override.
- **Camera:** positions, orientations, eyes, and targets now go through
one `_as_device_tensor()` helper. `env_ids` handling is unchanged.
- **Ray casters:**
- The multi-mesh ray caster finds the rigid-body ancestor with
`sim_utils.get_first_matching_ancestor_prim`.
  - Inlined single-use kernel-argument locals.
  - Simplified the debug-vis code.
- Removed an unreachable "No meshes found" check. The loop already
raises for an invalid path, and only one mesh path is allowed.
  - Fixed the `frame` return annotation (`torch.Tensor`).
- **Devices:**
- Fixed the gamepad and keyboard `__init__` docstrings, which listed
parameters that don't exist.
  - Simplified the Haply force clipping.
- **Markers / UI / visualizers:**
  - Device moves are done in one expression.
- Added a `_has_implementation` helper and fixed docstrings and a typo.
  - The env-camera regex is precompiled.
  - Simplified how the live-plot source list is built.
- **`isaaclab/__init__.py`:** `pip_prebundle` is folded into the
fragment tuple, and one partition helper is shared by `sys.path` and
`PYTHONPATH`.

Small behavior notes:
- `SensorBase.__init__` now sets its callback and debug-vis handles to
`None` before anything that can fail, so `__del__` no longer raises
`AttributeError` when construction fails early (e.g. in
`validate(cfg)`).
- `Se2SpaceMouse` sets `_thread = None` first and `__del__` joins it
only when it was started, so a failed construction (e.g. no device
found) no longer raises in `__del__`.
- The Haply WebSocket receive-loop error is reported with `logger.error`
instead of `print`.

## Type of change

- Refactor, plus small teardown robustness fixes (see the behavior
notes)

## Verification

- Equivalence scripts comparing develop and this branch, with seeded
random inputs:
- Prebundle path demotion (2000 `sys.path` / `PYTHONPATH` cases):
identical.
- Haply force selection and clipping (1000 cases, CPU and CUDA):
identical.
- Camera array-like conversion (numpy, lists, tensors; CPU and CUDA):
bitwise identical, with the same dtype, device, and shape.
- Tests, all passed:
- Sensors: `test_sensor_base`, `test_sensor_destructors`,
`test_ray_caster_patterns`, `test_ray_caster_kernels`,
`test_ray_caster_sensor`, `test_ray_caster_camera`,
`test_multi_mesh_ray_caster`, `test_multi_mesh_ray_caster_camera`,
`test_camera_pose_write_across_backends`.
  - Devices: `test_device_constructors`.
  - Markers: `test_visualization_markers`, `test_vis_marker_registry`.
  - Visualizers: `test_visualizer`.
- Assets: `test_articulation_iface`, `test_rigid_object_iface`,
`test_rigid_object_collection_iface`.

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<package>/changelog.d/` for each changed package (see
[Changelog](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html#changelog))
- [x] If this is a user-visible change, the fragment clearly describes
it

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

(cherry picked from commit 2d6ebcc)
@isaaclab-bot

isaaclab-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 2b746ec.

@StafaH
StafaH deleted the core-cleanup/13-assets-sensors-misc branch October 10, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants