Skip to main content

Introduction to ROS 2 and Programming Foundation

  • Chapter
  • First Online:
Introduction to Intelligent Robot System Design

Abstract

With the evolution of robot technology, ROS has also improved significantly and is now widely being used. The number of packages in the ROS community has increased exponentially over the years, enabling significant progress in robot development. Additionally, many developers and research institutions have proposed improvements to address the limitations of ROS. However, these local function improvements often could not facilitate the enhancement of the overall performance. At ROSCon 2014, the next-generation ROS design architecture (Next-generation ROS: Building on DDS) was officially released. Numerous new technologies and concepts have been incorporated in the next-generation ROS, which not only includes a change in the overall architecture but also enhances the comprehensive performance of ROS 2. This chapter introduces three aspects of ROS 2: the design, installation and use, and programming foundation.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 84.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    https://roscon.ros.org

  2. 2.

    http://design.ros2.org/articles/ament.html

    https://docs.ros.org/en/foxy/How-To-Guides/Ament-CMake-Documentation.html

Author information

Authors and Affiliations

Authors

Appendices

Further Reading

AmentFootnote 2 compilation system in ROS 2: the "ament_cmake" build system and the "ament_tools" meta build tool.

The ament is an evolution of catkin, and the word ament is actually a synonym of catkin. ament is a meta build system to improve building applications, which are split into separate packages. It consists of two major parts:

  • a build system (e.g., CMake, Python setuptools) to configure, build, and install a single package

  • a tool to invoke the build of individual packages in their topological order

The tool relies on meta information about the packages to determine their dependencies and their build type. This meta information is defined in a manifest file called, which is specified in REP 140. Each package is built separately with its own build system. In order to make the output of one package available to other packages, each package can extend the environment in a way that downstream packages can find and use its artifacts and resources. If the resulting artifacts are installed into, for example, it might not be necessary to alter the environment at all since these folders are commonly being searched by various tools.

The ament_tools is a Python package, which provides the command line tool to build, test, install, and uninstall packages. It is similar to catkin_tools and builds each package in a workspace in topological order. Support for different build systems is integrated through extension points, which allows support for other build types to be added without changing the ament tool itself.

While it currently does not build packages in parallel that feature will be added in the future to speed up the build process. The goal is to reuse common functionality from catkin_tools by making it available through a third package, which can be used by both tools.

Each package can utilize a different build system to perform the steps of configuring, building, and installing. The build type is defined in each package manifest using the build_type tag in the export section. Currently supported are CMake and Python, but support for others (e.g., autotools, plain Makefiles) will likely be added in the future.

The catkin has been used for ROS 1 since ROS Groovy. It was developed as a replacement for rosbuild, which was used from the beginning of ROS. Therefore, various features of catkin have been designed to be similar to rosbuild. catkin is a single monolithic package providing various features and functionalities. For example, it integrates support for which makes it very difficult to also optionally support since only one tool can be selected at a time. The ament on the other hand is designed to be very modular. Almost every feature is provided by a separate package and can be optionally used. The CMake part of ament also features an extension point system to extend it with further functionality.

Exercises

  1. 1.

    Can mobile robots deploying ROS 1 be used on highways with high real-time requirements? What are the existing problems?

  2. 2.

    How many versions of ROS 2 are currently available? What are the differences between ROS 2 and ROS 1 in terms of the design framework? What are the differences in programming between ROS 2 and ROS 1?

  3. 3.

    What are DDS (Data Distribution Service) and its communication mechanism of ROS 2? What is its role?

  4. 4.

    Please design a program in ROS 2 to realize the function shown in the following figure. The small tank will walk in an elliptical path in a two-dimensional environment. Please explain the design idea, flow chart, and core procedures.

  5. 5.

    With reference to the official website of ROS 2, to write a node to realize service communication in ROS 2.

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Peng, G., Lam, T.L., Hu, C., Yao, Y., Liu, J., Yang, F. (2023). Introduction to ROS 2 and Programming Foundation. In: Introduction to Intelligent Robot System Design. Springer, Singapore. https://doi.org/10.1007/978-981-99-1814-0_11

Download citation

Publish with us

Policies and ethics