(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Setting up the Environment Loader

Description: How to set up ROS_ENV_LOADER on the PR2

Tutorial Level: BEGINNER

Next Tutorial: Starting up the PR2

Why an Environment Loader?

With the new catkin build system, binaries are built without hardcoded library paths, making the install directory more flexible and setting the stage for ROS to become included in many major linux distributions. Until then, ros is still installed into /opt/ros/fuerte, and this means that more complex environment changes are required than were necessary in the past. The environment loader exists to do that environment setup when performing remote launches.

The PR2 looks for the environment loader scripts in the ROS_ENV_LOADER environment variable.

Simple Usage

If you are only running ROS from debian packages, you can use the default environment loader:

   export ROS_ENV_LOADER=/etc/ros/fuerte/env.sh

Writing the setup scripts

If you have a local ROS overlay, you need to set up a custom environment loader.

The recommended set of setup scripts, assuming your local overlay is in ~/ros, is:

NOTE: Use $HOME instead of ~ in env.sh and setup.sh; ~ is a bash-ism that doesn't work in bourne shell.

  • ~/ros/setup.sh
    •    #!/bin/sh
         . /etc/ros/setup.sh
         export ROS_PACKAGE_PATH="$HOME/ros:$ROS_PACKAGE_PATH"
         export ROS_ENV_LOADER="$HOME/ros/env.sh"
  • ~/ros/env.sh
    •    #!/bin/sh
         
         . $HOME/ros/setup.sh
         if [ $# -eq 0 ] ; then
            $SHELL
         else
            exec "$@"
         fi
  • ~/ros/setup.bash
    •    #!/bin/bash
         CATKIN_SHELL=bash
         . ~/ros/setup.sh
  • ~/.bashrc sources ~/ros/setup.bash or ~/ros/setup.sh

The general concept here is to have one script (~/ros/setup.sh) which contains the base environment, and other scripts which use that in various ways; setup.bash adds bash-isms, and env.sh does the exec that is the defining feature of the environment loader.

If you generate setup.sh and setup.bash with rosinstall or rosws, you can use an env.sh similar to above, but you should probably set ROS_ENV_LOADER in your ~/.bashrc to avoid having it overwritten when you add more packages to your workspace.

Wiki: pr2_robot/Tutorials/Setting up the ROS_ENV_LOADER (last edited 2013-08-05 18:25:29 by AustinHendrix)