Commit c8067355 authored by Pascal Roth's avatar Pascal Roth Committed by Mayank Mittal

Fixes drift initialization in `RayCasterCamera` class (#249)

This MR fixes a bug in `RaycasterCamera` where the drift was not being
initialized correctly.

- Bug fix (non-breaking change which fixes an issue)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.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 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
parent 7c513475
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.9.47"
version = "0.9.48"
# Description
title = "ORBIT framework for Robot Learning"
......
Changelog
---------
0.9.48 (2023-11-24)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed initialization of drift in the :class:`omni.isaac.orbit.sensors.RayCasterCamera` class.
0.9.47 (2023-11-24)
~~~~~~~~~~~~~~~~~~~
......
......@@ -19,7 +19,7 @@ from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.sensors import RayCaster
if TYPE_CHECKING:
from omni.isaac.orbit.envs import BaseEnv
from omni.isaac.orbit.envs import BaseEnv, RLTaskEnv
"""
Root state.
......@@ -94,6 +94,6 @@ Commands.
"""
def generated_commands(env: BaseEnv) -> torch.Tensor:
def generated_commands(env: RLTaskEnv) -> torch.Tensor:
"""The generated command from the command generator."""
return env.command_manager.command
......@@ -75,8 +75,10 @@ class Camera(SensorBase):
Raises:
RuntimeError: If no camera prim is found at the given path.
ValueError: If the sensor types intersect with in the unsupported list.
ValueError: If the provided data types are not supported by the camera.
"""
# perform check on supported data types
self._check_supported_data_types(cfg)
# initialize base class
super().__init__(cfg)
......@@ -99,17 +101,6 @@ class Camera(SensorBase):
self._sensor_prims: list[UsdGeom.Camera] = list()
# Create empty variables for storing output data
self._data = CameraData()
# check if there is any intersection in unsupported types
# reason: these use np structured data types which we can't yet convert to torch tensor
common_elements = set(self.cfg.data_types) & Camera.UNSUPPORTED_TYPES
if common_elements:
raise ValueError(
f"Camera class does not support the following sensor types: {common_elements}."
"\n\tThis is because these sensor types output numpy structured data types which"
"can't be converted to torch tensors easily."
"\n\tHint: If you need to work with these sensor types, we recommend using the single camera"
" implementation from the omni.isaac.orbit.compat.camera module."
)
def __del__(self):
"""Unsubscribes from callbacks and detach from the replicator registry."""
......@@ -431,6 +422,20 @@ class Camera(SensorBase):
Private Helpers
"""
def _check_supported_data_types(self, cfg: CameraCfg):
"""Checks if the data types are supported by the ray-caster camera."""
# check if there is any intersection in unsupported types
# reason: these use np structured data types which we can't yet convert to torch tensor
common_elements = set(cfg.data_types) & Camera.UNSUPPORTED_TYPES
if common_elements:
raise ValueError(
f"Camera class does not support the following sensor types: {common_elements}."
"\n\tThis is because these sensor types output numpy structured data types which"
"can't be converted to torch tensors easily."
"\n\tHint: If you need to work with these sensor types, we recommend using the single camera"
" implementation from the omni.isaac.orbit.compat.camera module."
)
def _create_buffers(self):
"""Create buffers for storing data."""
# create the data object
......
......@@ -64,23 +64,17 @@ class RayCasterCamera(RayCaster):
Args:
cfg: The configuration parameters.
Raises:
ValueError: If the provided data types are not supported by the ray-caster camera.
"""
# perform check on supported data types
self._check_supported_data_types(cfg)
# initialize base class
super().__init__(cfg)
# Create empty variables for storing output data
# create empty variables for storing output data
self._data = CameraData()
# check if there is any intersection in unsupported types
# reason: we cannot obtain this data from simplified warp-based ray caster
common_elements = set(self.cfg.data_types) & RayCasterCamera.UNSUPPORTED_TYPES
if common_elements:
raise ValueError(
f"RayCasterCamera class does not support the following sensor types: {common_elements}."
"\n\tThis is because these sensor types cannot be obtained in a fast way using ''warp''."
"\n\tHint: If you need to work with these sensor types, we recommend using the USD camera"
" interface from the omni.isaac.orbit.sensors.camera module."
)
def __str__(self) -> str:
"""Returns: A string containing information about the instance."""
return (
......@@ -305,8 +299,23 @@ class RayCasterCamera(RayCaster):
Private Helpers
"""
def _check_supported_data_types(self, cfg: RayCasterCameraCfg):
"""Checks if the data types are supported by the ray-caster camera."""
# check if there is any intersection in unsupported types
# reason: we cannot obtain this data from simplified warp-based ray caster
common_elements = set(cfg.data_types) & RayCasterCamera.UNSUPPORTED_TYPES
if common_elements:
raise ValueError(
f"RayCasterCamera class does not support the following sensor types: {common_elements}."
"\n\tThis is because these sensor types cannot be obtained in a fast way using ''warp''."
"\n\tHint: If you need to work with these sensor types, we recommend using the USD camera"
" interface from the omni.isaac.orbit.sensors.camera module."
)
def _create_buffers(self):
"""Create buffers for storing data."""
# prepare drift
self.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)
......
......@@ -24,8 +24,8 @@ import traceback
import unittest
import carb
import omni.isaac.core.utils.stage as stage_utils
import omni.isaac.core.utils.prims as prim_utils
import omni.isaac.core.utils.stage as stage_utils
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import RigidObject, RigidObjectCfg
......
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