> ## 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.

# Develop a sample ROS2 application

This information describes how to use the QIR SDK toolchain to compile a simple ROS 2 sample application. The demos and code for both Python and C++ development are available as examples.

## Install the prebuilt QIR SDK on the host computer

Before you begin, download and extract the **QIR SDK** package as described in [Download the prebuilt packages](https://dragonwingdocs.qualcomm.com/archives/2.0/SDKs/QIR-SDK-2.0/download-the-prebuilt-packages.md). Use the QIR SDK package under `qirpsdk_artifacts`; do not use the robotics eSDK under `sdk/`, which is for rebuilding the robotics image.

On the host computer, go to the QIR SDK artifacts directory and decompress the QIR SDK archive:

```shell theme={null}
cd <decompressed_workspace>/images/iq-9075-evk/qirpsdk_artifacts/iq-9075-evk
tar -zxvf qirp-sdk_<qirp_version>.tar.gz
```

This command generates the `qirp-sdk` directory. `QIR SDK` is the product name; `qirp-sdk_<qirp_version>.tar.gz`, `qirpsdk_artifacts`, and `qirp-sdk` are the package and directory names used by the delivered artifacts.

> [!NOTE]
>
> **Note**
>
> * The `qirp-sdk_<qirp_version>.tar.gz` is located in the deployed path of QIR artifacts. The `<qirp_version>` changes with each release, such as 2.0.0, 2.0.1. For example, the complete package name can be `qirp-sdk_2.7.0.tar.gz`.
> * For all released versions, see [Qualcomm® Intelligent Robotics SDK (QIR SDK) 2.0 Release Notes](../../Key-Documents/QIR-SDK-Release-Notes/).
> * The QIR SDK supports these development kits for Qualcomm Linux:
>   | **Development kit** | **Machine name** |
>   | :-: | :-: |
>   | Qualcomm Dragonwing<sup>TM</sup> IQ-9075 EVK | `iq-9075-evk` |
>   | Qualcomm Dragonwing<sup>TM</sup> IQ-8275 EVK | `iq-8275-evk` |

## Develop applications using the QIR SDK

1. Set up the QIR SDK cross-compile environment from the extracted `qirp-sdk` directory.
   ```shell theme={null}
   cd <decompressed_workspace>/images/iq-9075-evk/qirpsdk_artifacts/iq-9075-evk/qirp-sdk
   source setup.sh
   ```
2. Fetch the project as the code baseline.
   ```shell theme={null}
   git clone https://github.com/ros2/demos.git -b jazzy
   ```
3. Develop your own application either in C++ or Python.

   > [tab] Develop ROS application using C++
   >
   > 1. Develop your own C++ application. The following is an example.
   >    ```powershell theme={null}
   >    cd demos/demo_nodes_cpp
   >    vim src/topics/talker.cpp +46
   >    ```
   >    Change the `demo_nodes_cpp/src/topics/talker.cpp` msg data in line `46`:
   >    ```cpp talker.cpp icon="code" theme={null}
   >    msg_->data = "Hello World : Qualcomm : " + std::to_string(count_++);
   >    ```
   > 2. Set the necessary environment variables and use the colcon tool to build the ROS2 package demo\_nodes\_cpp and its dependencies.
   >    ```powershell theme={null}
   >    colcon build --merge-install --packages-up-to demo_nodes_cpp --cmake-args ${CMAKE_ARGS}
   >    ```
   > 3. Push the demo to the device.
   >    ```powershell theme={null}
   >    cd demo_nodes_cpp/install
   >    tar -czvf demo_nodes_cpp.tar.gz lib share
   >    scp demo_nodes_cpp.tar.gz root@[ip-addr]:/opt/
   >    ssh root@[ip-addr]
   >    (ssh) mount -o remount,rw /usr
   >    (ssh) tar --no-overwrite-dir --no-same-owner -zxf /opt/demo_nodes_cpp.tar.gz -C /usr/ros/jazzy/
   >    ```
   > 4. Run the demo application on the device.
   >
   >    i. On the first terminal, run these commands:
   >
   >    ```shell theme={null}
   >    (ssh) source /usr/share/qirp-setup.sh
   >    (ssh) ros2 run demo_nodes_cpp talker
   >    ```
   >
   >    ii. On the second terminal, run these commands:
   >
   >    ```shell theme={null}
   >    (ssh) source /usr/share/qirp-setup.sh
   >    (ssh) ros2 run demo_nodes_cpp listener
   >    ```
   > 5. Check the output.
   >
   >    Terminal 1 output:
   >
   >    ```shell theme={null}
   >
   >    [INFO] [1739864779.759719598] [talker]: Publishing: 'Hello World : Qualcomm : 1'
   >    [INFO] [1739864780.759687179] [talker]: Publishing: 'Hello World : Qualcomm : 2'
   >    [INFO] [1739864781.760812014] [talker]: Publishing: 'Hello World : Qualcomm : 3'
   >    ...
   >    ```
   >
   >    Terminal 2 output:
   >
   >    ```shell theme={null}
   >
   >    [INFO] [1739864779.760348380] [listener]: I heard: [Hello World : Qualcomm : 1]
   >    [INFO] [1739864780.760276535] [listener]: I heard: [Hello World : Qualcomm : 2]
   >    [INFO] [1739864781.762066296] [listener]: I heard: [Hello World : Qualcomm : 3]
   >    ...
   >
   >    ```

   > [tab] Develop ROS application using Python
   >
   > 1. Develop your own Python application. The following is an example.
   >    ```powershell theme={null}
   >    cd demos/demo_nodes_py
   >    vim demo_nodes_py/topics/talker.py +33
   >    ```
   >    Change the `demo_nodes_py/topics/talker.py` msg data in line `33`:
   >    ```python talker.py icon="python" theme={null}
   >    msg.data = 'Hello World : Qualcomm : {0}'.format(self.i)
   >    ```
   > 2. Set the necessary environment variables and use the colcon tool to build the ROS 2 package demo\_nodes\_py and its dependencies.
   >    ```powershell theme={null}
   >    colcon build --merge-install --packages-up-to demo_nodes_py
   >    ```
   > 3. Push the demo to the device.
   >    ```powershell theme={null}
   >    cd demo_nodes_py/install
   >    tar -czvf demo_nodes_py.tar.gz lib share
   >    scp demo_nodes_py.tar.gz root@[ip-addr]:/opt/
   >    ssh root@[ip-addr]
   >    (ssh) mount -o remount,rw /usr
   >    (ssh) tar --no-overwrite-dir --no-same-owner -zxf /opt/demo_nodes_py.tar.gz -C /usr/ros/jazzy/
   >    ```
   > 4. Run the demo application on the device.
   >
   >    i. On the first terminal, run these commands:
   >
   >    ```shell theme={null}
   >    (ssh) export HOME=/home
   >    (ssh) source /usr/share/qirp-setup.sh
   >    (ssh) ros2 run demo_nodes_py talker
   >    ```
   >
   >    ii. On the second terminal, run these commands:
   >
   >    ```shell theme={null}
   >    (ssh) export HOME=/home
   >    (ssh) source /usr/share/qirp-setup.sh
   >    (ssh) ros2 run demo_nodes_py listener
   >    ```
   > 5. Check the output.
   >
   >    Terminal 1 output:
   >
   >    ```shell theme={null}
   >    [INFO] [1739864779.759719598] [talker]: Publishing: 'Hello World : Qualcomm : 1'
   >    [INFO] [1739864780.759687179] [talker]: Publishing: 'Hello World : Qualcomm : 2'
   >    [INFO] [1739864781.760812014] [talker]: Publishing: 'Hello World : Qualcomm : 3'
   >    ...
   >    ```
   >
   >    Terminal 2 output:
   >
   >    ```shell theme={null}
   >    [INFO] [1739864779.760348380] [listener]: I heard: [Hello World : Qualcomm : 1]
   >    [INFO] [1739864780.760276535] [listener]: I heard: [Hello World : Qualcomm : 2]
   >    [INFO] [1739864781.762066296] [listener]: I heard: [Hello World : Qualcomm : 3]
   >    ...
   >
   >    ```
