Unverified Commit e49ab0a1 authored by Pascal Roth's avatar Pascal Roth Committed by GitHub

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: 's avatarKelly Guo <kellyg@nvidia.com>
Signed-off-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
parent d1ecc377
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.40.18"
version = "0.40.19"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.40.19 (2025-07-11)
~~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed missing attribute in :class:`~isaaclab.sensors.ray_caster.RayCasterCamera` class and its reset method when no
env_ids are passed.
0.40.18 (2025-07-09)
~~~~~~~~~~~~~~~~~~~~
......
......@@ -110,11 +110,14 @@ class RayCaster(SensorBase):
# resolve None
if env_ids is None:
env_ids = slice(None)
num_envs_ids = self._view.count
else:
num_envs_ids = len(env_ids)
# resample the drift
r = torch.empty(len(env_ids), 3, device=self.device)
r = torch.empty(num_envs_ids, 3, device=self.device)
self.drift[env_ids] = r.uniform_(*self.cfg.drift_range)
# resample the height drift
r = torch.empty(len(env_ids), device=self.device)
r = torch.empty(num_envs_ids, device=self.device)
self.ray_cast_drift[env_ids, 0] = r.uniform_(*self.cfg.ray_cast_drift_range["x"])
self.ray_cast_drift[env_ids, 1] = r.uniform_(*self.cfg.ray_cast_drift_range["y"])
self.ray_cast_drift[env_ids, 2] = r.uniform_(*self.cfg.ray_cast_drift_range["z"])
......
......@@ -345,6 +345,7 @@ class RayCasterCamera(RayCaster):
"""Create buffers for storing data."""
# prepare drift
self.drift = torch.zeros(self._view.count, 3, device=self.device)
self.ray_cast_drift = torch.zeros(self._view.count, 3, device=self.device)
# create the data object
# -- pose of the cameras
self._data.pos_w = torch.zeros((self._view.count, 3), device=self._device)
......@@ -400,6 +401,8 @@ class RayCasterCamera(RayCaster):
# obtain the poses of the sensors
# note: clone arg doesn't exist for xform prim view so we need to do this manually
if isinstance(self._view, XFormPrim):
if isinstance(env_ids, slice): # catch the case where env_ids is a slice
env_ids = self._ALL_INDICES
pos_w, quat_w = self._view.get_world_poses(env_ids)
elif isinstance(self._view, physx.ArticulationView):
pos_w, quat_w = self._view.get_root_transforms()[env_ids].split([3, 4], dim=-1)
......
......@@ -125,6 +125,16 @@ def test_camera_init(setup_sim):
for im_data in camera.data.output.values():
assert im_data.shape == (1, camera_cfg.pattern_cfg.height, camera_cfg.pattern_cfg.width, 1)
# check the camera reset
camera.reset()
assert torch.all(camera.frame == 0)
# Simulate physics
for _ in range(10):
sim.step()
camera.update(dt)
camera.reset(env_ids=[0])
assert camera.frame[0] == 0
def test_camera_resolution(setup_sim):
"""Test camera resolution is correctly set."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment