> ## 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 `to the host computer

On the host computer, go to the artifacts directory and decompress `QIR SDK` using the `tar` command:

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

This command generates the `qirp-sdk` directory.

<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`  |
</Note>

## Using QIR SDK to develop applications

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

   <Tabs>
     <Tab title="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`:
          ```powershell 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/
          ```
       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>

     <Tab title="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`:
          ```powershell 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/
          ```
       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/bin/ros_setup.sh && 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/bin/ros_setup.sh && 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]
          ...

          ```
     </Tab>
   </Tabs>
