Installing On Gentoo
Gentoo installation is rather experimental at the moment. The installation is quite functional, though. Notice: on Funtoo Linux, the following instructions work, but you will need to make several modifications (so proceed at your own risk).
Contents
Prerequisites
Selecting Python 2.7
Currently, we need to use Python-2.7. To do so, we will use eselect.
# eselect python list Available Python interpreters: [1] python2.7 * [2] python3.3
Then do the following command to select 2.7.
# eselect python set 1
We will also install some other libraries for ROS, such as OpenCV, Gazebo and Bullet.
# emerge sci-physics/bullet sci-electronics/gazebo media-libs/opencv --jobs --load-average `nproc`
If gazebo fails to install, which is highly probable at the moment, omit it from the above command:
# emerge sci-physics/bullet media-libs/opencv --jobs --load-average `nproc`
Installing the Overlay
Before proceeding, the necessary tools for installing ROS must be installed on your system. To do so, you need to install Layman, an overlay manager for Gentoo.
# emerge layman -vaj
# echo "source /var/lib/layman/make.conf" >> /etc/portage/make.conf
Now we add the overlay with the necessary Gentoo packages.
# layman -f -o https://raw.githubusercontent.com/ros/ros-overlay/master/overlay.xml -a ros-overlay # emerge --sync
Now we install the necessary tools for installation.
# emerge rosdep rosinstall_generator wstool rosinstall catkin_pkg # pip install --upgrade setuptools
Next, add the following lines to the end of /etc/portage/package.use.
# required by ROS sys-libs/zlib minizip dev-libs/boost python
At this point, it is strongly advised that you perform a full system update.
# emerge --sync # emerge -uDNvaj @world --load-average `nproc`
Initializing rosdep
$ sudo rosdep init $ rosdep update
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.
$ rosinstall_generator desktop_full --rosdistro jade --deps --wet-only --tar > jade-desktop_full-wet.rosinstall $ wstool init -j8 src jade-desktop_full-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.
If wstool init fails or is interrupted, you can resume the download by running:
wstool update -j 4 -t src
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 jade -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.
Lastly, we need to do the following:
$ echo 'PYTHONPATH="/opt/ros/jade/lib64/python2.7/site-packages"' >> ~/.bashrc $ source ~/.bashrc
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:
$ sudo PYTHONPATH="/opt/ros/jade/lib64/python2.7/site-packages" ./src/catkin/bin/catkin_make_isolated --install --install-space /opt/ros/jade -DSETUPTOOLS_DEB_LAYOUT=OFF
At the time of writing, you will need to use a more up to date version of image pipeline, as OpenCV has just made a major bump (2.0 -> 3.0):
$ rm -rf src/image_pipeline $ git clone https://github.com/ros-perception/image_pipeline
Should your Gazebo installation fail, you may remove gazebo from the source directory and proceed with the rest of the install.
$ rm -rf src/gazebo_ros_pkgs
Now the packages should have been installed to /opt/ros/jade/ 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 /opt/ros/jade/setup.bash
To verify that your ROS install is operational, try and run roscore. You should get something similar to the image below.
Post-Installation Instructions
Creating a Workspace
It's recommended that you do your work in a separate ros workspace. To make one named catkin_ws, run the following.
$ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws/src && catkin_init_workspace & cd ../ && catkin_make
Editing Environment Variables
Now we add some lines to our ~/.bashrc file. Add these lines, replacing catkin_ws with the name you chose above.
PYTHONPATH="/opt/ros/jade/lib/python2.7/site-packages:/opt/ros/jade/lib64/python2.7/site-packages/" source /opt/ros/jade/setup.bash source ~/catkin_ws/devel/setup.bash
Install GMapping
Next we demonstrate how to install extra packages, such as GMapping.
$ roscd && cd ../src $ git clone https://github.com/ros-perception/openslam_gmapping $ git clone https://github.com/ros-perception/slam_gmapping $ cd ../ && catkin_make
with luck, you should now have GMapping.
Maintaining a Source Checkout
If we want to keep our source checkout up to date, we will have to periodically update our rosinstall file, download the latest sources, and rebuild our workspace.
Update the workspace
To update your workspace, first move your existing rosinstall file so that it doesn't get overwritten, and generate an updated version. For simplicity, we will cover the *destop-full* variant. For other variants, update the filenames and rosinstall_generator arguments appropriately.
$ mv -i jade-desktop_full-wet.rosinstall jade-desktop_full-wet.rosinstall.old $ rosinstall_generator desktop_full --rosdistro jade --deps --wet-only --tar > jade-desktop_full-wet.rosinstall
Then, compare the new rosinstall file to the old version to see which packages will be updated:
$ diff -u jade-desktop_full-wet.rosinstall jade-desktop_full-wet.rosinstall.old
If you're satified with these changes, incorporate the new rosinstall file into the workspace and update your workspace:
$ wstool merge -t src jade-desktop_full-wet.rosinstall $ wstool update -t src
Rebuild your workspace
Now that the workspace is up to date with the latest sources, rebuild it:
$ ./src/catkin/bin/catkin_make_isolated --install
If you specified the --install-space option when your workspace initially, you should specify it again when rebuilding your workspace
Once your workspace has been rebuilt, you should source the setup files again:
$ source ~/ros_catkin_ws/install_isolated/setup.bash