Publish multiple RTX LiDAR with ROS2

Isaac Sim version 2022.2.1 & ROS 2 Humble Bridge

I have already completed the tutorials regarding the implementation of a RTX LiDAR and the publication of its point cloud: 12. Publish RTX Lidar Point Cloud — Omniverse IsaacSim latest documentation (nvidia.com)

I have successfully managed to create an environment with one RTX LiDAR and publish its results with ROS2. Now I’ve trying to add an aditional RTX LiDAR to the same environment and publish its results in an additional ROS 2 topic, but I haven’t been able to do it. I haven’t found any example that implements this either.

Is it possible to achieve this or does currently Isaac Sim not support multiple RTX LiDAR and their publication?

Yes, you should be able to create multiple rtx lidar in a scene, although the debug view point cloud node will only show one of those at a time. That’s just because that nodes re-creates the debug points every frame and they are a global resource.

In our next release we have an automated test that runs 8 at once. Here it the body of that test. If you ignore test data recording part, this script should help you create multiple lidar and then clean up their resources afterward before exiting.

    async def benchmark_rtx_lidar(self, n_sensor):
        self.test_run.test_name = f"rtx_lidar_{n_sensor}"
        self.set_phase("loading")
        self.start_runtime()
        scene_path = "/Isaac/Environments/Simple_Warehouse/full_warehouse.usd"
        await self.fully_load_stage(self.assets_root_path + scene_path)
        timeline = omni.timeline.get_timeline_interface()
        hydra_textures = []
        writers = []
        sensors = []
        for i in range(n_sensor):
            lidar_type = "Rotary"
            if i % 2:
                lidar_type = "Solid_State"
            lidar_path = "/World/Rtx" + lidar_type + "Lidar_" + str(i)
            sensor_translation = Gf.Vec3f([-8, 13 + i * 2.0, 2.0])  # these positions are used for full_warehouse.usd
            # make sure to test rotary and solid state together.
            lidar_config = "Example_" + lidar_type

            _, sensor = omni.kit.commands.execute(
                "IsaacSensorCreateRtxLidar",
                path=lidar_path,
                parent=None,
                config=lidar_config,
                translation=sensor_translation,
                orientation=Gf.Quatd(0.5, 0.5, -0.5, -0.5),  # Gf.Quatd is w,i,j,k
            )
            sensors.append(sensor)
            texture, render_product_path = create_hydra_texture([1, 1], sensor.GetPath().pathString)
            hydra_textures.append(texture)
            # Create the post process graph that publishes the render var
            writer = rep.writers.get("Writer" + "IsaacPrintRTXLidarInfo")
            writer.initialize(testMode=True)
            writer.attach([render_product_path])
            writers.append(writer)

            await omni.kit.app.get_app().next_update_async()

        self.stop_runtime()
        await self.store_measurements()

        self.set_phase("benchmark")
        timeline.play()
        self.start_collecting_frametime()

        for _ in range(1 if self.test_mode else TEST_NUM_APP_UPDATES):
            await omni.kit.app.get_app().next_update_async()

        self.stop_collecting_frametime()
        await self.store_measurements()

        timeline.stop()

        for writer in writers:
            writer.detach()
        await omni.kit.app.get_app().next_update_async()

        for sensor in sensors:
            delete_prim(sensor.GetPath())
        await omni.kit.app.get_app().next_update_async()

        for texture in hydra_textures:
            texture = None
        await omni.kit.app.get_app().next_update_async()
1 Like

Thanks, I did manage to create and publish multiple RTX LiDAR. Apparently my problem was that I wasn’t holding to the textures as you do with “hydra_textures”.

On a side note, instead of using the writer you use in your code: “Writer” + “IsaacPrintRTXLidarInfo”, I implemented the wirter used in the stand alone exmaple: “RtxLidar” + “ROS2PublishPointCloud”. In my case, my program wasn’t able to find the one you used, saying it was not in the writers registry. Still, the program managed to work with the other writer.

1 Like