Skip to content

Commit e49ab0a

Browse files
Fixes missing ray_cast_drift in RayCasterCamera (#2901)
# Description Fixes missing `ray_cast_drift` in `RayCasterCamera` Fixes #2891 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Kelly Guo <kellyg@nvidia.com> Signed-off-by: Kelly Guo <kellyguo123@hotmail.com> Co-authored-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: Kelly Guo <kellyguo123@hotmail.com>
1 parent d1ecc37 commit e49ab0a

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

source/isaaclab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.40.18"
4+
version = "0.40.19"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/isaaclab/docs/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
0.40.19 (2025-07-11)
5+
~~~~~~~~~~~~~~~~~~~~
6+
7+
Fixed
8+
^^^^^
9+
10+
* Fixed missing attribute in :class:`~isaaclab.sensors.ray_caster.RayCasterCamera` class and its reset method when no
11+
env_ids are passed.
12+
13+
414
0.40.18 (2025-07-09)
515
~~~~~~~~~~~~~~~~~~~~
616

source/isaaclab/isaaclab/sensors/ray_caster/ray_caster.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,14 @@ def reset(self, env_ids: Sequence[int] | None = None):
110110
# resolve None
111111
if env_ids is None:
112112
env_ids = slice(None)
113+
num_envs_ids = self._view.count
114+
else:
115+
num_envs_ids = len(env_ids)
113116
# resample the drift
114-
r = torch.empty(len(env_ids), 3, device=self.device)
117+
r = torch.empty(num_envs_ids, 3, device=self.device)
115118
self.drift[env_ids] = r.uniform_(*self.cfg.drift_range)
116119
# resample the height drift
117-
r = torch.empty(len(env_ids), device=self.device)
120+
r = torch.empty(num_envs_ids, device=self.device)
118121
self.ray_cast_drift[env_ids, 0] = r.uniform_(*self.cfg.ray_cast_drift_range["x"])
119122
self.ray_cast_drift[env_ids, 1] = r.uniform_(*self.cfg.ray_cast_drift_range["y"])
120123
self.ray_cast_drift[env_ids, 2] = r.uniform_(*self.cfg.ray_cast_drift_range["z"])

source/isaaclab/isaaclab/sensors/ray_caster/ray_caster_camera.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def _create_buffers(self):
345345
"""Create buffers for storing data."""
346346
# prepare drift
347347
self.drift = torch.zeros(self._view.count, 3, device=self.device)
348+
self.ray_cast_drift = torch.zeros(self._view.count, 3, device=self.device)
348349
# create the data object
349350
# -- pose of the cameras
350351
self._data.pos_w = torch.zeros((self._view.count, 3), device=self._device)
@@ -400,6 +401,8 @@ def _compute_view_world_poses(self, env_ids: Sequence[int]) -> tuple[torch.Tenso
400401
# obtain the poses of the sensors
401402
# note: clone arg doesn't exist for xform prim view so we need to do this manually
402403
if isinstance(self._view, XFormPrim):
404+
if isinstance(env_ids, slice): # catch the case where env_ids is a slice
405+
env_ids = self._ALL_INDICES
403406
pos_w, quat_w = self._view.get_world_poses(env_ids)
404407
elif isinstance(self._view, physx.ArticulationView):
405408
pos_w, quat_w = self._view.get_root_transforms()[env_ids].split([3, 4], dim=-1)

source/isaaclab/test/sensors/test_ray_caster_camera.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ def test_camera_init(setup_sim):
125125
for im_data in camera.data.output.values():
126126
assert im_data.shape == (1, camera_cfg.pattern_cfg.height, camera_cfg.pattern_cfg.width, 1)
127127

128+
# check the camera reset
129+
camera.reset()
130+
assert torch.all(camera.frame == 0)
131+
# Simulate physics
132+
for _ in range(10):
133+
sim.step()
134+
camera.update(dt)
135+
camera.reset(env_ids=[0])
136+
assert camera.frame[0] == 0
137+
128138

129139
def test_camera_resolution(setup_sim):
130140
"""Test camera resolution is correctly set."""

0 commit comments

Comments
 (0)