isaaclab_newton.sensors#
Sub-package containing Newton-specific sensor implementations.
Classes
Ray-cast sensor that queries the whole Newton scene through the model's shape BVH. |
|
Configuration for the Newton BVH ray-cast sensor. |
|
Data container for the Newton BVH ray-cast sensor. |
|
Legacy Newton ray caster that queries one configured Warp mesh. |
|
Legacy Newton ray-caster camera backed by configured Warp meshes. |
|
Legacy Newton ray caster for configured static and dynamic Warp meshes. |
|
Legacy Newton ray-caster camera for configured Warp meshes. |
Ray Caster#
- class isaaclab_newton.sensors.NewtonRaycastSensor[source]#
Bases:
_NewtonRayCasterPoseMixin,BaseRayCasterRay-cast sensor that queries the whole Newton scene through the model’s shape BVH.
Rays are cast with
newton.intersect_ray()against every collision shape in the sensor’s own world plus the global world (e.g. terrain), so dynamic bodies are hit without configuring target meshes. The full update (sensor pose, ray transform, BVH query, hit resolve) is registered as a task withNewtonManager, which owns the shared BVH refit and sensor execution graph.Attributes:
The configuration parameters.
Data from the sensor.
World-frame ray start positions as of the last update [m].
World-frame ray directions (unit vectors) as of the last update.
Number of resolved Newton sites tracked as sensor frames.
Memory device for computation.
Whether the sensor has a debug visualization implemented.
Whether the sensor is initialized.
A dictionary to store warp meshes for raycasting, shared across all instances.
Number of instances of the sensor.
Methods:
__init__(cfg)Register the sensor site before Newton model finalization.
get_world_poses([indices])Return world poses for legacy camera helpers.
reset([env_ids, env_mask])Resets the sensor internals.
set_debug_vis(debug_vis)Sets whether to visualize the sensor data.
- cfg: NewtonRaycastSensorCfg#
The configuration parameters.
- __init__(cfg: NewtonRaycastSensorCfg)[source]#
Register the sensor site before Newton model finalization.
- property data: NewtonRaycastSensorData#
Data from the sensor.
This property is only updated when the user tries to access the data. This is done to avoid unnecessary computation when the sensor data is not used.
For updating the sensor when this property is accessed, you can use the following code snippet in your sensor implementation:
# update sensors if needed self._update_outdated_buffers() # return the data (where `_data` is the data for the sensor) return self._data
- property ray_starts_w: ProxyArray#
World-frame ray start positions as of the last update [m].
Shape is (N, B), dtype
wp.vec3f. In torch this resolves to (N, B, 3).
- property ray_directions_w: ProxyArray#
World-frame ray directions (unit vectors) as of the last update.
Shape is (N, B), dtype
wp.vec3f. In torch this resolves to (N, B, 3).
- get_world_poses(indices=None) tuple[ProxyArray, ProxyArray]#
Return world poses for legacy camera helpers.
- property has_debug_vis_implementation: bool#
Whether the sensor has a debug visualization implemented.
- property is_initialized: bool#
Whether the sensor is initialized.
Returns True if the sensor is initialized, False otherwise.
- meshes: ClassVar[dict[tuple[str, str], wp.Mesh]] = {}#
A dictionary to store warp meshes for raycasting, shared across all instances.
The keys are
(prim_path, device)tuples and values are the corresponding warp Mesh objects. Meshes are created lazily for the sensor’s active device, not eagerly for every device. Including the device in the key prevents a mesh created on one device (e.g. CPU) from being reused by a kernel running on a different device (e.g. CUDA) when multiple simulation contexts or tests use different devices in the same Python process.
- property num_instances: int#
Number of instances of the sensor.
This is equal to the number of sensors per environment multiplied by the number of environments.
- class isaaclab_newton.sensors.NewtonRaycastSensorCfg[source]#
Bases:
RayCasterCfgConfiguration for the Newton BVH ray-cast sensor.
Unlike
RayCasterCfg, no target meshes are configured: rays are cast against every collision shape in the Newton scene through the model’s shape BVH, including dynamic bodies.Attributes:
The associated sensor class.
Cloning contexts for this sensor.
Prim path (or expression) to the sensor.
Update period of the sensor buffers (in seconds).
Whether to visualize the sensor.
Spawn configuration for the sensor Xform prim.
Unused.
The offset pose of the sensor's frame from the sensor's parent frame.
Specify in what frame the rays are projected onto the ground.
The pattern that defines the local ray starting positions and directions.
Maximum distance (in meters) from the sensor to ray cast to.
Cast rays against the global world only.
The range of drift (in meters) to add to the ray starting positions (xyz) in world frame.
The range of drift (in meters) to add to the projected ray points in local projection frame.
The configuration object for the visualization markers.
- class_type: type[NewtonRaycastSensor] | str#
The associated sensor class.
The class should inherit from
isaaclab.sensors.sensor_base.SensorBase.
- cloning_contexts: tuple[str | type, ...] | None#
Cloning contexts for this sensor. Defaults to USD-only cloning.
Sensors carry no physics of their own; see
cloning_contexts.
- prim_path: str#
Prim path (or expression) to the sensor.
Note
The expression can contain the environment namespace regex
{ENV_REGEX_NS}which will be replaced with the environment namespace.Example:
{ENV_REGEX_NS}/Robot/sensorwill be replaced with/World/envs/env_.*/Robot/sensor.
- update_period: float#
Update period of the sensor buffers (in seconds). Defaults to 0.0 (update every step).
- spawn: SensorFrameCfg | None#
Spawn configuration for the sensor Xform prim.
A plain USD Xform is created at
prim_pathbefore initialization, matching the pattern used byCameraCfg(which spawns a Camera prim). Theprim_pathcan be either:A new child path under a parent link (e.g.
{ENV_REGEX_NS}/Robot/base).A physics body path (e.g.
{ENV_REGEX_NS}/Robot/base). In this case, the sensor will automatically create a child Xform at{prim_path}.
If
None, the prim atprim_pathmust already exist on the USD stage and must not be a physics body.
- offset: OffsetCfg#
The offset pose of the sensor’s frame from the sensor’s parent frame. Defaults to identity.
- ray_alignment: Literal['base', 'yaw', 'world']#
Specify in what frame the rays are projected onto the ground. Default is “base”.
The options are:
baseif the rays’ starting positions and directions track the full root position and orientation.yawif the rays’ starting positions track root position and the yaw component of the orientation, while ray directions remain fixed in world frame. This is useful for ray-casting height maps where the scan footprint should follow the body heading without tilting when the body pitches or rolls.worldif rays’ starting positions and directions are always fixed. This is useful in combination with a mapping package on the robot and querying ray-casts in a global frame.
- pattern_cfg: PatternBaseCfg#
The pattern that defines the local ray starting positions and directions.
- global_world_only: bool#
Cast rays against the global world only. Defaults to False.
Newton backend only (ignored by the PhysX and OvPhysX backends, which ray cast against the meshes in
mesh_prim_paths). The global world holds shapes shared by all environments (e.g. terrain). When False, rays additionally hit the shapes of the sensor’s own environment — including the sensor’s carrier body when it lies in the ray path; useoffsetto start the rays outside the carrier’s geometry in that case.
- drift_range: tuple[float, float]#
The range of drift (in meters) to add to the ray starting positions (xyz) in world frame. Defaults to (0.0, 0.0).
For floating base robots, this is useful for simulating drift in the robot’s pose estimation.
- ray_cast_drift_range: dict[str, tuple[float, float]]#
The range of drift (in meters) to add to the projected ray points in local projection frame. Defaults to a dictionary with zero drift for each x, y and z axis.
For floating base robots, this is useful for simulating drift in the robot’s pose estimation.
- visualizer_cfg: VisualizationMarkersCfg#
The configuration object for the visualization markers. Defaults to RAY_CASTER_MARKER_CFG.
Note
This attribute is only used when debug visualization is enabled.
- class isaaclab_newton.sensors.NewtonRaycastSensorData[source]#
Bases:
RayCasterDataData container for the Newton BVH ray-cast sensor.
Extends
RayCasterDatawith hit distances and surface normals, which the Newton BVH query provides at no extra cost.Attributes:
Ray hit distances from the ray origins [m].
Surface normals at the ray hit points in world frame.
Methods:
create_buffers(num_envs, num_rays, device)Create internal warp buffers and their
ProxyArraywrappers.- property ray_distances: ProxyArray#
Ray hit distances from the ray origins [m].
Shape is (N, B), dtype
wp.float32, where N is the number of sensors and B is the number of rays per sensor. Containsinffor missed hits.
- property ray_normals_w: ProxyArray#
Surface normals at the ray hit points in world frame.
Shape is (N, B), dtype
wp.vec3f. In torch this resolves to (N, B, 3). Containsinffor missed hits.
Legacy Ray Casters#
- class isaaclab_newton.sensors.LegacyRayCaster[source]#
Bases:
_LegacyNewtonRayCasterMixin,BaseRayCasterLegacy Newton ray caster that queries one configured Warp mesh.
Methods:
__init__(cfg)Register the sensor site before Newton model finalization.
get_world_poses([indices])Return world poses for legacy camera helpers.
reset([env_ids, env_mask])Resets the sensor internals.
set_debug_vis(debug_vis)Sets whether to visualize the sensor data.
Attributes:
Number of resolved Newton sites tracked as sensor frames.
Data from the sensor.
Memory device for computation.
Whether the sensor has a debug visualization implemented.
Whether the sensor is initialized.
A dictionary to store warp meshes for raycasting, shared across all instances.
Number of instances of the sensor.
The configuration parameters.
- __init__(cfg)#
Register the sensor site before Newton model finalization.
- property data: RayCasterData#
Data from the sensor.
This property is only updated when the user tries to access the data. This is done to avoid unnecessary computation when the sensor data is not used.
For updating the sensor when this property is accessed, you can use the following code snippet in your sensor implementation:
# update sensors if needed self._update_outdated_buffers() # return the data (where `_data` is the data for the sensor) return self._data
- get_world_poses(indices=None) tuple[ProxyArray, ProxyArray]#
Return world poses for legacy camera helpers.
- property has_debug_vis_implementation: bool#
Whether the sensor has a debug visualization implemented.
- property is_initialized: bool#
Whether the sensor is initialized.
Returns True if the sensor is initialized, False otherwise.
- meshes: ClassVar[dict[tuple[str, str], wp.Mesh]] = {}#
A dictionary to store warp meshes for raycasting, shared across all instances.
The keys are
(prim_path, device)tuples and values are the corresponding warp Mesh objects. Meshes are created lazily for the sensor’s active device, not eagerly for every device. Including the device in the key prevents a mesh created on one device (e.g. CPU) from being reused by a kernel running on a different device (e.g. CUDA) when multiple simulation contexts or tests use different devices in the same Python process.
- property num_instances: int#
Number of instances of the sensor.
This is equal to the number of sensors per environment multiplied by the number of environments.
- reset(env_ids: Sequence[int] | None = None, env_mask: wp.array | None = None)#
Resets the sensor internals.
- set_debug_vis(debug_vis: bool) bool#
Sets whether to visualize the sensor data.
- Parameters:
debug_vis¶ – Whether to visualize the sensor data.
- Returns:
Whether the debug visualization was successfully set. False if the sensor does not support debug visualization.
- cfg: RayCasterCfg#
The configuration parameters.
- class isaaclab_newton.sensors.LegacyRayCasterCamera[source]#
Bases:
_LegacyNewtonRayCasterMixin,BaseRayCasterCameraLegacy Newton ray-caster camera backed by configured Warp meshes.
Attributes:
A set of sensor types that are not supported by the ray-caster camera.
Number of resolved Newton sites tracked as sensor frames.
Data from the sensor.
Memory device for computation.
Frame number when the measurement took place.
Whether the sensor has a debug visualization implemented.
A tuple containing (height, width) of the camera sensor.
Whether the sensor is initialized.
A dictionary to store warp meshes for raycasting, shared across all instances.
Number of instances of the sensor.
The configuration parameters.
Methods:
__init__(cfg)Register the sensor site before Newton model finalization.
get_world_poses([indices])Return world poses for legacy camera helpers.
reset([env_ids, env_mask])Resets the sensor internals.
set_debug_vis(debug_vis)Sets whether to visualize the sensor data.
set_intrinsic_matrices(matrices[, ...])Set the intrinsic matrix of the camera.
set_world_poses([positions, orientations, ...])Set the pose of the camera w.r.t.
set_world_poses_from_view(eyes, targets[, ...])Set the poses of the camera from the eye position and look-at target position.
- UNSUPPORTED_TYPES: ClassVar[set[str]] = {'bounding_box_2d_loose', 'bounding_box_2d_loose_fast', 'bounding_box_2d_tight', 'bounding_box_2d_tight_fast', 'bounding_box_3d', 'bounding_box_3d_fast', 'instance_id_segmentation', 'instance_id_segmentation_fast', 'instance_segmentation', 'motion_vectors', 'rgb', 'semantic_segmentation', 'skeleton_data'}#
A set of sensor types that are not supported by the ray-caster camera.
- __init__(cfg)#
Register the sensor site before Newton model finalization.
- property data: CameraData#
Data from the sensor.
This property is only updated when the user tries to access the data. This is done to avoid unnecessary computation when the sensor data is not used.
For updating the sensor when this property is accessed, you can use the following code snippet in your sensor implementation:
# update sensors if needed self._update_outdated_buffers() # return the data (where `_data` is the data for the sensor) return self._data
- property frame: torch.tensor#
Frame number when the measurement took place.
- get_world_poses(indices=None) tuple[ProxyArray, ProxyArray]#
Return world poses for legacy camera helpers.
- property has_debug_vis_implementation: bool#
Whether the sensor has a debug visualization implemented.
- property is_initialized: bool#
Whether the sensor is initialized.
Returns True if the sensor is initialized, False otherwise.
- meshes: ClassVar[dict[tuple[str, str], wp.Mesh]] = {}#
A dictionary to store warp meshes for raycasting, shared across all instances.
The keys are
(prim_path, device)tuples and values are the corresponding warp Mesh objects. Meshes are created lazily for the sensor’s active device, not eagerly for every device. Including the device in the key prevents a mesh created on one device (e.g. CPU) from being reused by a kernel running on a different device (e.g. CUDA) when multiple simulation contexts or tests use different devices in the same Python process.
- property num_instances: int#
Number of instances of the sensor.
This is equal to the number of sensors per environment multiplied by the number of environments.
- reset(env_ids: Sequence[int] | None = None, env_mask: wp.array | None = None)#
Resets the sensor internals.
- set_debug_vis(debug_vis: bool) bool#
Sets whether to visualize the sensor data.
- Parameters:
debug_vis¶ – Whether to visualize the sensor data.
- Returns:
Whether the debug visualization was successfully set. False if the sensor does not support debug visualization.
- set_intrinsic_matrices(matrices: torch.Tensor, focal_length: float = 1.0, env_ids: Sequence[int] | None = None)#
Set the intrinsic matrix of the camera.
- set_world_poses(positions: torch.Tensor | None = None, orientations: torch.Tensor | None = None, env_ids: Sequence[int] | None = None, convention: Literal['opengl', 'ros', 'world'] = 'ros')#
Set the pose of the camera w.r.t. the world frame using specified convention.
Since different fields use different conventions for camera orientations, the method allows users to set the camera poses in the specified convention. Possible conventions are:
"opengl"- forward axis: -Z - up axis +Y - Offset is applied in the OpenGL (Usd.Camera) convention"ros"- forward axis: +Z - up axis -Y - Offset is applied in the ROS convention"world"- forward axis: +X - up axis +Z - Offset is applied in the World Frame convention
See
isaaclab.utils.math.convert_camera_frame_orientation_convention()for more details on the conventions.- Parameters:
positions¶ – The cartesian coordinates (in meters). Shape is (N, 3). Defaults to None, in which case the camera position in not changed.
orientations¶ – The quaternion orientation in (x, y, z, w). Shape is (N, 4). Defaults to None, in which case the camera orientation in not changed.
env_ids¶ – A sensor ids to manipulate. Defaults to None, which means all sensor indices.
convention¶ – The convention in which the poses are fed. Defaults to “ros”.
- Raises:
RuntimeError – If the camera prim is not set. Need to call
initialize()method first.
- set_world_poses_from_view(eyes: torch.Tensor, targets: torch.Tensor, env_ids: Sequence[int] | None = None)#
Set the poses of the camera from the eye position and look-at target position.
- Parameters:
- Raises:
RuntimeError – If the camera prim is not set. Need to call
initialize()method first.NotImplementedError – If the stage up-axis is not “Y” or “Z”.
- cfg: RayCasterCameraCfg#
The configuration parameters.
- class isaaclab_newton.sensors.LegacyMultiMeshRayCaster[source]#
Bases:
_LegacyNewtonRayCasterMixin,BaseMultiMeshRayCasterLegacy Newton ray caster for configured static and dynamic Warp meshes.
Methods:
__init__(cfg)Register the sensor site before Newton model finalization.
get_world_poses([indices])Return world poses for legacy camera helpers.
reset([env_ids, env_mask])Resets the sensor internals.
set_debug_vis(debug_vis)Sets whether to visualize the sensor data.
Attributes:
Number of resolved Newton sites tracked as sensor frames.
Data from the sensor.
Memory device for computation.
Whether the sensor has a debug visualization implemented.
Whether the sensor is initialized.
A dictionary to store warp meshes for raycasting, shared across all instances.
Number of instances of the sensor.
The configuration parameters.
- __init__(cfg)#
Register the sensor site before Newton model finalization.
- property data: MultiMeshRayCasterData#
Data from the sensor.
This property is only updated when the user tries to access the data. This is done to avoid unnecessary computation when the sensor data is not used.
For updating the sensor when this property is accessed, you can use the following code snippet in your sensor implementation:
# update sensors if needed self._update_outdated_buffers() # return the data (where `_data` is the data for the sensor) return self._data
- get_world_poses(indices=None) tuple[ProxyArray, ProxyArray]#
Return world poses for legacy camera helpers.
- property has_debug_vis_implementation: bool#
Whether the sensor has a debug visualization implemented.
- property is_initialized: bool#
Whether the sensor is initialized.
Returns True if the sensor is initialized, False otherwise.
- meshes: ClassVar[dict[tuple[str, str], wp.Mesh]] = {}#
A dictionary to store warp meshes for raycasting, shared across all instances.
The keys are
(prim_path, device)tuples and values are the corresponding warp Mesh objects. Meshes are created lazily for the sensor’s active device, not eagerly for every device. Including the device in the key prevents a mesh created on one device (e.g. CPU) from being reused by a kernel running on a different device (e.g. CUDA) when multiple simulation contexts or tests use different devices in the same Python process.
- property num_instances: int#
Number of instances of the sensor.
This is equal to the number of sensors per environment multiplied by the number of environments.
- reset(env_ids: Sequence[int] | None = None, env_mask: wp.array | None = None)#
Resets the sensor internals.
- set_debug_vis(debug_vis: bool) bool#
Sets whether to visualize the sensor data.
- Parameters:
debug_vis¶ – Whether to visualize the sensor data.
- Returns:
Whether the debug visualization was successfully set. False if the sensor does not support debug visualization.
- cfg: MultiMeshRayCasterCfg#
The configuration parameters.
- class isaaclab_newton.sensors.LegacyMultiMeshRayCasterCamera[source]#
Bases:
_LegacyNewtonRayCasterMixin,BaseMultiMeshRayCasterCameraLegacy Newton ray-caster camera for configured Warp meshes.
Attributes:
A set of sensor types that are not supported by the ray-caster camera.
Number of resolved Newton sites tracked as sensor frames.
Data from the sensor.
Memory device for computation.
Frame number when the measurement took place.
Whether the sensor has a debug visualization implemented.
A tuple containing (height, width) of the camera sensor.
Whether the sensor is initialized.
A dictionary to store warp meshes for raycasting, shared across all instances.
Number of instances of the sensor.
The configuration parameters.
Methods:
__init__(cfg)Register the sensor site before Newton model finalization.
get_world_poses([indices])Return world poses for legacy camera helpers.
reset([env_ids, env_mask])Resets the sensor internals.
set_debug_vis(debug_vis)Sets whether to visualize the sensor data.
set_intrinsic_matrices(matrices[, ...])Set the intrinsic matrix of the camera.
set_world_poses([positions, orientations, ...])Set the pose of the camera w.r.t.
set_world_poses_from_view(eyes, targets[, ...])Set the poses of the camera from the eye position and look-at target position.
- UNSUPPORTED_TYPES: ClassVar[set[str]] = {'bounding_box_2d_loose', 'bounding_box_2d_loose_fast', 'bounding_box_2d_tight', 'bounding_box_2d_tight_fast', 'bounding_box_3d', 'bounding_box_3d_fast', 'instance_id_segmentation', 'instance_id_segmentation_fast', 'instance_segmentation', 'motion_vectors', 'rgb', 'semantic_segmentation', 'skeleton_data'}#
A set of sensor types that are not supported by the ray-caster camera.
- __init__(cfg)#
Register the sensor site before Newton model finalization.
- property data: CameraData#
Data from the sensor.
This property is only updated when the user tries to access the data. This is done to avoid unnecessary computation when the sensor data is not used.
For updating the sensor when this property is accessed, you can use the following code snippet in your sensor implementation:
# update sensors if needed self._update_outdated_buffers() # return the data (where `_data` is the data for the sensor) return self._data
- property frame: torch.tensor#
Frame number when the measurement took place.
- get_world_poses(indices=None) tuple[ProxyArray, ProxyArray]#
Return world poses for legacy camera helpers.
- property has_debug_vis_implementation: bool#
Whether the sensor has a debug visualization implemented.
- property is_initialized: bool#
Whether the sensor is initialized.
Returns True if the sensor is initialized, False otherwise.
- meshes: ClassVar[dict[tuple[str, str], wp.Mesh]] = {}#
A dictionary to store warp meshes for raycasting, shared across all instances.
The keys are
(prim_path, device)tuples and values are the corresponding warp Mesh objects. Meshes are created lazily for the sensor’s active device, not eagerly for every device. Including the device in the key prevents a mesh created on one device (e.g. CPU) from being reused by a kernel running on a different device (e.g. CUDA) when multiple simulation contexts or tests use different devices in the same Python process.
- property num_instances: int#
Number of instances of the sensor.
This is equal to the number of sensors per environment multiplied by the number of environments.
- reset(env_ids: Sequence[int] | None = None, env_mask: wp.array | None = None)#
Resets the sensor internals.
- set_debug_vis(debug_vis: bool) bool#
Sets whether to visualize the sensor data.
- Parameters:
debug_vis¶ – Whether to visualize the sensor data.
- Returns:
Whether the debug visualization was successfully set. False if the sensor does not support debug visualization.
- set_intrinsic_matrices(matrices: torch.Tensor, focal_length: float = 1.0, env_ids: Sequence[int] | None = None)#
Set the intrinsic matrix of the camera.
- set_world_poses(positions: torch.Tensor | None = None, orientations: torch.Tensor | None = None, env_ids: Sequence[int] | None = None, convention: Literal['opengl', 'ros', 'world'] = 'ros')#
Set the pose of the camera w.r.t. the world frame using specified convention.
Since different fields use different conventions for camera orientations, the method allows users to set the camera poses in the specified convention. Possible conventions are:
"opengl"- forward axis: -Z - up axis +Y - Offset is applied in the OpenGL (Usd.Camera) convention"ros"- forward axis: +Z - up axis -Y - Offset is applied in the ROS convention"world"- forward axis: +X - up axis +Z - Offset is applied in the World Frame convention
See
isaaclab.utils.math.convert_camera_frame_orientation_convention()for more details on the conventions.- Parameters:
positions¶ – The cartesian coordinates (in meters). Shape is (N, 3). Defaults to None, in which case the camera position in not changed.
orientations¶ – The quaternion orientation in (x, y, z, w). Shape is (N, 4). Defaults to None, in which case the camera orientation in not changed.
env_ids¶ – A sensor ids to manipulate. Defaults to None, which means all sensor indices.
convention¶ – The convention in which the poses are fed. Defaults to “ros”.
- Raises:
RuntimeError – If the camera prim is not set. Need to call
initialize()method first.
- set_world_poses_from_view(eyes: torch.Tensor, targets: torch.Tensor, env_ids: Sequence[int] | None = None)#
Set the poses of the camera from the eye position and look-at target position.
- Parameters:
- Raises:
RuntimeError – If the camera prim is not set. Need to call
initialize()method first.NotImplementedError – If the stage up-axis is not “Y” or “Z”.
- cfg: MultiMeshRayCasterCameraCfg#
The configuration parameters.