Getting Started with ROS2: Overview of ROS2 Workspaces, Packages and Nodes

Part 4 of our “Getting Started with ROS2” Series

Sagar Kumar
Spinor
5 min readJul 2, 2024

--

Welcome, fellow readers, to our “Getting Started with ROS2” series! In this series, we aim to provide you with a comprehensive introduction to ROS 2 and will guide you through the fundamentals, its key concepts, and practical applications. If you have never used the Robot Operating System(ROS) before, even ROS 1, or if you want a practical and quick refreshment of the basics then this series is for you. Feel free to explore the links provided for a more in-depth understanding of the concepts discussed.

Here are the articles in the series:

  1. Getting Started with ROS2: An Introduction
  2. Getting Started with ROS2: Why ROS2?
  3. Getting Started with ROS2: Install and Setup ROS2 Humble on Ubuntu 22.04(LTS)

In our first article, we laid the groundwork by introducing you to the basic concepts of ROS 2. In our second article, we dig deeper into the rationale behind using ROS 2. Our third article provided a step-by-step guide to installing and setting up ROS2 Humble on Ubuntu 22.04 (LTS), ensuring you have a working environment ready for development.

Now, in our fourth article, we will guide you through an overview of ROS2 workspaces, packages, and nodes, explaining their roles and how they fit into the ROS2 ecosystem. This foundational understanding will prepare you for the deeper dives we will take in future articles dedicated to each of these essential components. So let’s get started!

Hierarchy of ROS2: Workspaces, Packages, and Nodes

Here’s a structured hierarchy that represents the relationship between ROS2, workspaces, packages, nodes, and their intercommunication:

ROS2
├── Workspaces
│ ├── Packages
│ │ ├── Nodes
│ │ │ ├── Publishers
│ │ │ ├── Subscribers
│ │ │ ├── Services
│ │ │ ├── Clients
│ │ │ └── Actions
│ │ ├── Launch Files
│ │ ├── Configuration Files
│ │ └── Resources
│ └── src (Source Directory)
│ └── Packages
├── Communication
│ ├── Topics
│ ├── Services
│ └── Actions
├── Tools
│ ├── colcon
│ ├── ros2cli
│ └── rviz2
│ └── rqt_graph
└── Ecosystem
├── Middleware (DDS)
├── Libraries
└── Community

Explanation of the Hierarchy

  1. ROS2: The overarching framework that enables modular and scalable development of robotic applications.
  2. Workspaces: The top-level directories where ROS2 packages are developed and built. Workspaces can contain multiple packages and facilitate organizing large projects. A workspace typically contains a `src` directory where the source code for packages resides.
  3. Packages: The fundamental building blocks in ROS2. Each package can include multiple nodes and other resources. Packages are designed to be reusable and modular, containing everything needed to run nodes, such as source code, launch files, and configuration files.
  4. Nodes: Executable processes(like a Python or C++ script) that perform computations in ROS2. Nodes communicate with each other using topics, services, and actions.
    - Publishers: Nodes that send data to topics.
    - Subscribers: Nodes that receive data from topics.
    - Services: Nodes that provide a request-reply communication mechanism.
    - Clients: Nodes that request services.
    - Actions: Nodes that provide goal-oriented communication, allowing for feedback and results over time.
  5. Intercommunication: The ways in which nodes interact within the ROS2 environment.
    - Topics: Channels for nodes to publish and subscribe to data streams.
    - Services: Synchronous communication mechanism where a node sends a request and waits for a reply.
    - Actions: Asynchronous communication mechanism where nodes can send goals, receive feedback, and get results.
  6. Tools: Various tools that assist in developing, building, and debugging ROS2 applications.
    - colcon: Build tool used to build ROS2 packages.
    - ros2cli: Command-line interface for interacting with ROS2.
    - rviz2: Visualization tool to visualize the state of the robot and the environment.
    - rqt_graph: A graphical tool that visualizes the ROS2 computation graph, helping to understand how nodes and topics are interconnected.
  7. Ecosystem: The broader environment that supports ROS2 development.
    - Middleware (DDS): The communication middleware that ROS2 relies on, typically DDS (Data Distribution Service).
    - Libraries: Core libraries and third-party libraries that provide additional functionality.
    - Community: The collaborative and open-source community that contributes to the development and improvement of ROS2.
Illustration of ROS2 Workspace
Illustration of ROS2 Package
Illustration of ROS2 Packages

The hierarchy represents how different components in ROS2 are organized and interact with each other. At the top is ROS2, which provides the framework for robotic application development. Workspaces act as the main organizational units, containing packages where the actual code and resources are stored. Each package can have multiple nodes that perform specific tasks and communicate through topics, services, and actions. Tools like colcon and ros2cli aid in managing and building these packages, while the ecosystem, including middleware and libraries, supports the overall functionality and development process.

By understanding this structure, users can see how individual components fit together, enabling them to develop and maintain complex robotic systems efficiently.

What’s Next?

In the upcoming articles, we will dig deeper into each of these essential components:

  • A comprehensive look at nodes, their types, and how they interact within a ROS2 system.
  • Detailed guidance on setting up and managing workspaces for efficient development.
  • An in-depth exploration of packages, including best practices for structuring and maintaining them.
  • We’ll also cover other crucial components of ROS2, such as topics, services, actions, tools like rviz2 and ros2cli, and much more, to provide a well-rounded understanding of the ROS2 ecosystem.

If you’ve made it this far, it means you’re not just interested — you’re committed, and we’re delighted to have you here!

Your interest and engagement inspire us to create more content and share knowledge with fellow learners, the community of robotics, and tech enthusiasts who share our passion.

So, thank you for being a part of this journey with us. Stay tuned for more insightful articles, tutorials, and practical examples as we continue our exploration of ROS 2 together.

References

--

--

Sagar Kumar
Spinor
Editor for

Sagar is a computer vision and robotics expert with a focus on Perception & Localization | Twitter: twitter.com/sagarcadet | Linkedin: linkedin.com/in/sagark30