The Beginner’s Guide to ROS

The Beginner’s Guide to ROS

Welcome to your ROS learning journey!

If you are interested in robotics, you must have heard of ROS (Robot Operating System). ROS is now very popular among roboticists. Researchers, hobbyists, and even robotics companies are using it, promoting it. and supporting it. But what is ROS? How did ROS reach its current state as a robotics standard? Why is ROS becoming a must-have skill for robotics practitioners? In this article, we will reveal the answers to these questions.

Keep on reading to understand ROS, or jump ahead to the section that interests you most.

1

A history of ROS

2

What is ROS?

3

Why ROS?

4

Start learning ROS

A history of ROS

Before we understand what ROS is, let me introduce you to ROS with a short history of how it started, the main reasons behind it, and its current status.

  • The Stanford Period
  • Similar frameworks at the time
  • Switching gears
  • Willow Garage takes the lead
  • Under the Open Source Robotics Foundation umbrella
  • ROS 2.0
  • Recent movements in the ROS ecosystem

 

The Stanford Period

ROS started as a personal project of Keenan Wyrobek and Eric Berger while at Stanford, as an attempt to remove the reinventing-the-wheel situation from which robotics was suffering. These two guys were worried about the most common problem of robotics at the time:

  • too much time dedicated to re-implementing the software infrastructure required to build complex robotics algorithms (basically, drivers to the sensors and actuators, and communications between different programs inside the same robot)
  • too little time dedicated to actually building intelligent robotics programs that were based on that infrastructure.

Even inside the same organization, the re-invention of the drivers and communication systems was re-implemented for each new project. This situation was beautifully expressed by Keenan and Eric in one of their slides used to pitch investors.

robotics-reinvent-wheel-History-ROS

Most of the time spent in robotics was reinventing the wheel (slide from Eric and Keenan pitch deck)

In order to attack that problem, Eric and Keenan created a program at Stanford called the Stanford Personal Robotics Program in 2006, with the aim to build a framework that allowed processes to communicate with each other, plus some tools to help create code on top of that. All that framework was supposed to be used to create code for a robot they would also build, the Personal Robot, as a test bed and example to others. They would build 10 of those robots and provide them to universities so that they could develop software based on their framework.

NOTE: People more versed in ROS will recognize the precursors of ROS-comm libraries and the Rviz, rqt_tools and the like of current modern ROS distributions. Also, the Personal Robot was the precursor to the famous PR2 robot.

pr1-robot-History-ROS

PR1 robot, picture by IEEE Spectrum

 

Similar frameworks at the time

The idea of such a system for robotics was not new. Actually, there were some other related projects already available for the robotics community: Player/Stage, one of the most famous in the line of open source, and URBI in the line of proprietary systems. Even Open-R, the system developed by Sony, which powered the early Aibo robots of 1999, was a system created to prevent that problem (a shame that Sony cancelled that project, as they could have become the leaders by now. Ironically, this year, Sony launched a new version of the Aibo robot… which runs ROS inside!). Finally, another similar system developed in Europe was YARP.

Actually, one of the leaders of the Player/Stage research project was Brian Gerkey, who later went to Willow Garage to develop ROS, and is now the CEO of Open Robotics, the company behind the development of ROS at present. On its side, URBI was a professional system led by Jean-Christoph Baillie, which worked very well, but could not compete with  ROS, which was free.

That is an important point to discuss: URBI was (at least) as good as ROS. I used it for many research tasks while doing my Ph.D.: for example, this code about making the Aibo robot walk using neural networks (in 2005!), and making Aibo dance, and do some other tricks. But URBI failed when competing with ROS. URBI had as many tools for debugging, and as much documentation as ROS. So, why did URBI fail against ROS?

The fastest readers will jump to the point that URBI was not free. Actually, it was quite expensive. Was the price what killed URBI? I don’t think so. In my opinion, what killed URBI was the lack of community. It takes some time to build a community, but once you have it, it acts like changing gears. URBI could not build a community because it relied on an (expensive) paid fee. That made it so that only people that could buy it were accessing the framework. That limits the amount of community you can create. It is true that ROS was free. But that is not the reason (many products that are free fail). The reason is that they built a community. Being free was just a strategy to build that community.

Switching gears

While at Stanford, Keenan and Eric received $50k of funding and used it to build a PR robot and a demo of what their actual project was. However, they realized that in order to build a really universal system and to provide those robots to the research groups, they would need additional funding. So they started to pitch investors.

At some point around 2008, Keenan and Eric met with Scott Hassan, investor and the founder of Willow Garage, a research center with a focus on robotics products. Scott found their idea so interesting that he decided to fund it and start a Personal Robotics Program inside Willow Garage with them. The Robot Operating System was born, and the PR2 robot with it. Actually, the ROS project became so important that all the other projects of Willow Garage were discarded and Willow Garage concentrated only on the development and spread of ROS.

Willow Garage takes the lead

ROS was developed at Willow Garage over the course of 6 years, until Willow shut down, back in 2014. During that time, many advancements in the project were made. It was this push during the Willow time that skyrocketed its popularity. It was also during that time that I acknowledged its existence (I started with ROS C-turtle in 2010) and decided to switch from Player/Stage (the framework I was using at that time) to ROS, even if I was in love with Player/Stage (I don’t miss you because ROS is so much better in all aspects… sorry, Player/Stage, it’s not me, it’s you).

In 2009, the first distribution of ROS was released: ROS Mango Tango, also called ROS 0.4. As you can see, the name of the first release had nothing to do with the current naming convention (for unknown reasons to this author). The release 1.0 of that distribution was launched almost a year later in 2010. From that point, the ROS team decided to name the distributions after turtle types. Hence, the following distributions and release dates were done:

Around that time, other events also happened:

  1. In 2009, they built a second version of the Personal Robot, the PR2
  2. In xxx, they launched ROS Answers, the channel to answer technical questions about ROS.
  3. The first edition of the ROSCON was in 2012. The ROSCON became the official yearly conference for ROS developers.
  4. In 2010, they built 11 PR2 robots and provided them to 11 universities for robotics software development using ROS (the original idea of Eric and Keenan). At that point, the PR2 robot was for sale, so anybody in the world could buy one (if enough money was available ;-)).
  5. Simulation started to become very important. More precisely, 3D simulation. That is why the team decided to incorporate Gazebo, the 3D robotics simulator from the Player/Stage project, into ROS. Gazebo became the default 3D simulator for ROS.

As ROS was evolving, all the metrics of ROS were skyrocketing. The number of repositories, the number of packages provided, and of course, the number of universities using it and of companies putting it into their products.

ros-evolution-repo-packages-History-ROS

Evolution of ROS in the early days (picture from Willow Garage)

 

Another important event that increased the size of the ROS community was when, in 2011, Willow Garage announced the release of the Turtlebot robot, the most famous robot for ROS developers. Even if PR2 was the intended robot for testing and developing with ROS, its complexity and high price made it non-viable for most researchers. Instead, the Turtlebot was a simple and cheap robot that allowed anybody to experiment with the basics of robotics and ROS. It quickly became a big hit, and is used even today, in its Turtlebot2 and Turtlebot 3 versions.

In 2013, Willow Garage ‘announced’ that the company would dissolve that year.

I remember when we received the news that Willow Garage was closing. I was working at Pal Robotics at the time. We at Pal Robotics were all very worried. What would happen with ROS? After all, we had changed a lot of our code to be working with ROS. We removed previous libraries like Karto for navigation (Karto is software for robot navigation, which at present is free, but at that time, we had to pay for a license to use it as the main SLAM and path planning algorithms of our robots).

The idea was that the newly created Open Source Robotics Foundation would take the lead in ROS development. And many of the employees were absorbed by Suitable Technologies (one of the spin-offs created from Willow Garage, which ironically does not use ROS for their products ;-)). The customer support for all the PR2 robots was absorbed by another important company, Clearpath Robotics.

Under the Open Source Robotics Foundation umbrella

Under the new legal structure of the OSRF, ROS continued to develop and release new distributions.

The reports created after each year are publicly available here under the tag ROS Metrics.

Having reached this point, it is important to state that the last distribution of ROS will be released in 2020. It is called ROS Noetic, which will be based on Python 3, instead of Python 2 as all the previous ones were. From that date, no more ROS 1 distributions will be released, and the full development will be taken for ROS 2.

(Update: ROS Noetic Ninjemys has been released on May 23rd, 2020. )

What is ROS 2? Let’s dig in…

ROS 2.0

Around 2015, the deficiencies of ROS for commercial products were manifesting very clearly. Single point of failure (the roscore), lack of security, and no real-time support were some of the main deficiencies that companies argued for not supporting ROS in their products. However, it was clear that, if ROS had to become the standard for robotics, it had to reach the industrial sector with a stronger voice than that of the few pioneer companies already shipping ROS in their products.

In order to overcome that point, the OSRF took the effort to create ROS 2.0.

ROS 2.0 had already reached its fourth distribution in June 2019 with the release of Dashing Diademata.

Recent movements in the ROS ecosystem

  • In 2017, the Open Source Robotics Foundation changed its name to Open Robotics, in order to become more of a company than a foundation, even if the foundation branch still exists (some explanation about it can be found in this post and in this interview with Tully Foote).
  • Recently, Open Robotics has opened a new facility in Singapore and established a collaboration with the government there for development.
  • Local ROS conferences have been launched:
    • ROSCON France
    • ROSCON Japan
  • In the last few months, big players like Amazon, Google, and Microsoft have started to show interest in the system, and show support for ROS.

That is definitely a sign that ROS is in good health (I would say in better than ever) and that it has a bright future in front of it. Sure, many problems will arise (like, for example, the current problem of creating a last ROS 1 distribution based on Python 3), but I’m 100% sure that we, and by we I mean the whole ROS community, will solve them and build on them.

What is ROS?

  • Why are there not enough developers for robotics?
  • Roboticists programming robots
  • What is the robot ROS API?
  • What is ROS anyway?
  • ROS for service robots
  • ROS for industrial robots 
  • ROS for agricultural robots

A story of software & hardware: why are there not enough developers for robotics?

In general, software developers do not like to deal with hardware. It is very likely that you are a software developer and never thought about entering into the robotics field. You probably think that by programming for robots, you would have to know about electronics, and maybe even mechanics. You probably think that hardware and software are too coupled in robots, that you cannot touch one without touching the other. And sometimes, it is true…

About 10 years ago, we had to develop a navigation system for a robot. However, our navigation program was not working at all. We thought that it was something wrong with the program, but after extensive review and testing in simulations, we found that it actually was a problem with the electronics of the laser scanner that we used to localize the robot. In order to find that error, we had to go to the basics and find where the problem within the physical laser was. For that, we needed to mess with the electronics. We had to take the laser out of the robot, put it on the table, and start experimenting. Different voltages, different interruptions to the power, all in order to try to reproduce the effect in a controlled environment. That is a lot of interaction with the hardware.

That interaction with the hardware is something that many software developers don’t like. After all, they decided to become software developers, not hardware developers!!

Roboticists programming robots

Due to this, the programming of robots has been done by roboticists, who are the people that build the robots. Maybe some of the roboticists were not directly involved in the creation of the robot, but they definitely have no problem getting into the hardware and trying to fix hardware problems in order to make their programs work.

But let’s face it, most roboticists are not as good at programming as software developers are. That is why robotics could benefit so much from having lots of expert programmers coming to the field.

The good news is that getting developers into the field is easier than ever. Thanks to the Robot Operating System, ROS, you can completely abstract the hardware from the software, so you can program a robot just by knowing the robot’s ROS API and having a simulation for testing. By using the ROS API, you can forget about the hardware and just concentrate on the software that makes the robot do what you want.

What is the robot ROS API?

The ROS API is the list of ROS topics, services, action servers, and messages that a given robot is providing to give access to its hardware, that is, sensors and actuators. If you are not familiar with ROS, you may not understand what those terms mean. But simply put in the developers’ language, topics/services/messages are like the software functions you can call on a robot to get data from the sensors or make the robot take action. It also includes the parameters you can pass on to those functions.

Most modern robot builders are providing off-the-shelf ROS APIs, for example, the ROS-Components shop that provides all its hardware running with a ROS API.

If the robot you want to work with does not run ROS, you can still make the robot work with ROS by ROSifying it. To ROSify means to adapt your robot to work with ROS. ROSifying a robot usually requires knowledge to access the hardware. You need to learn how to communicate with the electronics that provide the sensor data or access the motors of the robot. In this series of ROS tutorials, we are not dealing with that subject because it gets out of scope for developers. But if you are interested in this topic, you can learn more about it in this Robot Creation Course.

What is ROS anyway?

ROS stands for Robot Operating System. Even if the name says so, ROS is not a real operating system since it goes on top of Linux Ubuntu (also on top of Mac, and recently, on top of Windows). ROS is a framework on top of the O.S. that allows it to abstract the hardware from the software. This means, you can think in terms of software for

all the hardware of the robot. And that is good news for you because this implies that you can actually create programs for robots without having to deal with the hardware. Yea!

ROS works on Linux Ubuntu or Linux Debian. Experimental support already exists for OSX, Gentoo, and a version for Windows is under way, but we really don’t recommend for you to use them yet unless you are an expert. Check this page for more information about how to use ROS on those systems.

ROS for service robots

ROS is becoming the standard in robotics programming, at least in the service robots sector. Initially, ROS started at universities, but quickly spread into the business world. Every day, more and more companies and startups are basing their businesses on ROS. Before ROS, every robot had to be programmed using the manufacturer’s own API. This means that if you changed robots, you had to start the entire software again, apart from having to learn the new API. Furthermore, you had to know a lot about how to interact with the electronics of the robot in order to understand how your program was doing. The situation was similar to that of computers in the 80s, when every computer had its own operating system and you had to create the same program for every type of computer. ROS is for robots like Windows is for PCs, or Android for phones. By having a ROSified robot, that is, a robot that runs on ROS, you can create programs that can be shared among different robots. You can build a navigation program, that is a program to make a robot move around without colliding, for a four-wheeled robot built by company A and then use the same exact code to move a two-wheeled robot built by company B… or even use it on a drone from company C, with minor modifications.

ROS for industrial robots

ROS is being used in many of the service robots that are created at present. On the other side, industrial robotics companies are still not completely convinced about using it, mainly because they will lose the power of having a proprietary system. However, four years ago, an international group called ROS-Industrial (https://rosindustrial.org/) was created, whose aim is to make industrial manufacturers of robots understand that ROS is for them, since they will be able to use all the software off-the-shelf that other people have created for other ROS robots.

ROS for agricultural robots

In the same vein as ROS-Industrial, ROS-Agriculture (http://rosagriculture.org/) is another international group that aims to introduce ROS for agriculture robots. I highly recommend that you follow this group if you are interested because they are a very motivated team that can do crazy things with several tons of machine, by using ROS. Check out, for instance, this video (https://youtu.be/obu_Ru2gDHk) about an autonomous tractor running ROS, built by Kyler Laird of the ROS Agriculture group.

Why ROS?

The question then is this: why has ROS emerged on top of all the other possible contestants? None of them is worse than ROS in terms of features. Actually, you can find some features in all the other middlewares that outperform ROS. If that is so, why or how has ROS achieved the status of becoming the standard?

A simple answer from my point of view: excellent learning tutorials and debugging tools.

Here is a video where Leila Takayama, early developer of ROS, explains when she realized that the key for ROS to be used worldwide would be to provide tools that simplify the reuse of ROS code. None of the other projects have such a set of clear and structured tutorials. Even less, those other middlewares provide debugging tools in their packages. Lacking those two essential points is preventing new people from using their middlewares (even if I understand why the developers of OROCOS and YARP for not providing it… who wants to write tutorials or build debugging tools… nobody! 😉 )

Additionally, it is not only about Tutorials and Debugging-Tools. ROS creators also managed to create a good system of managing packages. The result of that is that developers worldwide could use others’ packages (relatively) easily. This created an explosion in available ROS packages, providing almost anything off-the-shelf for your brand-new ROSified robot.

Now, the rate at which contributions to the ROS ecosystem are made is so fast that it makes ROS almost unstoppable in terms of growth. According to ABI Research, about 55% of the world’s robots will include a ROS package by 2024. This is an indication of the fact that in ten years, ROS has become a defacto robotics standard, in academia and increasingly in industry.  More and more universities are teaching robotics  with ROS. The ROS Curriculum For Campus project that we launched in 2018 has been used by hundreds of universities. It is easy to see why ROS has become a must-have skill in the CV of robotics practitioners.

How to start learning ROS

Now, if you are convinced about becoming a ROS developer 😉 then using this beginner’s guide, we can follow these five steps to successfully learn ROS:

  1. How to learn ROS
  2. How to install ROS & ROS  2
  3. Start coding on ROS 
  4. How to test your ROS programs

Explore the chapters…

CHAPTER 1: How to Learn ROS

5 ROS learning methods

For true beginners. Discover the prerequisites for learning ROS, 5 ROS learning methods, and learn how to ask questions about ROS.

CHAPTER 2.1: How to Install ROS on Ubuntu 18.04

Setting up ROS

Learn step-by-step how to install ROS Melodic in a fresh Ubuntu 18.04.

 

CHAPTER 2.2: How to Install ROS 2 Crystal over Ubuntu 18.04 and ROS Melodic

Setting up ROS

Learn step-by-step to install ROS 2 Crystal in a fresh Ubuntu 18.04.

CHAPTER 3: Start Coding on ROS

Create your ROS programs

In order to create ROS programs, you will need a C++ or Python code editor. In this chapter, we are going to show you a list of integrated environments for programming ROS with those languages.

CHAPTER 4: How to Test Your ROS Programs

Make sure your ROS programs work properly

Learn how you can test the ROS programs you are developing for a robot. 

How to Test Your ROS Programs

How to Test Your ROS Programs

How can you test the ROS programs you are developing for a robot? If you are building a program for a robot, you have to make sure that it works properly, and for that, you need some tests.

If you think that you should test your programs directly on the robot, think again. Testing on the real robot is the last of the steps you will need to do in a testing procedure.

Why shouldn’t you test on the real robot first?:

  • Because you can break the robot or harm somebody. When you start testing your code, many things could be wrong in your program, which can make the robot go crazy and crash into something. We are not talking about mobile apps here!! We are talking about physical stuff that can be broken or harm somebody.
  • Because testing on the robot takes a lot more time than testing on your local machine. To test on a real robot, usually you will need to have a physical setup that you need to rebuild every time you test (because by doing the test, the physical robot or things in the environment will change position and need to be reset).

Jumping-from-simulatio-to-real-robot-using-vpn-ROS-DEVELOPMENT-STUDIO

Testing with the real robot is mandatory for the creation of a program for a robot (at least at present). However, it is the last of the steps in the testing procedure.

The proper procedure for developing for robots works as follows:

  1. You create the ROS program on your computer.
  2. You test in some way on your computer that the program works.
  3. Based on the test results, you modify the program until the local testing works properly.
  4. Once you are sure that your program works correctly on your computer, then you test it on the real robot.
  5. You will see that on the real robot, the results differ from your local tests. Then, you need to modify the code again, as well as the local tests, in order to reflect the points that were not working on the robot
  6. Repeat the whole testing cycle until it works on your local machine first, and then on the real robot.

IMPORTANT: If you want to develop fast and with as little hassle as possible, you should never go and try your code on the robot until it works properly in the local test environment. If the code doesn’t work in your local tests, it is never going to work on the real robot!

Then the question is, how do you test your programs on your local machine?

Well, you have several options for how to test your ROS programs without having to use a robot.

LEVELS OF TESTING

(This section’s information was extracted from ROS wiki)

Level 1. Library unit test (unittest, gtest): A library unit test should test your code sans ROS (if you are having a hard time testing sans ROS, you probably need to refactor your library). Make sure that your underlying functions are separated out and well tested with both common, edge, and error inputs. Make sure that the pre- and post- conditions of your methods are well tested. Also, make sure that the behavior of your code under these various conditions is well documented.

Level 2. ROS node unit test (rostest + unittest/gtest): Node unit tests start up your node and test its external API, i.e. published topics, subscribed topics, and services.

Level 3. ROS nodes integration/regression test (rostest + unittest/gtest): Integration tests start up multiple nodes and test that they all work together as expected.

Level 4. Functional testing: At this level, you should test the full robot application as a whole. Check that the robot is able to navigate, to grasp, to recognize people, etc… You will need to devise some tests that allow you to check that your code is still working on those functionalities. Usually, the tests are done using simulations or bag files.

CREATING TESTS FOR LEVELS 1,2, AND 3

In order to create tests for those levels, you will need to use the following libraries and packages:

  • Specifically for Level 1 tests:
    • gtest: Also known as Google Test, it is used to build unit tests in C++. You can get the full documentation about using gtest with ROS at this link.
    • unittest: The framework provided for doing unit tests in Python. You can get a full documentation about using unittest with ROS at this link.
  • Additionally, for Level 2 and 3 tests:
    • rostest: It is a package provided by ROS that allows the creation of nodes with specific configurations to test that your whole ROS program is working properly inside the ROS framework by executing unit tests from within. That is why, for the creation of tests for those two levels, we need to combine code>rostest with either code>gtest (C++ case) or unittest (Python case). You can get a full documentation about using code>rostest at this link.

CREATING TESTS FOR LEVEL 4

Level 4 tests are the ones that allow us to test if the program is actually doing what it is supposed to do. For testing that, we have three different options, from furthest to closest to reality.

Using mocks for testing

If you are a developer, you already know what mocks are. You can create your own mocks that emulate the connection to the different parts of the ROS API of your robot. On this page, you will find information about how to use mocks in ROS.

Working with mocks in ROS is not an easy option since it requires a lot of preparation work. Also, it is of very limited usefulness since it can only produce what you have put on it previously. Using mocks is an option that I don’t really recommend for developing. Use it only if you cannot use any of the other options below or if you are creating unit tests for your code. In my personal experience, I have never used them, having always used one of the next two options.

Anyway, if you want to use mocks for your testing, then I recommend that you use the Google Test environment: https://github.com/google/googletest.

Using ROS bags for testing

ROS provides a way to record in a log file the full ROS API of a robot while it is running in a real-life situation, and then run it back later on another computer. This log file is called a ROS bag. When you run a ROS bag on another computer, the computer will be showing your programs the same ROS API that it had when it was recorded.

You can learn how to use ROS bags here: record and replay of ROS bags (http://wiki.ros.org/rosbag).

ROS bags are a limited system in the sense that you can only use them when you want to create an algorithm that does something from sensor data. This means that you cannot generate commands to the robot because it is only a reproduction of data, so you can get the same data as the robot got when recorded, but you cannot decide new actions for the robot.

Using simulations for testing

So, if you want to go pro without having to use a real robot, you should use simulations of robots. Simulations are the next step in software development. This is like having the real robot on your side, but without having to care for the electronics, hardware, and physical space. Roboticists consider simulations to be the ugly brother of robotics. Roboticists usually hate to use a simulation because it is not the real robot. Roboticists like contact with the real thing. But fortunately, we are talking with the opposite kind of people here, those who want to keep their hands off the hardware. For them, simulations are key.

Let me tell you one thing: even if roboticists do not admit it, robot simulations are the key to intelligent robots. More on that in future posts, but remember, you read it here first! (https://www.theconstruct.ai/simulations-key-intelligent-robots/)

In the case of simulations, you have a simulation of a robot running on your computer that can run and act like the real robot. Once the simulation is running, your computer will present to your programs the same ROS API that you would have had if you were in the computer of the real robot. That is exactly the same as in the case of the ROS bags, with the advantage that now you can actually send commands to the robot and the simulated robot will reply accordingly to your commands. That is awesome!

To use robot simulations, ROS provides the Gazebo simulator (http://gazebosim.org/) already installed. You only need to have the simulation of the robot you want to program for running. Usually, the company creators of the robot already provide the simulation of their robot, which you can download and run on the Gazebo simulator.

Installing simulations and making them run could be a little more of a hassle. In case you want to avoid all that work, I recommend you use our ROS Development Studio, which contains the simulations ready to be launched with a single click, as well as having ROS, IDE, and other useful tools.

DEBUGGING

You will also need to debug the code. Most of the IDEs we have presented provide integrated debugging tools on them. However, you can also use all the standard debugging tools used for typical C++ code, including but not limited to:

If you are a ROS beginner, check out the course ROS BASICS IN 5 DAYS to learn how to debug ROS programs, and you will learn the following by using robot simulations:

  • Introduction to the main Debugging Tools: Logs, RQT, ROSBag…
  • How to plot your Topic data
  • 3D Visualization of Complex data (RViz)
How to Install ROS on Ubuntu 18.04

How to Install ROS on Ubuntu 18.04

Hey ROS Developers!

In this post, we are going step-by-step to install ROS Melodic in a fresh Ubuntu 18.04. I’m using a regular desktop computer, the one I use to support me on ROS development.

Let’s do it!

Step 1 – Configuration

The first step is adding the ROS repository to your ubuntu sources.list

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

Secondly, add the keys for accessing it:

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Executing: /tmp/apt-key-gpghome.WudTyznLyJ/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: key F42ED6FBAB17C654: public key "Open Robotics <info@osrfoundation.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1

And finally, update your packages list:

sudo apt update
Hit:1 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]     
Get:5 http://packages.ros.org/ros/ubuntu bionic InRelease [4669 B]                              
Get:6 http://packages.ros.org/ros/ubuntu bionic/main amd64 Packages [569 kB]
Fetched 662 kB in 2s (406 kB/s)   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.

 

Great!

 

Step 2 – ROS Installation

We have some options at this point. They are:

a. ROS Base

It installs ROS packagebuild and communication libraries.

It is recommended for embedded computers, where you don’t have much hardware for graphical tools or real robots (in the production stage) to run their specific tasks, without the need of debugging.

sudo apt install ros-melodic-ros-base

 

b. ROS Desktop

It installs ROS Base, rqt, rviz and robot-generic libraries

These are the basic packages for ROS development. It’s recommended for beginners to follow tutorials about ROS without having to install too much. RQT and RVIZ provides graphical interfaces for visualizing what is happening behind the scenes. With this option, you don’t have to work only using shell.

sudo apt install ros-melodic-desktop

 

c. ROS Desktop Full

It installs everything of ROS Desktop option plus 2D/3D simulators and 2D/3D perception.

If you want to simulate using ROS default Gazebo version, that’s your option. The Gazebo versions that comes with ROS Melodic is 9.0. (Related post: All about Gazebo 9)

sudo apt install ros-melodic-desktop-full

For convenience, I’m installing the ROS Base option, because I want to have a faster installation. After running the command, you must have a confirmation at the end of the output in your terminal:

0 upgraded, 485 newly installed, 0 to remove and 3 not upgraded.
Need to get 234 MB of archives.
After this operation, 1132 MB of additional disk space will be used.
Do you want to continue? [Y/n]

As you can see, ~1 GB will be installed.

Just press enter to confirm. It may take a while. A progress bar must be shown at the bottom:

Go and have a coffee =)

In the end, just a regular message about the last packages installed:

Setting up ros-melodic-nodelet-topic-tools (1.9.16-0bionic.20190601.015001) ...
Setting up ros-melodic-nodelet-core (1.9.16-0bionic.20190601.015433) ...
Setting up ros-melodic-roswtf (1.14.3-0bionic.20190601.014658) ...
Setting up ros-melodic-ros-comm (1.14.3-0bionic.20190601.015500) ...
Setting up ros-melodic-ros-core (1.4.1-0bionic.20190601.015718) ...
Setting up ros-melodic-ros-base (1.4.1-0bionic.20190808.193524) ...
Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

And you must have a free terminal ready to use again:

user@computer:~$

 

Step 3 – ROS Dependencies

We are almost there! ROS commands Client can also manage dependencies for you and rosdep is the one in charge of it.

That’s why we have to initialize rosdep. It goes like this:

sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

Similarly to ubuntu repositories, you need to update rosdep sometimes:

rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/ubuntu/.ros/rosdep/sources.cache

 

Step 4 – Configuring environment

We have ROS and the dependencies manager installed. Let’s configure our environment. This is a very important step, once we have it done, working with ROS will be smooth.

ROS is installed at /opt/ros/<distro> (in this case /opt/ros/melodic). In order to have ROS commands available, it’s needed to source the shell file inside of the installation folder. This is done like the following:

source /opt/ros/melodic/setup.bash

But.. considering we want to have it available in every terminal we open, we use to have a “shortcut”, which is adding this command to the file "/home/<user>/.bashrc". The .bashrc file is called every time a new terminal is opened, therefore, we won’t need to source ROS setup, since we have the instruction in this file. In order to add the command to the file, you can edit it manually using an editor of your preference or just execute the command below:

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

 

Step 5 – Testing it!

At this point, we must have everything in place. Let’s try some ROS commands to make sure the installation has finished successfully.

If you have the same terminal opened from the beginning, consequently, you have to execute the source for your .bashrc file to have ROS commands available.

source ~/.bashrc

And if you have added it to your .bashrc file, that’s the last time you will execute it =)

The first thing we should try it running roscore. In other words, we will run the process in charge of communicating everything ROS-related in a ROS environment.

roscore
... logging to /home/ubuntu/.ros/log/c70b2cce-e773-11e9-9f15-027a087bcd00/roslaunch-ip-172-31-31-24-15073.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ip-172-31-31-24:45551/
ros_comm version 1.14.3


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.3

NODES

auto-starting new master
process[master]: started with pid [15096]
ROS_MASTER_URI=http://ip-172-31-31-24:11311/

setting /run_id to c70b2cce-e773-11e9-9f15-027a087bcd00
process[rosout-1]: started with pid [15107]
started core service [/rosout]

Your terminal must be stuck here, therefore, you can’t execute anything else while you have roscore process there. roscore is running and ready to serve to other ROS processes!

Open a new terminal (your .bashrc will do the necessary source) and execute:

rosnode list
/rosout

 

Step 6 – Conclusion

That’s it for today! You have ROS Melodic installed and ready to use!

If you like this kind of content, don’t forget to share it with your colleagues.

Either you like it or not, please leave a comment so we can keep improving our material!

 

*References:

Learning path

Intro to Robot Programming – ROS

The must-have learning path for Robot Operating System (ROS) & Robotics beginners.

ROS for Beginners: How to Learn ROS

ROS for Beginners: How to Learn ROS

Now is the moment to start learning ROS.

We find many people that are new to ROS lack the basic skills necessary to start programming in ROS. That is why we have included a section of prerequisites here that you must meet before trying to get into ROS.

PREREQUISITES

You need to know in advance how to program in C++ or Python. Also, you need to be comfortable using the Linux shell. Those two are mandatory! If you still don’t know those two, I recommend you start learning how the Linux shell works and then move on to learning how to code in Python. If you don’t know C++, then do not worry about it now. Just learn Python and the Linux shell. We recommend the following free online courses:

As I already mentioned, ROS can be programmed with C++ or Python. However, if you don’t know C++ very well, do not try to get into ROS with C++. If that is your situation, please learn ROS with Python. Of course, you can start learning C++ now because C++ is the language used in the robotics industry, and you will need to make the transition from ROS Python to ROS C++ later. But your initial learning of ROS should be done by programming in Python. I know you are going to think that you can handle it and take both things at the same time. I do not agree at all. Bad decision. Good luck. Final comment: bindings for other languages, like Prolog, Lisp, Nodejs, and R, also exist. Find a complete list of currently supported languages here. I do not recommend for you to learn ROS with any of those languages though. ROS is complicated enough withuot having to complicate it further with experimental languages. Also, you will have plenty of time to practice with those once you know ROS with Python. [irp posts=”12071″ name=”Learn ROS with C++ or Python?”]

LEARNING ROS

If you have the basics of programming in any of those languages and of the use of the shell, the next step is to learn ROS. In order to do that, you have 5 methods to choose from.

Want to Master ROS and Launch Your Robotics Career?

We introduce you to the Robotics Developer Masterclass—your complete guide. This 6-month program will help you master robotics development from scratch and Get You 100% Job-ready to work at leading robotics companies.

Five methods to learn ROS

1- The official tutorials: ROS wiki

The official ROS tutorial website provided by Open Robotics, that is, the organization that builds and maintains ROS, is very comprehensive and it is available in multiple languages. It includes details for ROS installation, how-tos, documentation of ROS, etc. and it’s completely free. Just follow the tutorials provided on the ROS Wiki page and get started. This type of tutorial belongs to the traditional academic learning materials. They start by describing concepts one by one, following a well-defined hierarchy. It’s good material, but easy to get lost while reading, and it takes time to grasp the core spirit of ROS.

There is a long list of tutorials there. The list is so big that it can be overwhelming. If you decide to use this method to learn ROS, then we recommend that you follow the order of the tutorials below for optimal learning:

  • Navigating the ROS file system
  • Creating a ROS package
  • Understanding topics
  • Writing publishers and subscribers
  • Examining publishers and subscribers
  • Writing service client
  • Examining service client
  • Creating Msg and Srv
  • Understanding service params
  • Defining custom messages
  • Recording and playing back data
  • ROS TF
  • ROS URDF
  • ROS Control
  • ROS Navigation

learn-ros-in-5-days-robot-ignite-academy

2- Video ROS tutorials

Video tutorials provide a unique presentation that shows how programs are created and run, in a practical way. It allows you to learn how to carry a ROS project from the professional or instructor, which alleviates a beginner’s fear of starting to learn ROS, to a certain degree. There are plenty of ROS tutorials on Youtube. Just search for ROS tutorials and select among all the videos shown.

But there is a drawback, which is that anyone can create a video. There is no requirement for any sort of qualification to publish this content, and therefore, credibility might be shifty. Also, it is difficult to find an order to the videos, so as to provide a full learning path. We only recommend using this method when you want to learn about a very specific subject of ROS. One of the ROS video tutorial courses provided by Dr. Anis Koubaa from Prince Sultan University would be a great starting point for learning ROS. The course combines a guided tutorial, different examples, and exercises with increasing levels of difficulty along with the use of an autonomous robot. Another of the great resources is our YouTube channel. Sorry to mention it like that, but it is true, based on the comments people leave for us! On our channel, we teach about ROS basics, ROS2 basics, Gazebo basics, ROS Q&A, and even real robot projects with ROS. Please have a look at it and let us know if you actually find it useful or not. If you are looking for an answer to a specific ROS question, like How to read laserscan data? How to move a robot to a certain point? or ROS mapping…etc., check out our weekly ROS Q&A series. video-tutorials-ros-learning-methods-fig-2

3- ROS face-to-face training

Face-to-face instructional courses are the traditional way of teaching. They builds strong foundations of ROS into students. ROS training is usually a short course, which requires you to focus on learning ROS in a particular environment and period of time. There is interaction with instructors and colleagues. which allows you to get feedback directly. Under the guidance and supervision of instructors, it definitely encourages a better result. The following are some of the institutions that are holding live ROS training or summer courses on a regular basis:

When we talk about ROS face-to-face training, we are not including the conferences, since the learning that you can get there is both little and specific. ROS conferences are more for staying up to date on the latest progress in the field, rather than learning ROS. So, it is supposed that you go to the conferences with at least the minimum ROS knowledge in order to take any profit from them. Some of the ROS conferences around the world:

4- ROS Books

ROS books are published by experienced roboticists. They extract the essence of ROS and present a lot of practical examples. Books are good tools for learning ROS; however, they require a high level of self-discipline and concentration, so as to achieve the desired result. They are only as good as the person using them, and this depends on many factors. It allows for many distractions to easily affect your progress unless a strong sense of self-discipline can ensure that you pay full attention at all times. Here you have a list of ROS books so far:

5- Integrated ROS learning platform – Robot Ignite Academy

We have created an integrated learning platform as a new way of learning ROS fast. Compared to other learning methods, it provides a more comprehensive learning mechanism. It is the easiest and fastest of all the methods. On the platform, you will learn ROS by practicing on simulated robots. You will follow a step-by-step tutorial and will program the robots while observing the program’s results on the robot simulation in real-time. The whole platform is integrated into a web page, so you don’t have to install anything. You just connect by using a web browser from any type of computer and start learning. Well, perhaps the only drawback is it is not free. You can try the platform with a free account at www.robotigniteacademy.com. We have to tell you that many universities around the world are using this academy to teach their students about ROS and robotics with ROS; for instance, University of Tokyo, University of Michigan, University of Sydney, University of Reims, University of Luxembourg, etc., as well as companies like Softbank, 3M, , and HP.

HOW TO ASK QUESTIONS

It will happen that while learning or creating your own ROS programs, you will have doubts. Things that don’t work as the documentation indicates, strange errors that appear even if you’ve checked that everything is correct… you will need to get support from the community in order to keep improving. For that purpose, you can use two different channels to ask questions:

  • ROS answers: This is the official forum for questions about ROS. Use this forum to ask your technical questions about ROS. Also, you can use it for checking for previous answers to questions similar to yours. Finally, use it to help others by answering the questions that you already know.
  • ROS discourse: This is the second official forum. However, this forum is not about answering technical questions. Instead, it is about announcing things related to ROS. If you have created a new package that interfaces ROS with neural networks, or you are holding an event about ROS, or you are releasing a product about ROS, this is the place to post it. Do not use this forum for technical questions, but for announcements or questions related to the ROS community.

Conclusion

Out of all the methods presented here, I’m going to recommend to you our online Robot Ignite Academy because it is by far the fastest and more comprehensive route for learning ROS. This is not something that I say, but what our customers say. Our online academy has a price, but it will considerably speed up your learning of ROS. In case you don’t want to spend money and you are not in a hurry, then the best option would be to follow the wiki tutorials. They are a little bit outdated and it is a slow path for learning ROS, but they definitely work. After all, that is the method the authors of this guide used to learn ROS. As a final recommendation, besides delivering ROS at the Master of Robotics of LaSalle University, Ricardo delivers a free live online class about ROS every Tuesday at 18:00 CEST/CET (the ROS Developers Live Class). We recommend for you to attend since it is 100% practice-based and deals with a new ROS subject every week.

  Updated on 22 October 2019 

Download ROS Developers Guide

What is ROS?

What is ROS?

INTRODUCTION TO ROBOT OPERATING SYSTEM (ROS)

If you are reading this, it is because you either are or you want to become a ROS developer. Basically a ROS developer is somebody who wants to build programs for robots based on ROS. Yeah, but what is ROS? How can I learn ROS? How can I start developing with it? What is the most optimal development environment for it? All those questions will be answered in the following pages. But before we start with the practical things, let’s answer some basic questions about what ROS is and why it can be the door through which you can become a developer for robots.

WHY ARE THERE NOT ENOUGH DEVELOPERS FOR ROBOTICS?

In general, software developers do not like to deal with hardware. It is very likely that you are a developer and never thought about entering the robotics realm. You probably think that by programming for robots, you would need to know about electronics and maybe even mechanics. You probably think that hardware and software are too coupled in robots, and that you cannot touch one thing without touching the other. For example, some years ago, I had to make the navigation system for a robot. However, our navigation program was not working at all. We thought that it was something wrong with the program, but after extensive review, we found that it actually was a problem with the electronics of the laser scanner that we used to localize the robot. There were some micro-interruptions in the voltage level that made the laser reboot. In order to find that error, we had to go to the basics and find where the problem within the physical laser was. For that, you need to mess with the electronics. You have to take the laser out of the robot, put it on your table, and start experimenting. Different voltages, different interruptions to the power, all in order to try to reproduce the effect in a controlled environment. That is a lot of interaction with the hardware.
Interaction with hardware is something that many software developers don’t like. After all, they decided to become developers of software, not hardware!!

ROBOTICISTS PROGRAMMING ROBOTS

Due to that, the programming of robots has been done by roboticists, who are the people that build the robots. Maybe some of them are not directly involved in the creation of the robot, but definitely they have no problem getting into the hardware and trying to fix some hardware problems, in order to make their program work. But let’s face it, most roboticists are better developers than programmers. That is why robotics could benefit so much from having lots of expert programmers coming to the field. The good news is that getting developers into the field is more possible than ever. Thanks to the Robot Operating System, ROS, you can completely abstract the hardware from the software, so you can program a robot just by knowing the robot ROS API. By using the ROS API, you can forget about the hardware and just concentrate on the software that makes the robot do what you want.

WHAT IS THE ROBOT ROS API?

The ROS API is the list of ROS topics, services, action servers, and messages that a given robot is providing to give access to its hardware, that is, sensors and actuators. If you are not familiar with ROS, you may not understand what those terms mean. But simply put in the developers’ language, topics/services/messages are like the software functions you can call on a robot to get data from the sensors or make the robot take action. It also includes the parameters you can pass on to those functions. Most modern robot builders are providing off-the-shelf ROS APIs, like for example, ROS- Components shop that provides all its hardware running with a ROS API. If the robot you want to work with does not run ROS, you can still make the robot work with ROS by ROSifying it. To ROSify means to adapt your robot to work with ROS. To ROSify a robot usually requires knowledge to access the hardware. You need to learn how to communicate with the electronics that provide the sensor data or access the motors of the robot. In this series of ROS tutorials, we are not dealing with that subject because it gets out of scope for developers. But if you are interested in this topic, you can learn more about it in this Robot Creation Course.
So for the rest of the tutorials, we will assume that you have access (or are willing to have access) to a robot that is ROSified.

WHAT IS ROS ANYWAY?

ROS stands for Robot Operating System. Even if it says so, ROS is not a real operating system since it goes on top of Linux Ubuntu. ROS is a framework on top of the O.S. that allows it to abstract the hardware from the software. This means you can think in terms of software for all the hardware of the robot. And that’s good news for you because this implies that you can actually create programs for robots without having to deal with the hardware. Yeah!

ROS FOR SERVICE ROBOTS

ROS is becoming the standard in robotics programming, at least in the service robots sector. Initially, ROS started at universities, but quickly spread into the business world. Every day, more and more companies and startups are basing their businesses in ROS. Before ROS, every robot had to be programmed using the manufacturer’s own API. This means that if you changed robots, you had to start the entire software again, apart from having to learn the new API. Furthermore, you had to know a lot about how to interact with the electronics of the robot in order to understand how your program was doing. The situation was similar to that of computers in the 80s, when every computer had its own operating system and you had to create the same program for every type of computer. ROS is for robots like Windows is for PCs, or Android for phones. By having a ROSified robot, that is, a robot that runs on ROS, you can create programs that can be shared among different robots. You can build a navigation program, that is a program to make a robot move around without colliding, for a four-wheeled robot built by company A and then use the same exact code to move a two-wheeled robot built by company B… or even use it on a drone from company C.

SOME COMMONLY ASKED QUESTIONS

Which operating system should be used with ROS?

ROS works on Linux Ubuntu or Linux Debian. Experimental support already exists for OSX and Gentoo, and a version for Windows in underway, but we really don’t recommend for you to use them yet, unless you are an expert. Check this page for more information about how to use ROS on those systems. If you don’t know how to work with Linux, I recommend you start with this free Linux for Robotics course.

HOW TO DEVELOP FOR ROBOTS WITH ROS

Now, if you are convinced you want to become a robotics developer, in this series of ROS tutorials, you are going to find the steps that you can take to become a ROS developer. We have divided the tutorial series into the following sections that should cover the whole development process: • Setting Up • Learning • Coding • Testing Let’s go, one by one. [irp posts=”14751″ name=”ROS for Beginners: How to Learn ROS”] To access the full guide, click the orange button below, or go to RobotIgniteAcademy.com.
Download ROS Developers Guide

Pin It on Pinterest