Cannot set input parameter `outputObjectId` in Annotator `RtxSensorCpuIsaacCreateRTXLidarScanBuffer`

Hello folks,

I am trying to save some pointcloud using a custom writer, where I want to save the complete scan of the pointcloud and the 3d bounding boxes for the objects having atleast 50 hit points from the lidar.

Below is the code where I am trying to get the objects Ids from the Annotator RtxSensorCpuIsaacCreateRTXLidarScanBuffer. As mentioned here, I am trying to set the outputObjectId to True but for some reason I cannot get the node to update the value and hence I always get the objectId array to be empty.

Below is the code for my writer:

import omni.usd
import omni.replicator.core as rep
from omni.replicator.core import Writer, AnnotatorRegistry, BackendDispatch

class PointCloudWriter(Writer):
    def __init__(self, output_dir):
        self._output_dir = output_dir
        self._backend = BackendDispatch({"paths": {"out_dir": output_dir}})
        self._frame_id = 0

        self.annotators = [
            AnnotatorRegistry.get_annotator(
                "RtxSensorCpuIsaacCreateRTXLidarScanBuffer",
                init_params={
                    "transformPoints": False,
                    "outputObjectId": True,
                },
            )
        ]

    def write(self, data):
        # rtx_lidar_data = data["RtxSensorCpuIsaacReadRTXLidarData"]
        rtx_lidar_data = data["RtxSensorCpuIsaacCreateRTXLidarScanBuffer"]
        print("RTX LIDAR DATA")
        print(rtx_lidar_data)
        self._frame_id += 1

The output:

RTX LIDAR DATA
{'azimuth': array([], dtype=float64), 'beamId': array([], dtype=float64), 'data': array([[ 4.4774494e+01,  1.0918704e+00, -1.3677580e+00],
       [ 3.1891663e+01,  2.3458719e+00, -1.3677565e+00],
       [ 1.7050253e+01,  4.1877291e-01, -1.3677613e+00],
       ...,
       [ 1.4610153e+00, -2.7388211e-02, -1.3677599e+00],
       [ 1.4254761e+00,  4.2956349e-02, -1.3677679e+00],
       [ 1.3883824e+00,  1.1087897e-01, -1.3677622e+00]], dtype=float32), 'distance': array([44.808685 , 32.00706  , 17.110151 , ...,  2.0015202,  1.9760102,
        1.9520946], dtype=float32), 'elevation': array([], dtype=float64), 'emitterId': array([], dtype=float64), 'index': array([   132,    134,    140, ..., 262138, 262140, 262142], dtype=uint32), 'intensity': array([0.01510742, 0.01578566, 0.0179886 , ..., 0.01819391, 0.02302446,
       0.03828166], dtype=float32), 'materialId': array([], dtype=float64), 'normal': array([], dtype=float64), 'objectId': array([], dtype=float64), 'timestamp': array([], dtype=float64), 'velocity': array([], dtype=float64), 'info': {'numChannels': 128, 'numEchos': 2, 'numReturnsPerScan': 262144, 'renderProductPath': '/Render/RenderProduct_Lidar', 'ticksPerScan': 1024, 'transform': array([ 0.99937255, -0.03541888, -0.        ,  0.        ,  0.03541888,
        0.99937255,  0.        ,  0.        ,  0.        , -0.        ,
        1.        ,  0.        ,  1.24622905, -0.97593123,  1.36775899,
        1.        ])}}

Also, It would be great if anyone can suggest any better solutions.
Thank you in advance.

@marmik18 not an expert, but not sure if this post by the mod/dev is relevant?

@Simplychenable Thank you for the related post. That definitely helped.

Unfortunately, it doesn’t work for me. I tried initializing the annotator before I register my writer. Also, I tried passing the same instance of the annotator and still the objectId array is empty.

Please see the class for reference

class SDG:
    def _setup_sdg(self):
        # Disable capture on play and async rendering
        carb.settings.get_settings().set("/omni/replicator/captureOnPlay", False)
        carb.settings.get_settings().set("/omni/replicator/asyncRendering", False)
        carb.settings.get_settings().set("/app/asyncRendering", False)
        self._setup_annotators()
        self._setup_render_products()

    def _setup_annotators(self):
        self._rtx_lidar_scan_buffer_annotater = AnnotatorRegistry.get_annotator(
            "RtxSensorCpuIsaacCreateRTXLidarScanBuffer"
        )
        self._rtx_lidar_scan_buffer_annotater.initialize(outputObjectId=True)
        

    def _setup_render_products(self):
        rp_lidar = rep.create.render_product(
            self._lidar.GetPath(), (1, 1), name="Lidar"
        )
        self._render_products = [rp_lidar]

        if self._debug:
            print(f"[{self.__class__.__name__}] Setting up debug render products")

            # Create a Replicator Writer that "writes" points into the scene for debug viewing
            writer = rep.writers.get("RtxLidarDebugDrawPointCloudBuffer")
            writer.attach([rp_lidar])

            # Create Point cloud publisher pipeline in the post process graph
            writer = rep.writers.get("RtxLidar" + "ROS2PublishPointCloud")
            writer.initialize(topicName="point_cloud", frameId="sim_lidar")
            writer.attach([rp_lidar])

        rep.WriterRegistry.register(PointCloudWriter)
        self._writer = rep.WriterRegistry.get("PointCloudWriter")
        self._writer.initialize(
            output_dir=os.path.join(
                config.sdg_config.output_dir,
                datetime.now().strftime("%Y-%m-%d_%H-%M-%S"),
                "lidar",
            ),
            lidar_annotator=self._rtx_lidar_scan_buffer_annotater
        )

        self._writer.attach(self._render_products)

        rep.orchestrator.preview()