Installing from source

Install from source requires that you download and compile the source code on your own. ROS Noetic supports Ubuntu Focal and Debian Buster, but other platforms are possible. The target platforms are defined in REP 3

Prerequisites

Installing bootstrap dependencies

Install bootstrap dependencies (Ubuntu):

These tools are used to facilitate the download and management of ROS packages and their dependencies, among other things.

Ubuntu or Debian:

Fedora:

  • $ sudo dnf install gcc-c++ python3-rosdep python3-rosinstall_generator python3-vcstool @buildsys-build

    Some packages used in ROS are not currently available in the Fedora RPM repositories. Most of the other packages are available in RPM Fusion. See RPM Fusion Command Line Setup.

Generic (pip):

  • If you are using a non-Debian system you need to make sure that you have all build tools (compiler, CMake, etc.) installed. You can install all ROS Python tools via PIP:
    $ sudo pip3 install -U rosdep rosinstall_generator vcstool
    If there are errors with this or the rosdep step below, your system's version of pip may be out-of-date. Use your system's package management to update it, or use it to update itself:
    $ sudo pip3 install --upgrade setuptools

    Note that on many platforms such as OSX you may want to install the above packages and use ROS inside a virtualenv so as to make sure not to collide with system dependencies.

Initializing rosdep

$ sudo rosdep init
$ rosdep update

Installation

Start by building the core ROS packages.

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 download the source code for ROS packages so we can build them. We will use vcstool` for this. For the purpose of this guide, we'll assume you'd like to build all of Desktop.

  • $ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
    $ mkdir ./src
    $ vcs import --input noetic-desktop.rosinstall ./src

This will download all of the source code for packages part of Desktop into the ~/ros_catkin_ws/src directory. The command will take a few minutes to download everything.

Looking for something other than Desktop? More variants are defined in REP 131 such as desktop_full, robot, perception, etc. Just change the package path above from desktop to the one you want.

Resolving Dependencies

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

  • $ rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y

rosdep looks at all the packages in the src directory and tries to find and install their dependencies on your platform. After a while (and maybe some prompts for your password) rosdep will finish installing system dependencies and you can continue.

Building the catkin Workspace

By now you have a workspace with all of the source code, and all required system dependencies have been installed. Now it's time to build the code. ROS 1 packages use CMake; however, calling cmake by hand on all the packages by hand would be tedious. There are tools we can use to build all the packages in the right order. The tool we'll use is catkin_make_isolated.

catkin_make_isolated isn't the only tool we could use. There are other tools that would work, like catkin_make or catkin_tools (which has a command line executable called catkin), or colcon. Some of those might be better for your use case, but we'll use catkin_make_isolated here since that's what the ROS buildfarm uses.

This command will build everything in the workspace. It may take a while. The command is running catkin_make_isolated command from the source folder because it has not been installed yet. Once installed it can be called using just catkin_make_isolated.

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

Note: Want debug symbols? You might want to select a different CMake build type.

When the above command finishes, it will have installed everything into ~/ros_catkin_ws/install_isolated. If you would like to install somewhere else then add --install-space path/to/somewhere/else to the catkin_make_isolated call.

For usage on a robot without Ubuntu, it is recommended to install compiled code into /opt/ros/noetic just as the Ubuntu packages would do. Of course, don't do this in Ubuntu, as the packages would collide with apt-get packages.

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 like so:

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

Maintaining a Source Checkout

If we want to keep our source checkout up to date, you will have to periodically update your rosinstall file, download the latest sources, and rebuild the workspace.

Update your rosinstall file

To update your workspace, first move your existing rosinstall file so that it doesn't get overwritten, and generate an updated version

$ mv -i noetic-desktop.rosinstall noetic-desktop.rosinstall.old
$ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall

Then, compare the new rosinstall file to the old version to see which packages will be updated:

$ diff -u noetic-desktop.rosinstall noetic-desktop.rosinstall.old

Download the latest sources

If you're satisfied with these changes, incorporate the new rosinstall file into the workspace and update your workspace:

$ vcs import --input noetic-desktop.rosinstall ./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

Wiki: noetic/Installation/Source (last edited 2020-05-23 16:49:44 by ShaneLoretz)