Skip to content

Commit 91d3c20

Browse files
pascal-rothmohanksriram
authored andcommitted
Adds lidar pattern for raycaster sensor (isaac-sim#616)
# Description Add a lidar pattern for the `RayCaster` sensor. The pattern is determined by number of channels, horizontal and vertical field of view and corresponding horizontal resolution. An example config for a Velodyne VLP 16 is provided. ## Type of change - New feature (non-breaking change which adds functionality) ## Screenshots ![Screenshot from 2024-07-02 10-13-45](https://github.com/isaac-sim/IsaacLab/assets/57946385/31c87608-9d4d-4a11-9ad5-1ced954aa750) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.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
1 parent c05a279 commit 91d3c20

File tree

8 files changed

+128
-3
lines changed

8 files changed

+128
-3
lines changed

docs/source/api/lab/omni.isaac.lab.sensors.patterns.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@ RS-Bpearl Pattern
4949
:members:
5050
:inherited-members:
5151
:exclude-members: __init__, func
52+
53+
LiDAR Pattern
54+
-------------
55+
56+
.. autofunction:: omni.isaac.lab.sensors.patterns.lidar_pattern
57+
58+
.. autoclass:: LidarPatternCfg
59+
:members:
60+
:inherited-members:
61+
:exclude-members: __init__, func

source/extensions/omni.isaac.lab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.19.0"
4+
version = "0.19.1"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/extensions/omni.isaac.lab/docs/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
0.19.1 (2024-07-05)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Added
8+
^^^^^
9+
10+
* Added a lidar pattern function :func:`~omni.isaac.lab.sensors.ray_caster.patterns.patterns.lidar_pattern` with
11+
corresponding config :class:`~omni.isaac.lab.sensors.ray_caster.patterns_cfg.LidarPatternCfg`.
12+
13+
414
0.19.0 (2024-07-04)
515
~~~~~~~~~~~~~~~~~~~
616

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/ray_caster/patterns/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
"""Sub-module for ray-casting patterns used by the ray-caster."""
77

8-
from .patterns import bpearl_pattern, grid_pattern, pinhole_camera_pattern
9-
from .patterns_cfg import BpearlPatternCfg, GridPatternCfg, PatternBaseCfg, PinholeCameraPatternCfg
8+
from .patterns import bpearl_pattern, grid_pattern, lidar_pattern, pinhole_camera_pattern
9+
from .patterns_cfg import BpearlPatternCfg, GridPatternCfg, LidarPatternCfg, PatternBaseCfg, PinholeCameraPatternCfg

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/ray_caster/patterns/patterns.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import annotations
77

8+
import math
89
import torch
910
from typing import TYPE_CHECKING
1011

@@ -128,3 +129,49 @@ def bpearl_pattern(cfg: patterns_cfg.BpearlPatternCfg, device: str) -> tuple[tor
128129
ray_directions = -torch.stack([x, y, z], dim=1)
129130
ray_starts = torch.zeros_like(ray_directions)
130131
return ray_starts, ray_directions
132+
133+
134+
def lidar_pattern(cfg: patterns_cfg.LidarPatternCfg, device: str) -> tuple[torch.Tensor, torch.Tensor]:
135+
"""Lidar sensor pattern for ray casting.
136+
137+
Args:
138+
cfg: The configuration instance for the pattern.
139+
device: The device to create the pattern on.
140+
141+
Returns:
142+
The starting positions and directions of the rays.
143+
"""
144+
# Vertical angles
145+
vertical_angles = torch.linspace(cfg.vertical_fov_range[0], cfg.vertical_fov_range[1], cfg.channels)
146+
147+
# If the horizontal field of view is 360 degrees, exclude the last point to avoid overlap
148+
if abs(abs(cfg.horizontal_fov_range[0] - cfg.horizontal_fov_range[1]) - 360.0) < 1e-6:
149+
up_to = -1
150+
else:
151+
up_to = None
152+
153+
# Horizontal angles
154+
num_horizontal_angles = math.ceil((cfg.horizontal_fov_range[1] - cfg.horizontal_fov_range[0]) / cfg.horizontal_res)
155+
horizontal_angles = torch.linspace(cfg.horizontal_fov_range[0], cfg.horizontal_fov_range[1], num_horizontal_angles)[
156+
:up_to
157+
]
158+
159+
# Convert degrees to radians
160+
vertical_angles_rad = torch.deg2rad(vertical_angles)
161+
horizontal_angles_rad = torch.deg2rad(horizontal_angles)
162+
163+
# Meshgrid to create a 2D array of angles
164+
v_angles, h_angles = torch.meshgrid(vertical_angles_rad, horizontal_angles_rad, indexing="ij")
165+
166+
# Spherical to Cartesian conversion (assuming Z is up)
167+
x = torch.cos(v_angles) * torch.cos(h_angles)
168+
y = torch.cos(v_angles) * torch.sin(h_angles)
169+
z = torch.sin(v_angles)
170+
171+
# Ray directions
172+
ray_directions = torch.stack([x, y, z], dim=-1).reshape(-1, 3).to(device)
173+
174+
# Ray starts: Assuming all rays originate from (0,0,0)
175+
ray_starts = torch.zeros_like(ray_directions).to(device)
176+
177+
return ray_starts, ray_directions

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/ray_caster/patterns/patterns_cfg.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,22 @@ class BpearlPatternCfg(PatternBaseCfg):
122122
We manually set the vertical ray angles to match the Bpearl sensor. The ray-angles
123123
are not evenly spaced.
124124
"""
125+
126+
127+
@configclass
128+
class LidarPatternCfg(PatternBaseCfg):
129+
"""Configuration for the LiDAR pattern for ray-casting."""
130+
131+
func: Callable = patterns.lidar_pattern
132+
133+
channels: int = MISSING
134+
"""Number of Channels (Beams). Determines the vertical resolution of the LiDAR sensor."""
135+
136+
vertical_fov_range: tuple[float, float] = MISSING
137+
"""Vertical field of view range in degrees."""
138+
139+
horizontal_fov_range: tuple[float, float] = MISSING
140+
"""Horizontal field of view range in degrees."""
141+
142+
horizontal_res: float = MISSING
143+
"""Horizontal resolution (in degrees)."""

source/extensions/omni.isaac.lab_assets/omni/isaac/lab_assets/anymal.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
import omni.isaac.lab.sim as sim_utils
2323
from omni.isaac.lab.actuators import ActuatorNetLSTMCfg, DCMotorCfg
2424
from omni.isaac.lab.assets.articulation import ArticulationCfg
25+
from omni.isaac.lab.sensors import RayCasterCfg
2526
from omni.isaac.lab.utils.assets import ISAACLAB_NUCLEUS_DIR
2627

28+
from .velodyne import VELODYNE_VLP_16_RAYCASTER_CFG
29+
2730
##
2831
# Configuration - Actuators.
2932
##
@@ -160,3 +163,13 @@
160163
Since we don't have a publicly available actuator network for ANYmal-D, we use the same network as ANYmal-C.
161164
This may impact the sim-to-real transfer performance.
162165
"""
166+
167+
168+
##
169+
# Configuration - Sensors.
170+
##
171+
172+
ANYMAL_LIDAR_CFG = VELODYNE_VLP_16_RAYCASTER_CFG.replace(
173+
offset=RayCasterCfg.OffsetCfg(pos=(-0.310, 0.000, 0.159), rot=(0.0, 0.0, 0.0, 1.0))
174+
)
175+
"""Configuration for the Velodyne VLP-16 sensor mounted on the ANYmal robot's base."""
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
"""Configuration for Velodyne LiDAR sensors."""
7+
8+
9+
from omni.isaac.lab.sensors import RayCasterCfg, patterns
10+
11+
##
12+
# Configuration
13+
##
14+
15+
VELODYNE_VLP_16_RAYCASTER_CFG = RayCasterCfg(
16+
attach_yaw_only=False,
17+
pattern_cfg=patterns.LidarPatternCfg(
18+
channels=16, vertical_fov_range=(-15.0, 15.0), horizontal_fov_range=(-180.0, 180.0), horizontal_res=0.2
19+
),
20+
debug_vis=True,
21+
max_distance=100,
22+
)
23+
"""Configuration for Velodyne Puck LiDAR (VLP-16) as a :class:`RayCasterCfg`.
24+
25+
Reference: https://velodynelidar.com/wp-content/uploads/2019/12/63-9229_Rev-K_Puck-_Datasheet_Web.pdf
26+
"""

0 commit comments

Comments
 (0)