# Develop a robotic application

The following example provides a general procedure for developing a ROS application using the QIRP SDK, using a ROS2 demo application on GitHub as an example.

**Prerequisites:**

- **Required for all cases**

    Enable `SSH` in ‘Permissive’ mode with the steps mentioned in [Log in using SSH](https://docs.qualcomm.com/bundle/publicresource/topics/80-70017-254/how_to.html#use-ssh).
- **Required when using the prebuilt package**

    - The prebuilt robotics image is flashed, see Flash and install.
    - The prebuilt QIRP SDK is downloaded.

**Steps:**

1. Set up the cross-compile environment.

cd <qirp_decompressed_workspace>/qirp-sdk
        source setup.sh
        Copy to clipboard
2. Fetch the project and write your own code.

    1. Fetch a project from GitHub.

git clone https://github.com/ros2/demos.git -b humble
            cd demos/demo_nodes_cpp
            vim src/topics/talker.cpp
            Copy to clipboard
    2. Develop your own application. The following is a sample.

        Change the `demo_nodes_cpp/src/topics/talker.cpp` msg data in line46, such as changing ‘Hello world’ to ‘get message success’：

46:msg_->data = "get message success " + std::to_string(count_++);
            Copy to clipboard
3. Compile the application.

export AMENT_PREFIX_PATH="${OECORE_TARGET_SYSROOT}/usr;${OECORE_NATIVE_SYSROOT}/usr"
        export PYTHONPATH=${PYTHONPATH}:${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages
        colcon build --merge-install --cmake-args \
         -DPython3_NumPy_INCLUDE_DIR=${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages/numpy/core/include \
         -DCMAKE_STAGING_PREFIX=$(pwd)/install \
         -DCMAKE_PREFIX_PATH=$(pwd)/install/share \
         -DBUILD_TESTING=OFF \
         --packages-up-to demo_nodes_cpp
        Copy to clipboard
4. Push the demo to the device.

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 -zxf /opt/demo_nodes_cpp.tar.gz -C /usr/
        Copy to clipboard
5. Run the demo application on the device.

(ssh) export HOME=/home
        (ssh) source /usr/bin/ros_setup.sh && source /usr/share/qirp-setup.sh
        (ssh shell 1) ros2 run demo_nodes_cpp talker
        (ssh shell 2) ros2 run demo_nodes_cpp listener
        Copy to clipboard

Last Published: Dec 30, 2024

Previous Topic
 
Flash and install Next Topic

QIRP SDK sample applications