(!) 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.

Installing ROS and building ainstein_radar

Description: Instructions for ROS beginners to build the Ainstein ROS packages

Tutorial Level: BEGINNER

This tutorial goes through the process of cloning and building the ainstein_radar package and is meant for anyone comfortable with using a terminal in Ubuntu but with little ROS experience.

Installing ROS

First, follow official ROS installation guide for your linux distribution - each version of Ubuntu has a recommended version of ROS, choose from the options below. Using ROS on Windows is possible as of this writing, but not recommended or supported; please use a linux (preferably Ubuntu) machine instead. It should be possible to run Ubuntu in a Virtual Machine (VM) from Windows, or dual-boot Ubuntu alongside Windows.

We recommend using ROS Melodic (Ubuntu 18.04) as there are many packages yet to be ported to ROS Noetic (Ubuntu 20.04), however we will detail installation for each of these distros.

ROS Kinetic Kame
Released May, 2016
LTS, supported until April, 2021
This version isn't recommended for new installs.
Kinetic Kame

ROS Melodic Morenia
Released May, 2018
LTS, supported until May, 2023
Recommended for Ubuntu 18.04

Melodic Morenia

ROS Noetic Ninjemys
Released May, 2020
Latest LTS, supported until May, 2025
Recommended for Ubuntu 20.04
Noetic Ninjemys

Setting up a catkin workspace

This section follows the official ROS setup instructions. Once you have ROS installed, you can check the installation in a few simple ways. If your environment is configured correctly, running

printenv | grep ROS

in a terminal should print some ROS environment variables. Then try running

roscore

Which runs a ROS master node (which is needed to run anything else, since the master coordinates all communication). Once that seems to be working, we need to set up what's called a "catkin workspace" which is where our user packages will reside. As an aside, there are two types of packages - system-wide packages (installed usually using the apt package manager) and user packages (installed in a catkin workspace). Catkin is a build tool which wraps CMake, specifically for managing a collection of packages with inter-dependencies. To create a catkin workspace as described in the ROS documentation, eg:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/

Cloning and building the ainstein_radar package

Any ROS packages you wish to build in this new catkin workspace should be cloned into ~/catkin_ws/src. To clone ainstein_radar, for example:

cd ~/catkin_ws/src
git clone https://github.com/AinsteinAI/ainstein_radar.git

You should now have the source code for the ainstein_radar package in your workspace. Next, let's ensure your current terminal session has the system-wide ROS environment variables set up by using:

source /opt/ros/melodic/setup.bash # change melodic to noetic if necessary

Now, the build process itself is slightly different between Melodic and Noetic, so please follow the appropriate instructions for your ROS distro below.

ROS Melodic (Ubuntu 18.04)

Install catkin which is the build tool for building workspaces of interdependent ROS packages (if you haven't already installed it) with:

sudo apt install python-catkin-tools

You're now ready to build the catkin workspace as follows:

cd ~/catkin_ws/
rosdep install --from-paths src --ignore-src --rosdistro=melodic
catkin build ainstein_radar_msgs # build messages first
catkin build

This should install any system dependencies required by the package(s), and then build the whole workspace.

ROS Noetic (Ubuntu 20.04)

With Noetic, you should instead use the older-style catkin_make build command, and you may also need to specify -j4 to limit computational resources else your computer may freeze during building (your experience may vary, this was my personal experience). Thus, the suggested build command steps are:

cd ~/catkin_ws/
rosdep install --from-paths src --ignore-src --rosdistro=noetic
catkin_make -j4

If you have issues building with errors related to missing ainstein_radar_msgs message types, instead build the messages package "first" and then the whole workspace as follows:

catkin_make clean # clean first to be safe
catkin_make --pkg ainstein_radar_msgs
catkin_make -j4

Post-build Steps

Your workspace build should have generated a file called ~/catkin_ws/devel/setup.bash which sets up environment variables for user packages, the same way the file /opt/ros/melodic/setup.bash sets up the environment variables for the system packages. You should source both of these in your ~/.bashrc as the documentation describes, adding to the bottom of ~/.bashrc the following:

source /opt/ros/melodic/setup.bash # change melodic to noetic if necessary
source ~/catkin_ws/devel/setup.bash

To quickly test your build and environment, try running

roscd ainstein_radar_drivers

If the package was build correctly and the environment variables have been set up properly, this command should change directory to the drivers subpackage. You can find other useful ROS commands for working in terminal in the main ROS documentation.

Wiki: ainstein_radar/Tutorials/Installing ROS and building ainstein_radar (last edited 2020-11-16 15:58:18 by AinsteinAi)