Skip to content

Commit

Permalink
Fixes drift initialization in RayCasterCamera class (#249)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pascal-roth authored and Mayankm96 committed Nov 24, 2023
1 parent 7c51347 commit c806735
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 28 deletions.
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.orbit/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.9.47"
version = "0.9.48"

# Description
title = "ORBIT framework for Robot Learning"
Expand Down
9 changes: 9 additions & 0 deletions source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
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)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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.
Expand Down Expand Up @@ -94,6 +94,6 @@ def last_action(env: BaseEnv) -> torch.Tensor:
"""


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
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ def __init__(self, cfg: CameraCfg):
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)

Expand All @@ -99,17 +101,6 @@ def __init__(self, cfg: CameraCfg):
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."""
Expand Down Expand Up @@ -431,6 +422,20 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,17 @@ def __init__(self, cfg: RayCasterCameraCfg):
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 (
Expand Down Expand Up @@ -305,8 +299,23 @@ def _debug_vis_callback(self, event):
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
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
Expand Down

0 comments on commit c806735

Please sign in to comment.