Unverified Commit ab789546 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Adds a prim path expression check for camera and ray-cast sensors (#314)

# Description

Currently, the ray-cast and camera sensors don't support having regex
expression in the leaves. While we must address this (#313), we add this
to our future plans.

For now, this MR adds a check to make sure users are aware and don't do
a wrong operation.

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] 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 5710bc47
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.10.6" version = "0.10.7"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.10.7 (2023-12-19)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Added a check to ray-cast and camera sensor classes to ensure that the sensor prim path does not
have a regex expression at its leaf. For instance, ``/World/Robot/camera_.*`` is not supported
for these sensor types. This behavior needs to be fixed in the future.
0.10.6 (2023-12-19) 0.10.6 (2023-12-19)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
...@@ -578,6 +589,7 @@ Added ...@@ -578,6 +589,7 @@ Added
0.9.18 (2023-10-23) 0.9.18 (2023-10-23)
~~~~~~~~~~~~~~~~~~~
Added Added
^^^^^ ^^^^^
......
...@@ -7,6 +7,7 @@ from __future__ import annotations ...@@ -7,6 +7,7 @@ from __future__ import annotations
import math import math
import numpy as np import numpy as np
import re
import torch import torch
from tensordict import TensorDict from tensordict import TensorDict
from typing import TYPE_CHECKING, Any, Sequence from typing import TYPE_CHECKING, Any, Sequence
...@@ -76,6 +77,16 @@ class Camera(SensorBase): ...@@ -76,6 +77,16 @@ class Camera(SensorBase):
RuntimeError: If no camera prim is found at the given path. RuntimeError: If no camera prim is found at the given path.
ValueError: If the provided data types are not supported by the camera. ValueError: If the provided data types are not supported by the camera.
""" """
# check if sensor path is valid
# note: currently we do not handle environment indices if there is a regex pattern in the leaf
# For example, if the prim path is "/World/Sensor_[1,2]".
sensor_path = cfg.prim_path.split("/")[-1]
sensor_path_is_regex = re.match(r"^[a-zA-Z0-9/_]+$", sensor_path) is None
if sensor_path_is_regex:
raise RuntimeError(
f"Invalid prim path for the camera sensor: {self.cfg.prim_path}."
"\n\tHint: Please ensure that the prim path does not contain any regex patterns in the leaf."
)
# perform check on supported data types # perform check on supported data types
self._check_supported_data_types(cfg) self._check_supported_data_types(cfg)
# initialize base class # initialize base class
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
from __future__ import annotations from __future__ import annotations
import numpy as np import numpy as np
import re
import torch import torch
from typing import TYPE_CHECKING, ClassVar, Sequence from typing import TYPE_CHECKING, ClassVar, Sequence
...@@ -61,6 +62,16 @@ class RayCaster(SensorBase): ...@@ -61,6 +62,16 @@ class RayCaster(SensorBase):
Args: Args:
cfg: The configuration parameters. cfg: The configuration parameters.
""" """
# check if sensor path is valid
# note: currently we do not handle environment indices if there is a regex pattern in the leaf
# For example, if the prim path is "/World/Sensor_[1,2]".
sensor_path = cfg.prim_path.split("/")[-1]
sensor_path_is_regex = re.match(r"^[a-zA-Z0-9/_]+$", sensor_path) is None
if sensor_path_is_regex:
raise RuntimeError(
f"Invalid prim path for the ray-caster sensor: {self.cfg.prim_path}."
"\n\tHint: Please ensure that the prim path does not contain any regex patterns in the leaf."
)
# Initialize base class # Initialize base class
super().__init__(cfg) super().__init__(cfg)
# Create empty variables for storing output data # Create empty variables for storing output data
......
...@@ -42,16 +42,13 @@ def raycast_mesh( ...@@ -42,16 +42,13 @@ def raycast_mesh(
The ray hit position. Shape (N, 3). The ray hit position. Shape (N, 3).
The returned tensor contains :obj:`float('inf')` for missed hits. The returned tensor contains :obj:`float('inf')` for missed hits.
The ray hit distance. Shape (N,). The ray hit distance. Shape (N,).
Will only return if `return_distance` is True, else returns None. Will only return if :attr:`return_distance` is True, else returns None.
Always at second position of the output tuple.
The returned tensor contains :obj:`float('inf')` for missed hits. The returned tensor contains :obj:`float('inf')` for missed hits.
The ray hit normal. Shape (N, 3). The ray hit normal. Shape (N, 3).
Will only return if `return_normal` is True else returns None. Will only return if :attr:`return_normal` is True else returns None.
Always at third position of the output tuple.
The returned tensor contains :obj:`float('inf')` for missed hits. The returned tensor contains :obj:`float('inf')` for missed hits.
The ray hit face id. Shape (N,). The ray hit face id. Shape (N,).
Will only return if `return_face_id` is True else returns None. Will only return if :attr:`return_face_id` is True else returns None.
Always at fourth position of the output tuple.
The returned tensor contains :obj:`int(-1)` for missed hits. The returned tensor contains :obj:`int(-1)` for missed hits.
""" """
# extract device and shape information # extract device and shape information
......
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