[Documentation] [TitleIndex] [WordIndex

Installing on Gentoo from source

Install from source requires that you download and compile the source code on your own.

Install Necessary System Tools

Assuming you have not done so, it would be a good idea to emerge the package sudo at this time. We're going to add a line to the make.conf file, as well (assuming you don't already have it there).

As root:

# emerge sudo
# echo 'EMERGE_DEFAULT_OPTS="--autounmask-write y"' >> /etc/portage/make.conf

If you get the line (below) stating that the packages are masked during an emerge command (likely, given the quantity), run the command "sudo etc-update". It will update the appropriate configuration files.

Many of ROS's Python libs still depend on Python2.7 so you will likely need to switch.

$ sudo eselect python list
$ sudo eselect python set <num> # choose python2.7
$ sudo python-updater

The following mask changes are necessary to proceed:

Now continue with the dependencies for ROS. Log in as a standard user.

$ sudo bash -c 'echo app-portage/gentoolkit >> /etc/portage/package.keywords'
$ sudo bash -c 'echo dev-python/setuptools >> /etc/portage/package.keywords'
$ sudo emerge -u pyyaml git cmake subversion mercurial gentoolkit setuptools layman 
$ sudo layman -a lorelei
$ sudo bash -c 'echo source /var/lib/layman/make.conf >> /etc/make.conf'
$ sudo bash -c 'echo media-libs/assimp >> /etc/portage/package.keywords'
$ sudo bash -c 'echo media-libs/freeimage >> /etc/portage/package.keywords'
$ sudo emerge -u boost gtest log4cxx wxpython dev-python/pip dev-libs/apr
  dev-python/paramiko dev-libs/poco dev-cpp/eigen dev-libs/tinyxml dev-python/PyQt4
  dev-cpp/yaml-cpp dev-libs/boost[python] media-libs/opencollada
$ sudo pip-python2.7 install -U empy nose wstool rosdep rosinstall rospkg catkin-pkg Distribute

Now you need to build the library COLLADA-DOM from source. Unfortunately, this library is not currently part of portage. As this is a large package, it will take some time to build (but, since you run Gentoo, you're probably quite used to it).

$ sudo mkdir -p /usr/local/src
$ sudo chown `echo $USER` /usr/local/src 
$ cd /usr/local/src/
$ svn co https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk colladadom
$ cd colladadom
$ sudo nano -w /etc/portage/make.conf

Now you need to change your USE flags and recompile zlib (with minizip). For clarity, do not add the "...", just add the word "minizip" in front of what already exists in the file.

USE = "minizip ..."

$ sudo emerge zlib
$ cmake .
$ make
$ sudo make install
$ sudo ldconfig

At this point, it is highly suggested that you run python-update. This will make sure your packages are happy and healthy.

$ sudo python-updater

Now you need to clone and install rosinstall_generator from scratch.

$ cd ~
$ git clone https://github.com/ros-infrastructure/rosinstall_generator
$ cd rosinstall_generator
$ sudo python setup.py install

At this point, you've likely altered your system quite significantly. So, it is a very good idea to update your packages. This will definitely take a while. This will build your packages that need updating, as well as recompiling those that have been altered significantly by the installation process. You probably do not have to do this, but it is much safer if you do.

$ sudo emerge-webrsync
$ sudo emerge --sync
$ sudo emerge --update --changed-use --deep --with-bdeps=y @world

Installation

Start by building the core ROS packages.

Building the catkin Packages

ROS is in the process of converting to a new build system, catkin, but not all of the packages have been converted and the two build systems cannot be used simultaneously. Therefore it is necessary to build the core ROS packages first (catkin packages) and then the rest.

Create a catkin Workspace

In order to build the core packages, you will need a catkin workspace. Create one now:

  • $ mkdir ~/ros_catkin_ws
    $ cd ~/ros_catkin_ws

Next we will want to fetch the core packages so we can build them. We will use wstool for this. Select the wstool command for the particular variant you want to install:

Desktop-Full Install: ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception

  • $ rosinstall_generator desktop-full --rosdistro groovy --deps --wet-only > groovy-desktop-full-wet.rosinstall
    $ wstool init -j8 src groovy-desktop-full-wet.rosinstall

Desktop Install (recommended): ROS, rqt, rviz, and robot-generic libraries

  • $ rosinstall_generator desktop --rosdistro groovy --deps --wet-only > groovy-desktop-wet.rosinstall
    $ wstool init -j8 src groovy-desktop-wet.rosinstall

ROS-Comm: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.

  • $ rosinstall_generator ros_comm --rosdistro groovy --deps --wet-only > groovy-ros_comm-wet.rosinstall
    $ wstool init -j8 src groovy-ros_comm-wet.rosinstall

This will add all of the catkin or wet packages in the given variant and then fetch the sources into the ~/ros_catkin_ws/src directory. The command will take a few minutes to download all of the core ROS packages into the src folder. The -j8 option downloads 8 packages in parallel.

In addition to the 3 variants above, more are defined in REP 131 such as robot, perception, etc. Just change the package path to the one you want, e.g., for robot do:

$ rosinstall_generator robot --rosdistro groovy --deps --wet-only > groovy-robot-wet.rosinstall
$ wstool init -j8 src groovy-robot-wet.rosinstall

Resolving Dependencies

Before you can build your catkin workspace you need to make sure that you have all the required dependencies. We use the rosdep tool for this:

  • $ rosdep install --from-paths src --ignore-src --rosdistro groovy -y

This will look at all of the packages in the src directory and find all of the dependencies they have. Then it will recursively install the dependencies.

The --from-paths option indicates we want to install the dependencies for an entire directory of packages, in this case src. The --ignore-src option indicates to rosdep that it shouldn't try to install any ROS packages in the src folder from the package manager, we don't need it to since we are building them ourselves. The --rosdistro option is required because we don't have a ROS environment setup yet, so we have to indicate to rosdep what version of ROS we are building for. Finally, the -y option indicates to rosdep that we don't want to be bothered by too many prompts from the package manager.

After a while (and maybe some prompts for your password) rosdep will finish installing system dependencies and you can continue.

Building the catkin Workspace

Once it has completed downloading the packages and resolving the dependencies you are ready to build the catkin packages. We will use the catkin_make_isolated command because there are both catkin and plain cmake packages in the base install, when developing on your catkin only workspaces you should use catkin/commands/catkin_make.

Invoke catkin_make_isolated:

  • $ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

Note: You might want to select a different CMake build type (e.g. RelWithDebInfo or Debug, see http://cmake.org/cmake/help/v2.8.12/cmake.html#variable:CMAKE_BUILD_TYPE).

Note: The default catkin installation location would be ~/ros_catkin_ws/install_isolated, if you would like to install some where else then you can do this by adding the --install-space /opt/ros/groovy argument to your catkin_make_isolated call.

For usage on a robot without Ubuntu, it is recommended to install compiled code into /opt/ros/groovy just as the Ubuntu packages would do. Don't do this in Ubuntu, as the packages would collide with apt-get packages. It is also possible to install elsewhere (e.g. /usr), but it is not recommended unless you really know what you are doing.

Please see REP 122: Filesystem Hierarchy Layout for more detailed documentation on how the installed files are placed.

Note: In the above command we are running the catkin_make_isolated command from the catkin source folder because it has not been installed yet, once installed it can be called directly.

Now the packages should have been installed to ~/ros_catkin_ws/install_isolated or to wherever you specified with the --install-space argument. If you look in that directory you will see that a setup.bash file have been generated. To utilize the things installed there simply source that file. Lets do that now before building the rest of ROS:

  • $ source ~/ros_catkin_ws/install_isolated/setup.bash

Build the rosbuild Packages

Now that you have the catkin ROS packages built and sourced, you can build any of the packages and stacks using the rosbuild build system.

Create a rosbuild workspace

Note: You do not need to do this part of the installation for the ROS-Comm: (Bare Bones) variant as it does not contain any rosbuild packages in it.

Like with building catkin packages, it is convenient to build rosbuild packages in a workspace. Lets create a ROS workspace using rosws:

  • $ mkdir ~/ros_ws
    $ cd ~/ros_ws
    $ rosws init . ~/ros_catkin_ws/install_isolated

Note that we are pointing the ROS workspace to the catkin install location that we built in the previous step. This allows the ROS workspace to always source the catkin install location environment before you use the ROS workspace.

Download ROS Stacks

Now we need to get the dry (rosbuild) components of the variant you chose before. Use the corresponding command for your variant to do this:

Desktop-Full Install: 2d/3d simulators, navigation, robot models and several tutorial stacks

  • $ rosinstall_generator desktop-full --rosdistro groovy --deps --dry-only > groovy-desktop-full-dry.rosinstall
    $ rosws merge groovy-desktop-full-dry.rosinstall

Desktop Install (recommended): ROS, rqt, rviz, and robot-generic libraries

  • $ rosinstall_generator desktop --rosdistro groovy --deps --dry-only > groovy-desktop-dry.rosinstall
    $ rosws merge groovy-desktop-dry.rosinstall

Now this just setups your rosbuild workspace, you need to tell rosws to fetch the packages still:

  • $ rosws update -j8

Build the ROS Stack

Once this is done fetching the stack you can source this workspace and then build the stack:

  • $ source ~/ros_ws/setup.bash
    $ rosmake -a

2023-10-28 12:37