ROS2 vs ROS1. Installing ROS2 on Ubuntu 18.04

ROS (Robotic operation system) confidently occupies a leading position in the standards of robotics. In the words of a famous politician, “not only everything” is already using it.
In this article, we will try to take a look at the next stage of ROS development - the ROS2 system, suitable for more “sleek” developers. Let's compare both systems in general terms, and at the same time install ROS2 on Ubuntu 18.04.



* image from www.theconstructsim.com
A slightly outdated model will be used as the basic PC configuration - intel NUC (5i5RYK), 4GB RAM, SSD M.2 120Gb. NUC performance is enough "for the eyes" for ROS purposes, but single-board cards (raspberry, odroid, jetson) are deliberately not considered, because each of them has its own specifics. It is assumed that Ubuntu 18.04 (recommended for use with ROS) is already installed.

Introduction.


Over the past decade, ROS (ROS1) has grown and has grown several times. Currently,
he has a huge list of packages, where each package solves the problem either partially or
completely, which eliminates the concept of the invention of the wheel again. The packages created by the community have led to the creation of a completely new approach to robotics and the proposed intelligent filling for existing systems.

Limitations of ROS1.


Despite the fact that ROS1 gave a certain freedom of communication with complex hardware and software components, there are some difficulties associated with the use of ROS1 in the final product. These difficulties begin to appear when there is a whole fleet of heterogeneous robots (mobile robots, robotic manipulators, and so on).
Establishing a relationship between them is quite difficult due to the architectural limitations of ROS1.
The first limitation is that ROS1 does not support the multimaster concept.
The second limitation of ROS1 is that, despite the fact that nodes can communicate with each other without problems, there is no safe way in this communication. Anyone who has the ability to connect to the master (master-node) can access the topics and then either exploit or modify them. Therefore, the main purpose of ROS1 is to test the concept or prototype for scientific purposes.
And the third, perhaps the main limitation of ROS1 is that this system is not a real-time system. This leads to delays in receiving data and their loss.
All the above disadvantages pushed to the creation of ROS2.

What are the benefits of ROS2?


- allows you to establish secure connections between system components (nodes)
- the interaction is real-time
- the connection of several robots into one network is simplified
- the quality of communication between nodes
is improved - the ROS architecture level is implemented directly on the hardware
- the latest packages are used updates (ROS1 is not updated as often).

ROS2 follows the industry standard and implements real-time interaction through the so-called DDS (Data Distributed Services) concept.

ROS2 Versions

.
The first official stable version of ROS2 was released in December 2017. The distribution was named "Ardent Apalone." Then there was a release in June 2018, with the name "Bouncy Bolson". Crystal Clemmys appeared in December 2018. Dashing Diademata (current version) in May 2019. As you can see, distributions are updated quite cheerfully, and, hopefully, the alphabet is enough for the first time.

OS support

.
ROS2 supports (if we talk about official support) Linux, Windows, macOS, and Real-Time Operating Systems (RTOS) OS layers, ROS1 only Linux and macOS.
More detailed OS support:


So why do you need ROS2?


ROS2 uses the same operating principles as ROS1. At the same time, ROS2 is not part of ROS1. ROS2 was created to step over the limits of its fellow by using newer dependencies and tools.
Unlike ROS1, whose stack is written in C ++, and client libraries in C ++ and Python, ROS-2 also uses the C language. An independent level written in C is introduced that interacts with ROS2 client libraries such as rclcpp, rclpy, and rcljava.

ROS2 better supports network configurations and implements reliable connections.
ROS2 also no longer uses the concept of nodelets (http://wiki.ros.org/nodelet) and supports the ability to initialize multiple nodes at the same time (multinode initialization). Unlike ROS1, another distinguishing feature of ROS2 is the ability to track the status of a node and receive messages if a node or topic has been added or deleted. This can be used to create fault tolerant systems.

Changes that have occurred in ROS2 compared to ROS1:


Install ROS2

.
So, we’ll install from the sources the current distribution of Dashing Diademata (dashing) on ​​Ubuntu 18.04

Set up the environment.


$ 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 ROS2 repositories.


$ sudo apt update && sudo apt install curl gnupg2 lsb-release
$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc |
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'


Install the ROS Developer Tools.


$ sudo apt update && sudo apt install -y build-essential cmake git
python3-colcon-common-extensions python3-lark-parser python3-pip
python-rosdep python3-vcstool wget
$ python3 -m pip install -U argcomplete flake8 flake8-blind-except
flake8-builtins flake8-class-newline flake8-comprehensions flake8-
deprecated flake8-docstrings flake8-import-order flake8-quotes
pytest-repeat pytest-rerunfailures pytest pytest-cov pytest-runner
setuptools
$ sudo apt install --no-install-recommends -y libasio-dev libtinyxml2-dev


Create a workspace ROS2.


$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
$ vcs import src < ros2.repos

It will take some time.

Install dependencies using rosdep.


$ sudo rosdep init
$ rosdep update
$ rosdep install --from-paths src --ignore-src --rosdistro dashing -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69
rti-connext-dds-5.3.1 urdfdom_headers"

If everything went well and the entry “All required rosdeps installed successfully” appears in the terminal, you can proceed to the next step.

We collect the code, install colcon.


In ROS1, packages were collected using the catkin tool. ROS2 uses colcon (a utility that includes catkin_make, catkin_make_isolated, catkin_tools, and ament_tools). colcon can collect both ROS1 packets and ROS2 packets. After the last command, you can safely go to drink tea, because Installation may take about an hour. Upon its successful completion, approximately the following information about the successful installation will appear in the terminal:
$ sudo apt install python3-colcon-common-extensions
$ cd ~/ros2_ws/
$ colcon build --symlink-install






Setting up the environment for ROS2 (environment).


In order not to enter the long command 'source ~ / ros2_ws / install / local_setup.bash' each time to initiate ROS in the terminal, add alias to bashrc:
$ sudo gedit ~/.bashrc

Next, add the line at the end of the file:
alias initros2='source ~/ros2_ws/install/local_setup.bash

Save, exit the file and re-read it with the command (so as not to reboot system):
$ source ~/.bashrc

Check the operation of ROS2.


1st terminal: These commands start the talking node. 2nd terminal: Here, respectively, the “listening” node is launched. Visually, both nodes look something like this: You can also look at the topics generated by the nodes in the 3rd terminal: To summarize. ROS2 was reviewed in comparison with ROS1, the installation procedure for ROS2 (Dashing Diademata (dashing)) on Ubuntu 18.04 was demonstrated.
$ initros2
$ ros2 run demo_nodes_cpp talker




$ initros2
$ ros2 run demo_nodes_py listener










All Articles