ROS2 Installation and Overview

The goal in this post is describing the installation process of ROS2 Crystal Clemmys with ROS bag and giving you an overview of ROS2. Installing ROS2 can be a waste of time if you don’t know where to start and which packages/dependencies you need to install. I wasted time to figure out how to install ROS2 Crystal with ROS2 bag correctly, So I thought that might be helpful for other developers to skip the installation step and go straight to development and save time. So this post will be short. Basically, it should be possible to install ROS2 on different OS (Obviously with lots of pain) by building from the source which described here, but we will use the binary installation for Ubuntu 18.04 and I think they are also valid for Debian too. So let’s get started.

ROS2 Crystal Clemmys Installation

These steps are more or less the same as what described here, but the important point is that if you want to use rosbag, you should install some ROS1 packages. You can download the shell script and run that if you don’t want to go through steps:

  • Make sure to set locale to en_US.UTF-8:

    sudo locale-gen en_US en_US.UTF-8
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    export LANG=en_US.UTF-8
    
  • Add the repository to your source list:

    sudo apt update && sudo apt install curl gnupg2 lsb-release 
    curl http://repo.ros2.org/repos.key | sudo apt-key add -
    sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
    
  • Set the ROS distribution name that you want to install, in this case, is crystal and install it (choose between full install or base install):

    export CHOOSE_ROS_DISTRO=crystal  # or bouncy or ardent
    sudo apt update
    sudo apt install ros-$CHOOSE_ROS_DISTRO-desktop         # Full install
    #sudo apt install ros-$CHOOSE_ROS_DISTRO-ros-base        # Base install
    
  • Note: If you want to use ROS2 bag consider the following steps, otherwise you can skip them. ROS2 bag is using ros1_bridge but it is not included in the ROS2 installation of crystal, so we should first add the related repository to our source list:

    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
    sudo apt update
    sudo apt install ros-$CHOOSE_ROS_DISTRO-ros1-bridge 
    
  • The ROS CLI use argcomplition, so install it:

    sudo apt install python3-argcomplete 
    
  • In order to use ROS commands in terminal we need to source the overlay workspace in our .bashrc:

    source /opt/ros/$CHOOSE_ROS_DISTRO/setup.bash
    echo "source /opt/ros/$CHOOSE_ROS_DISTRO/setup.bash" >> ~/.bashrc
    echo "export CHOOSE_ROS_DISTRO=crystal" >> ~/.bashrc
    
  • Install RMW implementation (FastRTPS):

    sudo apt update
    sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-opensplice-cpp   # for OpenSplice
    sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-connext-cpp      # for RTI Connext (requires license agreement)
    
  • In this step ROS2 bag will be installed, more information about it can be found here.

    export CHOOSE_ROS_DISTRO=crystal # rosbag2 is available starting from crystal
    sudo apt-get install ros-$CHOOSE_ROS_DISTRO-ros2bag* ros-$CHOOSE_ROS_DISTRO-rosbag2* 
    
  • Installing build system for ROS2 (Colcon):

    sudo apt install python3-colcon-common-extensions
    

You can use the script from my Git Repository to install ROS2 Crystal Clemmys and ROS bag properly and don’t forget to restart your instance.

Overview: ROS2 vs. ROS1

One of the important changes in ROS2 is using DDS (Data Distribution Service) for communicating between nodes. This implementation brings different advantages to ROS2, especially, there is no need to run the master node. In ROS1, we need to run the master node in order to enable ROS nodes to locate each other and so they can communicate. But in ROS2, nodes can communicate with each other using publish/subscribe model. This approach makes it easy to connect microcontrollers and sensors to the ROS environment. The other advantage would be allowing ROS2 to aim multi-robot systems whereas ROS1 aimed single robot use cases.

Some other advantages of ROS2 would be providing real-time communication with QoS which can also work under lossy network whereas ROS1 doesn’t guarantee real-time communication and requires a highly reliable network. Moreover, ROS2 is a cross-platform meaning it should work in different OS’s (but with suffering, it takes half a week to properly install it:-)). The installation of the ROS2 does not come with the build system whereas in ROS1 catkin would be installed along with ROS1 as a build system, so for making workspace, we should first install a build system like colcon which is a unified build system containing catkin and ament for compiling the ROS1 and ROS2.

What are the other advantages/disadvantages and which features do you like? Share them on the comment section.

Add a Comment

Your email address will not be published. Required fields are marked *