Robots have a wide range of uses, spanning industries such as shuffle ordering manufacturing, logistics, agriculture, healthcare, and many more. While industrial robots have seen extensive growth for decades, the service robot industry is currently seeing explosive growth. As a class, robots are a complex integration of various engineering specialties including, but not limited to, electrical, electronic, mechanical, pneumatics, hydraulics, and sensors. As such, the development of all these systems that support a robot’s design is time consuming and complex. To help roboticists develop, design, apply, and model a robot's behavior, the Robot Operating System (ROS) was created by students at Stanford University. The current version of ROS is ROS 2, which improves on the original ROS. This learning module discusses ROS basics as well its updated version, ROS 2, along with some programming and application examples utilizing the Avnet ZUBoard 1CG and the AMD Kria™ KR260 Robotics Starter Kit.
Related Components | Test Your Knowledge
2. What is the Robot Operating System (ROS)?
The Robot Operating System is an open-source collection of software libraries and tools that simplifies the process of creating robots and robotic applications. ROS has a cross-platform framework that enables creators to reuse existing applications across several platforms, including arms, drones, and mobile bases, promoting standardization. ROS supports hardware abstraction, device drivers, libraries, visualizers, message passing, package management, and other features. The ROS framework works alongside a traditional operating system, typically running on an embedded operating system, such as Embedded Linux.
Figure 1: Kria™ KR260 Robotics Starter Kit with native ROS 2 support enables roboticists
to develop robots using an adaptive compute platform. Source: Webinar
3. What are the benefits of ROS?
The ROS provides a variety of benefits, including:
- Ecosystem: ROS provides a rich package ecosystem for many robotics applications, including sensing, motion planning, control, mapping, and navigation.
- Flexibility: The hardware-independent nature of ROS enables programmers to modify it to work with several kinds of robots, including mobile robots, robotic arms, and drones.
- Open Source: ROS supports several operating systems, including Linux, macOS, and Windows, opening it up to a wider range of users.
- Operating Systems: The hardware-independent nature of ROS enables programmers to modify it to work with several kinds of robots, including mobile robots, robotic arms, and drones.
- Safeguarding of proprietary code: Several fundamental ROS packages are accessible under permissive open-source license that allow companies to utilize and adapt ROS commercially without making their code publicly available.
- Test and validation: ROS offers simulation tools, such as Gazebo, that allow testing and validating robot behaviors in virtual settings before deploying them in the real world.
- User Base: ROS has a large and active community, which contributes to the creation of new packages, libraries, and documentation.
4. How did ROS get started?
In 2006, Wyrobek and Berger created the Stanford Personal Robotics Program to address the issue of communication between processes and code creation tools. They built a Personal Robot (PR) as a test bed and provided ten robots to universities for software development. They received $50k in funding while at Stanford, but needed additional funding to build a universal system, as well as to provide robots to research groups. In 2008, Scott Hassan, investor, and founder of Willow Garage, funded their project and started a Personal Robotics Program within Willow Garage. ROS was born. They began development on PR2. The first distribution, ROS Mango Tango, was released in 2009. The team named distributions after turtle types, with distributions including Box Turtle, ROS C-Turtle, Diamond Back, ROS Electric Emys, ROS Fuerte Turtle, and ROS Groovy Galapagos. In 2010, 11 PR2 robots were built and provided to 11 universities for robotics software development using ROS.
5. Description of the ROS Framework
As previously stated, ROS is an open-source framework for writing robot software, typically running on an embedded operating system such as Linux. It offers hardware drivers, robot models, datatypes, and support for perception and Simultaneous Localization and Mapping (SLAM). ROS also provides tools like Rviz for 3D visualization and Gazebo for simulators. In addition, using ROS to simulate and model robotic systems enables verification before deployment, a step that is essential for fast development.
- Framework / Architecture: ROS can be described through three levels of concepts: the Filesystem, the Computation Graph, and the Community. The Filesystem level mainly covers ROS resources encountered on disk. The Computation Graph level represents the core functionality of ROS, i.e., the network of ROS processes responsible for data processing. The Community level relates to the resources, such as repositories and distributions, that enable software exchange among developer communities.
Figure 2: The Main Components of ROS. Source: Researchgate.net
The exchange of data in a one-to-one fashion is done using a Service, which is defined in ROS as a pair of messages, a request and a reply. A service is defined by a providing node, and clients can call it and send request messages. ROS uses XMLRPC – a stateless HTTP-based protocol – to enable remote procedure calls. Such a protocol is used to expose functions such as registration APIs for publishers and subscribers or even by nodes to expose parts for one-to-one communications. - The ROS Filesystem: The ROS Filesystem has a hierarchical structure that enables the effective organization and management of resources. Figure 3 illustrates the ROS filesystem. The ROS filesystem leverages packages as the basic building blocks of functionality, organizing related packages into stacks for a common purpose, and bundling versioned stacks into distributions to provide a comprehensive and standardized set of ROS software for various robotic applications. These basic building blocks include:
- Packages are the fundamental unit within the ROS software organization, containing nodes, external libraries, data files, configuration files, and an XML configuration file called "manifest.xml." They encapsulate and organize specific pieces of ROS functionality or software components.
- Stacks are collections of packages grouped for a common purpose or functionality, providing a higher-level organizational structure in ROS.
- Metapackages are specialized ROS packages that contain a package manifest without other files like code or tests. Developers use them to group and represent related packages.
- The package manifest is an XML file located in the root folder of a package or meta package, containing metadata about the package's properties like name, version, authors, maintainers, and dependencies.
- Message (msg) types are stored in .msg files and describe the data structures that are contained in ROS messages. The robot subsystems in ROS use messages to exchange data, which can be primitive types like numbers, strings, Booleans, or complex compound types.
- Test and validation: ROS offers simulation tools, such as Gazebo, that allow testing and validating robot behaviors in virtual settings before deploying them in the real world.
- ROS services help nodes communicate with each other, for example, sensor_msgs/SetCameraInfo for camera calibration. They use a simplified service description language and are stored in .srv files within the /srv/ subdirectories of packages.
Figure 3: ROS Filesystem Level. Source: Circuitcellar.com
6. What is ROS 2?
The Open-Source Robotics Foundation (OSRF) created ROS 2.0 to solve several deficiencies in the older ROS, including single point of failure, lack of security, and limited real-time control capabilities. These shortcomings hindered its adoption in the industrial sector. The newer version has improved reliability, safety, and real-time capabilities.
ROS 2 is a redesign of the framework and purpose-built to industry standards. The purpose of ROS 2 is to offer a standard software platform to developers across industries that will carry them from research and prototyping to deployment and production. Developers can install new packages alongside ROS 1 to facilitate migration to a more secure platform, incorporating new technologies and updated APIs.
The features of ROS 2 features include discovery, transport, and serialization over DDS (Data Distribution Service), support for multiple DDS implementations, a common core client library, publish/subscribe over topics, a ROS 1/ROS 2 communication bridge, DDS security support, quality-of-service settings for non-ideal networks, composition of node requirements, and support for nodes with managed lifecycles.
7. What are the differences between ROS 1
and ROS 2?
The differences between ROS 1 and ROS 2 fall into three main categories: Architecture, Features, and Tooling/Ecosystem. The following are the main differences:
- Architecture: ROS 1 uses the ROS Controller-Node Architecture and XML-RPC middleware. In contrast, ROS 2 uses DDS for higher efficiency, reliability, low latency, scalability, and configurable quality of service (QoS) parameters. While XMLRPC is suitable for simple remote procedure calls, DDS supports real-time systems and removes communications from single points of failure.
- Backward Compatibility: ROS 2 is not backward compatible with ROS 1, meaning that ROS 1 packages may not work with ROS 2 without some reworking. However, tools like ROSbridge can simplify the transition.
- Communication: ROS 2 utilizes industry standard communication methods that are widely deployed in industrial applications. These include IDL (Interface Definition Language), DDS, and DDS-I RTPS (DDS Interoperability Wire Protocol - Real-Time Publish Subscribe Protocol). Its use of DDS and DDS allows for superior real-time processing, especially when deterministic, low-latency communication is needed.
- Libraries: ROS 1 has two separate libraries, roscpp for C++ and rospy for Python, which have a gap in feature-parity. ROS 2 has a base library, rcl (ROS client library), written in C. Libraries are built on top, ensuring core functionality is available in different APIs. This allows ROS2 to offer language support for additional languages, such as Java and C#.
- Licensing: ROS 2 code is licensed under the Apache 2.0 License, while ROS 1 code is ported under the 3-clause BSD License. Both licenses permit use of the software without affecting the user's intellectual property.
- Message Data: In ROS 1, message data is stored in the bag file format, created by tools such as rosbag. In ROS 2, rosbag provides more serialization flexibility than with ROS.
- Operating Systems: ROS 1 was primarily built for Ubuntu, while ROS 2 runs on various operating systems, including Linux, Windows, and macOS.
- Tooling changes: Tooling changes between ROS 1 and ROS 2 include the replacement of Catkin with Ament as a build system, and overlays, a secondary workspace that you can customize without affecting the primary workspace.
Figure 4: A Comparison of ROS 1 and ROS 2. Source: Researchgate.net
ROS 1 and ROS 2 have some additional differences. As illustrated in Figure 4, ROS 2 uses a peer-2-peer protocol, while ROS is a controller-node protocol. With ROS, parameters describe the configuration of nodes. In ROS 1, a parameter server controls the parameters, however, there is no global parameter server in ROS 2. Each parameter is specific to a node. Services in ROS 1 are synchronous, meaning requests are stuck until the server responds or fails. In contrast, ROS 2 uses asynchronous services. Actions were never part of the core functionalities in ROS 1 but were added to address the lack of asynchronous services and feedback mechanisms.
8. The Top 5 Questions about ROS
- Do robots have an OS?
Yes, robots have an OS, although it is not a conventional OS such as Windows, Linux and Android, but rather a meta-operating system that runs on the existing OS. - What is the robot operating system on Windows 10?
Microsoft officially supports the ROS1 Melodic Morenia and ROS 2 Dashing Diademata distributions, which are built on the Windows Subsystem for Linux (WSL). - Do robots use Linux?
ROS and several other robotics operating systems run on Linux. Ubuntu has provided the best development environment for robotics developers. - Is ROS C++ or Python?
Python and C++ are the most commonly used languages for ROS due to their support in the core libraries and tools of the framework. - What are the prerequisites for learning ROS?
To learn ROS, one must know a programming language, such as Python or C++, and be comfortable using the Linux shell. - Why use ROS2 over ROS1?
ROS 2 is an updated version of ROS 1, addressing its limitations and introducing several improvements, including Data Distribution Service (DDS) support. DDS provides real-time communication, scalability, performance enhancement, and security benefits not found in ROS 1.
9. For The ROS 2 Beginner: Example Projects - Basic Programs
Here are some basic ROS 2 programming examples. A basic knowledge of Linux terminal and python programming language is required for completing the projects. For an introduction to ROS2, read blogs here.
- Publisher - Subscriber We are going to write a simple publisher - subscriber program for finding the sum of n positive numbers. The program takes a positive integer as input and publishes it via a topic in a publisher node. Another subscriber node subscribes to the topic having the input data, calculates the sum of integers until the input number and displays it in the terminal. To see the entire project, click here
- Service Server - Client This project makes our sum of n positive integer numbers program into a service. A service package needs to be created using ament_cmake build tool. To see the entire project, click here
The previous two programs gave us an insight into the basic working of ROS 2 programs. Now let us take a step further in ROS2 programming. - Camera Stream We will create a publisher node to capture a video stream from a camera and publish it to a topic. We will create another subscriber node who will subscribe to the camera topic and display it in an OpenCV window. To see the entire project, click here
- Face Detection We will reuse the concepts of our camera stream nodes to create a publisher node that will capture a video stream from a camera, detects the faces inside the stream, overlay a rectangle over the detected faces and publish the overlayed image to a topic. We will reuse the camera stream subscriber node to subscribe to the camera topic and display it in an OpenCV window. To see the entire project, click here
10. For the Developer: Adaptive Computing for Robot Applications
Adaptive computing enables the optimization of hardware for specific applications by combining programmable logic and high-performance processors. The programmable logic provides the developer with the ability to implement high-performance parallel processing pipelines by writing C/C++ code using AMD tools, which make robotic functions responsive and deterministic. The use of adaptive computing also enables the system to be architected such that the programmable logic provides acceleration or offload of functions from the processing system and provides deterministic processing for safety-critical functions. As such, adaptive computing processors are well-suited to ROS applications since the processing system has the capability to execute operating systems and frameworks such as embedded Linux and ROS 2. Looking at the robotics landscape today, AMD and Avnet have created a list of off-the-shelf products that are production ready and equipped with the software stack to run ROS 2.
- Avnet ZUBoard 1CG for Robot Control The ZUBoard provides an adaptive computing platform for the control of robots. It can be set up to add support for ROS 2. The ZUBoard gives the developer access to the capabilities of the AMD Zynq™ UltraScale+ ZU1CG device. Designers can create designs for both the AMD Zynq UltraScale+™ MPSoC Processor Subsystem (PS) and the Programmable Logic (PL) fabric. The ZU1CG device features 81K programmable logic cells with a Dual-core Arm ® Cortex ®-A53 MPCore™ and Dual-core Arm Cortex-R5F MPCore, as well as cache and on-chip memory. The board also features 1GB of ISSI LPDDR4 with non-volatile boot options in the 256Mb ISSI QSPI Flash or a microSD card slot. The ZUBoard 1CG has an AMD Vivado™ software-enabled board definition file and AMD PetaLinux BSP (a preconfigured AMD PetaLinux build), making it an ideal base for exploring bare metal, Linux, or AMD Vitis™ AI software accelerators.
Figure 5: Avnet ZUBoard 1CG. Source: Avnet
Tips from hackster.io
Here are a few links from our friends at hackster.io that can assist developers utilizing the ZUBoard in robotics projects:
- ZUBoard - Adding support for ROS2
This project describes how to add support for ROS2 to the ZUBoard. - Controlling Robots with ZUBoard
This project is a Getting Started Guide to controlling a robot with hand signs for ZUBoard. - ZUBoard Motor Control Build Along
Interactive, live build-along teaches you to create an FPGA-based motor control application for a brushless DC (BLDC) motor using the Avnet ZUBoard and control it using AMD PetaLinux.
- ZUBoard - Adding support for ROS2
- AMD Kria™ KR260 Robotics Starter Kit The AMD Kria™ KR260 Robotics Starter Kit is an easy way to develop ROS 2-based robotics with adaptive computing. The kit pairs a non-production AMD Kria K26 SOM with a baseboard, containing the connections that are critical for robotics development. This provides developers the ability to start with an easy foundation and build upon it using design flows (ROS 2, C++, Python, FPGA RTL, etc.), as required. The kit simplifies hardware acceleration and offload of ROS 2 for Robotics, SLVS-EC vision sensors, and industrial interfaces like 10 GigE Vision, EtherCAT, and time sensitive networking (TSN), among others, to speed design and development. The software stack enabled on Kria KR260 to natively support ROS 2 is called Kria robotics stack.
- What is the AMD Kria™ Robotics Stack? The AMD Kria™ KR260 Robotics Starter Kit supports the AMD Kria™ robotics stack for roboticists. KRS is an integrated set of robot libraries and utilities that use hardware to accelerate the development, maintenance, and commercialization of industrial-grade robotic solutions. It adopts ROS 2 as the Software Development Kit (SDK) and proposes a ROS 2-centric development approach to enable a software defined, hardware-accelerated platform.
Figure 6: AMD Kria™ Robotics Stack. Source: AMD
- ROS 2 Perception Node Accelerated Application The ROS 2 Perception Node accelerated application (i.e., Perception-ROS app) is a good place to start because it is representative of a ROS 2 package with a decent computationally intensive workload to appreciate the acceleration. All users need is a KR260 and simulation environment like Gazebo that interfaces via a PC to Kria to get up and running. This application enables high-performance robotic perception through hardware acceleration of components of ROS 2 perception stacks, enables Gazebo simulation flows, and is a pathway to future design with the Kria robotics stack. At runtime, using the Perception-ROS App, users can expect up to 3.5X faster execution of common functions in the ROS 2 perception package.
Figure 7: Perception-ROS App. Source: AMD
Getting Started with the AMD Kria™ KR260 Robotics Starter Kit
The AMD Kria™ KR260 Robotics Starter Kit is built to be developer-friendly, which is reflected in the getting started experience. No FPGA experience is required. Follow these steps to get started:
- If you don't have an AMD Kria™ KR260 Robotics starter kit, you can get one here .
- To get started with the AMD Kria™ KR260 Robotics Starter Kit, prior to powering, booting the board, and running your first application, you need to follow the instructions on the Getting Started with AMD Kria KR260 Robotic Starter Kit pages to download and write the AMD SOM Starter Linux image to a microSD card. The webpage guides you to power on the AMD Kria KR260, boot Linux, and run a number of pre-built accelerated applications to start evaluation of the capabilities on the platform. click here.
- Launch the ROS 2 Perception Node Application, click here.
- If you need more information, go to the github pages for the Kria KR260 Robotics Starter Kit, click here.
*Trademark. AMD is a trademark of AMD Corporation. Other logos, product and/or company names may be trademarks of their respective owners.
For more AMD products Shop Now
Test Your Knowledge
Automation 5
Complete our Essentials: Robot Operating System 2 course, rate the document, take the quiz, and leave your feedback to earn this badge.
Are you ready to demonstrate your knowledge about Robot Operating Systems? Then take a quick 10-question multiple choice quiz to see how much you've learned from this module.
To earn the Essentials of Automation 5 Badge, read through the learning module and attain 100% in the quiz.