../_images/tiago-icon.png ../_images/tiagopro-icon.png ../_images/ari-icon.png

Tutorial: Deploying ROS packages on the robot#

🏁 Goal of this tutorial

By the end of this tutorial, you will know how to deploy ROS packages on a PAL’s robots robot.

This tutorial contains a brief introduction to the deploy script PAL Robotics provides with the development environment.

The deploy tool can be used to:

  • Install new software onto the robot

  • Modify the behaviour of existing software packages by installing a newer version and leaving the original installation untouched.

The deploy tool#

When PAL’s robots boots up it always adds two sources of packages to its ROS environment. One is the ROS software distribution of PAL Robotics at /opt/pal/gallium/, the other is a fixed location at /home/pal/deployed_ws, which is where the deploy tool installs to. This location precedes the rest of the software installation, making it possible to overlay previously installed packages.

To maintain consistency with the ROS release pipeline, the deploy tool uses the install rules in the CMakeLists.txt of every catkin package. Make sure that everything you need on the robot is declared to be installed.

Usage#

 1 usage: deploy.py [-h] [--user USER] [--yes] [--package PKG]
 2                       [--install_prefix INSTALL_PREFIX]
 3                       [--cmake_args CMAKE_ARGS]
 4                       robot
 5 Deploy built packages to a robot. The default behavior is to deploy *all*
 6 packages from any found workspace. Use --package to only deploy a single package.
 7 positional arguments:   robot
 8                 hostname to deploy to (e.g. tiago-0c)
 9 optional arguments:
10     -h, --help            show this help message and exit
11     --user USER, -u USER  username (default: pal)
12     --yes, -y             don\'t ask for confirmation, do it
13     --package PKG, -p PKG deploy a single package
14     --install_prefix INSTALL_PREFIX, -i INSTALL_PREFIX
15                         Directory to deploy files
16     --cmake_args CMAKE_ARGS, -c CMAKE_ARGS
17                         Extra cmake args like
18                         --cmake_args=\"-DCMAKE_BUILD_TYPE=Release\"
19 e.g.: deploy.py ari-0c -u root -p pal_tts -c=\"-DCMAKE_BUILD_TYPE=Release\"

Notes#

  • The build type by default is not defined, meaning that the compiler will use the default C++ flags. This is likely to include -O2 optimization and -g debug information, meaning that, in this mode, executables and libraries will go through optimization during compilation and will therefore have no debugging symbols. This behaviour can be changed by manually specifying a different option such as: --cmake_args="-DCMAKE_BUILD_TYPE=Debug"

  • Different flags can also be set by chaining them: --cmake_args="-DCMAKE_BUILD_TYPE=Debug -DPCL_ONNURBS=1"

  • If an existing library is overlayed, executables and other libraries which depend on this library may break. This is caused by ABI / API incompatibility between the original and the overlaying library versions. To avoid this, is it recommended to simultaneously deploy the packages that depend on the changed library.

  • There is no tool to remove individual packages from the deployed workspace except to delete the /home/pal/deployed_ws folder altogether.

Deploy tips#

  • You can use an alias ( you may want to add it to your .bashrc) to ease the deploy process:

alias deploy="rosrun pal_deploy deploy.py"
  • You can omit the --user pal as it is the default argument

  • You may deploy a single specific package instead of the entire workspace:

deploy -p hello_world ari-0c
  • You can deploy multiple specific packages instead of the entire workspace:

deploy -p "hello_world other_local_package more_packages" ari-0c
  • Before deploying you may want to do a backup of your previous ~/deployed_ws in the robot to be able to return to your previous state, if required.

Tutorial: deploying code to the robot from the Developer Docker image#

First, follow the same steps as described in Tutorial: Build and run a new ROS package, and make sure your Developer Docker image is installed and available.

Run the SDK Docker image, mounting the newly created workspace, as explained in the Tutorial: Build and run a new ROS package section. Make sure to map the workspace properly.

./pal_docker.sh -it -v ~/docker_mounts/gallium:/home/user/ -v /home/user/example_ws:/home/user/example_ws/ PATH_TO_YOUR_DOCKER_IMAGE bash

In the docker, load the ROS environment (you may add the following instruction to the ~.bashrc)

source /opt/pal/gallium/setup.bash

Deploy the package to the robot:

cd ~/example_ws
export ROS_MASTER_URI=http://ari-0c:11311
rosrun pal_deploy deploy.py --user pal ari-0c

The deploy tool will build the entire workspace in a separate path and, if successful, it will request confirmation in order to install the package on the robot, as shown in the figure below.

../_images/hello_world_deploy_1.png

Press Y so that the package files are installed on the robot computer.

../_images/Hello_world_deploy_2.png

Then connect to the robot:

ssh pal@ari-0c

And run the new node as follows. For C++:

rosrun hello_world hello_world_node

For Python:

rosrun hello_world hello_world.py

If everything goes well you should see Hello world printed on the screen. From the docker check the message is correctly published:

export ROS_MASTER_URI=http://ari-0c:11311
rostopic echo /hello
../_images/hello_echo.png