11. Publish RTX Lidar Point Cloud

RTX or Raytraced lidar is an alternative to the PhysX lidar in Isaac Sim. It supports both Solid State and Rotating Lidar configuration via a JSON config file. Each RTX Sensor must be attached to its own viewport to simulate properly.

11.1. Learning Objectives

In this example, we will

  • Have a brief introduction on how to use RTX Lidar sensors

  • Create a RTX Lidar sensor

  • Publish sensor data to ROS2 as a PointCloud2 message

Prerequisites

  • Completed the ROS2 ROS2 Cameras tutorial.

  • FASTRTPS_DEFAULT_PROFILES_FILE environmental variable is set prior to launching sim, and ROS2 bridge is enabled.

11.2. Create RTX Lidar and Publish Lidar data over ROS:

  1. On a clean stage, add a few objects in the scene (eg Cone and cube, keep them away from the origin)

  2. Create a Rotating RTX Lidar sensor: Create->Isaac->Sensors->RTX Lidar->Rotating

  3. Create Visual Scripting->Action Graph. Next, add the following nodes to this graph:

    1. On Playback Tick: This is the node responsible for triggering all the other nodes once Play is pressed.

    2. Isaac Create Render Product: In the input camera prim select the RTX lidar created in step 2.

    3. ROS2 RTX Lidar Helper: This node will handle publishing of the laser scan message from the rtx lidar. The input render product is obtained from the output of Isaac Create Render Product in step b.

    4. ROS2 RTX Lidar Helper: This node will handle publishing the point cloud from the rtx lidar. Under input type select point_cloud and change the topic name to point_cloud. The input render product is obtained from the output of Isaac Create Render Product in step b.

    Action Graph Layout

Once the graph has been set correctly, hit Play` to begin simulation. The RTX lidar should be sending the LaserScan and PointCloud2 messages and can be visualized in RViZ.

For RViZ visualization:

  1. Run RViZ2 (rviz2) in a sourced terminal.

  2. Set fixed frame as sim_lidar

  3. Add LaserScan visualization and set topic to /scan

  4. Add PointCloud2 visualization and set topic to /point_cloud

    RViZ Visualization for RTX Lidar

11.3. Running The Example

  • In a new terminal with your ROS2 environment sourced, run rviz2 -d ros2_workspace/src/isaac_tutorials/rviz2/rtx_lidar.rviz to start rviz and show the lidar point cloud

  • Finally, run the sample script

    ./python.sh standalone_examples/api/omni.isaac.ros2_bridge/rtx_lidar.py
    

Once the scene finishes loading you should see the point cloud for the rotating lidar sensor being simulated

11.4. RTX Lidar Script sample

While most of the sample code is faily generic, there are a few specific pieces needed to create and simulate the sensor

We first need to create the RTX Lidar Sensor

_, sensor = omni.kit.commands.execute(
    "IsaacSensorCreateRtxLidar",
    path="/sensor",
    parent=None,
    config="Example_Rotary",
    translation=(0, 0, 1.0),
    orientation=Gf.Quatd(0.5, 0.5, -0.5, -0.5),
)

Here Example_Rotary defines the configuration for the lidar sensor. The two generic configuration files provided are located in exts/omni.drivesim.sensors.nv.lidar/data. Example_Rotary.json and Example_Solid_State.json. To switch the lidar to the example solid state configuration you can replace config=”Example_Rotary”, with config=”Example_Solid_State”.

Next, we need create a render product and attach this sensor to it

_, render_product_path = create_hydra_texture([1, 1], sensor.GetPath().pathString)

We can then create the post process pipeline that takes the rendered RTX Lidar data and publishes it to ROS:

sensors.get_synthetic_data().activate_node_template("RtxLidar" + "ROS2PublishPointCloud", 0, [render_product_path])

Note

You can specify an optional attributes={…} dictionary when calling activate_node_template to set node specific parameters. See the API Documentation for complete usage information.

11.5. Summary

This tutorial covered creating and using the RTX Lidar Sensor with ROS2.