Robotics is a growing field in our world today as robots become more mainstream. The goal of robotics is to create robots that are mostly useful, can assist humans, or even replace humans, with more recent research aiming to make robots intelligent. Some examples of robots around us today are Sophia, the humanoid-like robot that was given official citizenship in Saudi Arabia, delivery robots and drones, and robot vacuums in our households among others. 

Sophia, the robot.
(Photo credit: ITU Featured Photos: AI for Good Global Summit 2018. 15-17 May 2018, Geneva)

A robot vacuum cleaner.
(Photo credit: Jazzyartphotos via Pixabay)

Robotics, as a branch of technology, encompasses different areas. It covers design, mechanical and electrical engineering, and programming. These different areas are necessary for the design, building, and operation of robots. You can build applications for controlling and operating robots using Python scripts. One of the most common middleware suites used to build and run these scripts is ROS. Middleware is the term used to describe software that enables the communication between multiple applications in a distributed system. 

This article is an introduction to robotics programming using ROS.

What is ROS?

ROS, pronounced as Ruhs, stands for Robot Operating System. Contrary to its name, it is actually not an operating system, ROS is an open-source set of libraries and packages that you can use to write programs for robots. It can be seen as a meta-operating system for the robot. 

ROS framework can easily be implemented in multiple languages. Currently, it has been implemented and currently supported for Python, C++, and Lisp, while still being experimented with in Java and Lua. Personally, I use the Python implementation with the Python library, Rospy being the major library.

ROS currently has two versions known as ROS 1 and ROS 2. ROS (also known as ROS 1) was created in 2007, and although a new version, ROS 2, was released in 2017, many people still use ROS 1. This is because it has more packages, richer debugging tools, and is more stable currently.

ROS 1 vs ROS 2

ROS 1 only works on Unix-based platforms and is compatible with Python 2, C++ 3, and C++ 11. ROS 2, on the other hand, works on Linux, macOS, and Windows 10, and is compatible with Python 3.5 and above, C++ 11, C++ 14, and C++ 17.  

Although the end of life of the most recent ROS 1 distribution (noetic) has been set to 2025, to avoid having fewer packages to use and to have access to more robust documentation, it is advisable to stick to ROS 1 if you are a beginner roboticist or a general robotics developer. This article will be focused on ROS 1.

ROS distributions

A ROS distribution is a versioned release of ROS packages. This lets developers work with stable releases with minimal changes and bug fixes. Any major changes will be made to the next distribution released. Some distributions come with Long term Support (LTS) which means they have been extensively tested and are generally more stable. The end of life (EOL) of LTS distributions is typically set to five years from release, after which it will no longer be actively supported. 

ROS could also support more than one version concurrently. The currently supported distributions in ROS 1 are ROS Noetic Ninjemys (EOL: May 2025) and ROS Melodic Morenia (EOL: May 2023). Deciding which distribution to use could be based on many factors such as your computer operating system, newer capabilities that you need in your program, or a specific platform or framework you need to use with your code (e.g OpenCV3 works with Kinetic, Melodic, or Noetic distributions, while OpenCV4 only works on Noetic. The main officially supported OS for ROS 1 distributions is Unix-based systems, so you might need to either boot Linux OS on your computer or set up a Virtual machine. I published an article earlier on how I was able to set up a virtual machine on my macOS Big Sur for this. However, you can also run ROS on Windows 10 for newer ROS 2 distributions like ROS Galactic Gechelone and ROS Foxy Fitzroy.

Why ROS?

ROS is used by the majority of the robotics code in the world today. It has been in existence for about fourteen years and has a large, active community of maintainers and users. ROS promotes modularity and is reusable. Projects are grouped in packages, composed of executables called nodes. ROS is scalable and suitable for very large development processes. ROS is language agnostic. This means that even if your node is written in Python, it can send messages and receive messages from a node written in C++.

ROS language implementations

The two major ROS language implementations are in Python and C++. The Python ROS implementation is rospy, a pure Python client library, while the C++ implementation is called roscpp. roscpp is the most commonly used ROS client library currently. With these libraries, you are able to write scripts and programs to operate robots, either in simulation or physically. 


In this article, I walked through an introduction to robotics programming using ROS, a robotics middleware suite. I hope this article is helpful to you and gives you a good introduction to the robotics programming world. This is the first article in my series about programming robots. The next article will cover how to create your first package and write your first script which we will develop later to operate a robot.

Thank you for reading.