Improve support for lidar data
Is your feature request related to a problem? Please describe. Lidar data is quite similar to back-projected depth maps, so it would be nice to support distance-based color maps that can be changed from inside the viewer.
Raw lidar data often comes in terms of angles, distances, and per-point timestamps; processed data (projected and potentially motion compensated) typically comes as 3D point clouds in the sensor frame + sensor pose. I believe the latter would be more important to support directly.
Similar ideas apply to, for example, radar data; so maybe it would make sense to name the archetype in a more general way than just LidarScan.
Things I'm unsure of
- I suspect raw lidar data might come in lots of different formats and conventions (i.e., how to interpret the angles to retrieve the 3D point); hence, just supporting 3D points in the sensor frame might be sufficient
- similar to most sensors, I think the sensor pose should be the closest available transform in time not the latest, but that's a separate issue #1522
- Should the sensor pose be logged as a transform or should there be an option to log it as part of the sensor scan? Maybe best to support both for simplicity; however, in that case, it's important that both cases behave the same way.
- It's probably worth checking a few lidars and what data they provide (I know about return number and intensity, but maybe there's more)
Describe the solution you'd like
Add a LidarScan archetype (or something more general like RangeScan maybe) that takes 3D points and supports different color maps based on the Euclidean distance to the scan origin.
Specifically for lidar, special per-point values that might be nice to support are the return number (integer) and intensity (float).
It would be nice if the color map input could be changed between distance / return number / intensity / x-value / ...
Describe alternatives you've considered It's already possible to log lidar scans as points, but the color map has to be calculated manually and can't be changed from inside the viewer.
I found link to this issue in lidar example and it uses matplotlib for colormaps. There is colormap python lib that has single dependency on numpy: cmap (no need to install whole matplotlib). Code example to colorize lidar cloud by distance from origin in rainbow colors using cmap:
import rerun as rr
import numpy as np
from cmap import Colormap
def colorize_radial(pc: np.ndarray):
r_dist = np.linalg.norm(pc, axis=1)
r_norm = (r_dist - r_dist.min()) / (r_dist.max() - r_dist.min())
cmap = Colormap("yorick:rainbow")
return cmap(r_norm)
if __name__ == "__main__":
rr.init("lidar", spawn=True)
cloud = np.array(...) # load (n,3) point cloud
colors = colorize_radial(cloud)
rr.log("cloud", rr.Points3D(cloud, colors=colors, radii=0.01), static=True)
There are a lot colormaps in cmap that can be used as reference for native support in rerun if needed.