> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate ROS component performance with qrb_ros_benchmark

> qrb_ros_benchmark is a benchmarking tool designed for evaluating the performance of ROS components on Qualcomm robotics platforms. It provides reusable components for benchmarking various message types and ROS nodes, with a focus on zero-copy transport mechanisms.

`qrb_ros_benchmark` builds on [ros2\_benchmark](https://github.com/NVIDIA-ISAAC-ROS/ros2_benchmark) and extends it with specialized components for benchmarking QRB ROS transport types, including:

* QRB transport types (Image, IMU, PointCloud2)

* DMABuf transport types (Image, PointCloud2)

* Standard ROS message types

## Software structure

The following figure shows the software structure of `qrb_ros_benchmark`.

<Frame caption="Software structure of qrb_ros_benchmark.">
  <img src="https://mintcdn.com/qualcomm-prod/EDJV-hu6qJhZi4pm/SDKs/QIR-SDK-Ubuntu/images/image22.png?fit=max&auto=format&n=EDJV-hu6qJhZi4pm&q=85&s=dc8ce26ef5c3db66a9691174e6dbe97a" alt="Layered stack with the QRB ROS benchmark monitor and playback nodes above the ROS2 benchmark nodes, QRB transport components, and ROS2." width="550" height="430" data-path="SDKs/QIR-SDK-Ubuntu/images/image22.png" />
</Frame>

The basic usage is similar to [ros2\_benchmark](https://github.com/NVIDIA-ISAAC-ROS/ros2_benchmark) and the following are the exclusive message types supported by `qrb_ros_benchmark`:

**QRB transport types:**

* `qrb_ros/transport/type/Image`

* `qrb_ros/transport/type/Imu`

* `qrb_ros/transport/type/PointCloud2`

* `qrb_ros_tensor_list_msgs::msg::TensorList`

**DMABuf transport types:**

* `dmabuf_transport/type/Image`

* `dmabuf_transport/type/PointCloud2`

## Prerequisites

You have set up the device, installed ROS2 Jazzy and the Qualcomm Intelligent Robotics (QIR) SDK on the device according to [Install the QIR SDK](./install-the-qir-sdk).

## Run out-of-the-box `qrb_ros_benchmark`

<Steps>
  <Step title="Install the qrb_ros_benchmark packages">
    ```bash Install the packages theme={null}
    sudo apt install ros-jazzy-qrb-ros-benchmark
    ```
  </Step>

  <Step title="Create a minimum template for evaluating qrb_ros/transport/type/Image">
    ```bash Create the launch file theme={null}
    vim qrb-ros-transport-image-type_launch.py
    ```

    <Accordion title="qrb-ros-transport-image-type_launch.py">
      ```python qrb-ros-transport-image-type_launch.py theme={null}
        from launch_ros.actions import ComposableNodeContainer
        from launch_ros.descriptions import ComposableNode
        from ros2_benchmark import ImageResolution
        from ros2_benchmark import ROS2BenchmarkConfig, ROS2BenchmarkTest
        def launch_setup(container_prefix, container_sigterm_timeout):
            data_loader_node = ComposableNode(
                name='DataLoaderNode',
                namespace=TestQrbNode.generate_namespace(),
                package='ros2_benchmark',
                plugin='ros2_benchmark::DataLoaderNode',
            )
            # QrbPlaybackNode
            playback_node = ComposableNode(
                name='QrbPlaybackNode',
                namespace=TestQrbNode.generate_namespace(),
                package='qrb_ros_benchmark',
                plugin='qrb_ros::benchmark::QrbPlaybackNode',
                parameters=[{
                    'data_formats': [
                        'qrb_ros/transport/type/Image'
                    ],
                }],
                remappings=[
                    ('buffer/input0', '/data_loader_image'),
                    ('input0', '/playback_image')
                ]
            )
            # Insert QRB ROS nodes
            # QrbMonitorNode
            monitor_node = ComposableNode(
                name='QrbMonitorNode',
                namespace=TestQrbNode.generate_namespace(),
                package='qrb_ros_benchmark',
                plugin='qrb_ros::benchmark::QrbMonitorNode',
                parameters=[{
                    'monitor_data_format': 'qrb_ros/transport/type/Image',
                }]
            )
            composable_node_container = ComposableNodeContainer(
                name='container',
                namespace=TestQrbNode.generate_namespace(),
                package='rclcpp_components',
                executable='component_container_mt',
                prefix=container_prefix,
                sigterm_timeout=container_sigterm_timeout,
                composable_node_descriptions=[
                    data_loader_node,
                    playback_node,
                    monitor_node,
                    # Insert QRB ROS nodes
                ],
                output='screen'
            )
            return [composable_node_container]
        def generate_test_description():
            return TestQrbNode.generate_test_description_with_nsys(launch_setup)
        class TestQrbNode(ROS2BenchmarkTest):
            config = ROS2BenchmarkConfig(
                benchmark_name='Qrb_ros_transport image Test Benchmark',
                input_data_path='/path/to/rosbag',
                publisher_upper_frequency=100.0,
                publisher_lower_frequency=10.0,
                playback_message_buffer_size=10
            )
            def test_benchmark(self):
                self.run_benchmark()
      ```
    </Accordion>
  </Step>

  <Step title="Start the qrb-ros-transport-image-type benchmark">
    ```bash Start the benchmark theme={null}
    source /opt/ros/jazzy/setup.bash
    launch_test qrb-ros-transport-image-type_launch.py
    ```
  </Step>
</Steps>

## Build from source

<Steps>
  <Step title="Install dependencies">
    ```bash Install the dependencies theme={null}
    sudo apt install ros-jazzy-qrb-ros-transport-image-type
    ```
  </Step>

  <Step title="Download the source code and build with colcon">
    ```bash Clone the repositories and build theme={null}
    mkdir -p ~/ros-ws/src
    cd ~/ros-ws/src
    git clone https://github.com/qualcomm-qrb-ros/ros2_benchmark.git
    git clone https://github.com/qualcomm-qrb-ros/qrb_ros_transport.git
    git clone https://github.com/qualcomm-qrb-ros/lib_mem_dmabuf.git
    git clone https://github.com/qualcomm-qrb-ros/qrb_ros_imu.git
    git clone https://github.com/qualcomm-qrb-ros/dmabuf_transport.git
    git clone https://github.com/qualcomm-qrb-ros/qrb_ros_benchmark.git
    cd ~/ros-ws/
    colcon build
    ```
  </Step>

  <Step title="Run and debug">
    ```bash Source the workspace theme={null}
    source install/setup.bash
    ```
  </Step>

  <Step title="Run the qrb-ros-benchmark">
    Run the `qrb-ros-benchmark` according to step 2 of [Run out-of-the-box `qrb_ros_benchmark`](./evaluate-ros-component-performance-with-qrb_ros_benchmark#run-out-of-the-box-qrb_ros_benchmark).
  </Step>
</Steps>
