I have been able to view 2d lidar data in rviz using the ros_bridge what i want to do is to visualize 3d lidar points in rviz.
what i am trying to do is to create a python script that reades the 3d data from omni isaac lidar and make a custom ros publisher
i can run the python code in the isaac sim code editor but as the isaac sim is running in an aws instance it can only be runned in headless mode.
so not able to use the menu to open or save python scripts and as the clipboard is not supported yet its been really tedious to write code and the code getting erased if isaac sim crashes.
i think there is a really simple workaround but not able to find anything helpful on the internet.
An alternative to run your code is to develop it as a custom Extension. One of the advantages of this approach is that any modification of the code will be automatically reloaded by the Extension Discovery system. Also, the code will persist, even to possible Isaac Sim crashes.
Following your answer, I was able to run my python script as an extension and was able to read lidar data from isaac simulation.
just one more thing i am not able to do “import rospy” in my script
as i understand isaac-sim is using its own python installation
i have tried to add ros to python path using sys.path(“path to ros installlation”) but still not able to get it to work.
really sorry to bother you once again.
following your advice i was able to send data using ros message and view it rviz.
the problem i am having right now is that the point cloud that is been shown is not accurate.
i am using the following code to get x,y,z coordinates using depth, zenith and azimuth data from the isaac lidar. But as you can see in the attached screen shots it is rotated 90 degree and also curved along the sides.
It seems to be the zenith data provided by lidar is respect to XY-plane and not Z-axis, Then, taking this into account you can use the next equations to generate the 3D point cloud
x = depth * sin(π/2 - zenith) * cos(azimuth)
y = depth * sin(π/2 - zenith) * sin(azimuth)
z = depth * cos(π/2 - zenith)
Also, you can verify them using the next code that generate the data shown in the figure
from omni.isaac.lidar import _lidar
from omni.add_on.visualizer import _visualizer
import numpy as np
# lidar interface
lidarInterface = _lidar.acquire_lidar_interface()
lidarPath = "/World/Lidar"
# get lidar data
depth = lidarInterface.get_depth_data(lidarPath) / 65535
zenith = np.pi / 2 - lidarInterface.get_zenith_data(lidarPath)
azimuth = lidarInterface.get_azimuth_data(lidarPath)[:,np.newaxis]
# compute x,y,z
x = (depth * np.sin(zenith) * np.cos(azimuth)).flatten()
y = (depth * np.sin(zenith) * np.sin(azimuth)).flatten()
z = (depth * np.cos(zenith)).flatten()
# get valid x,y,z (where lidar line traces interact with the objects)
indexes = np.where(depth.flatten() < 1)[0]
x = x[indexes]
y = y[indexes]
z = z[indexes]
# show point cloud
fxy = _visualizer.figure("XY")
fyz = _visualizer.figure("YZ")
fxz = _visualizer.figure("XZ")
fxy.scatter(x, y, aspect="equal")
fyz.scatter(y, z, aspect="equal")
fxz.scatter(x, z, aspect="equal")
_visualizer.scatter3d(x, y, z)
this worked and am able to get proper point cloud and visualize in rviz.
Nvidia should really put this in documentation or something, @toni.sm you have really been great help.
just one thing i don’t seem to have omni.add_on.visualizer in my installation
by the name of it, i think its an addon? how can i get it
omni.add_on.visualizer is an extension I created to generate and show graphic data in an easy way… You can find it on GitHub (Any feedback will be welcome):