A person learning Robot Operating System
Generated by DALLE

Unveiling the Power of ROS: A Beginner’s Journey into CLI Tools

Naveed Ul Mustafa
13 min readFeb 21, 2024

Embark on a thrilling exploration of the Robot Operating System (ROS) through the lens of a beginner. Discover the foundational blocks of ROS 2, from the intricate ROS graph to the dynamic communication models that empower robots to perform complex tasks. Dive into the world of nodes, topics, services, parameters, actions, and the indispensable rqt_console, all through the accessible command-line interface.

In the ever-evolving landscape of robotics, the ability to design, develop, and deploy sophisticated systems has become increasingly accessible, thanks in large part to the Robot Operating System (ROS). Whether you’re a seasoned robotics engineer or just embarking on your journey into this dynamic field, understanding the foundational elements of ROS can significantly amplify your capabilities. At the heart of ROS lies the concept of the ROS graph — a network that not only defines but also dynamically illustrates the interactions between nodes, the core entities within the ROS ecosystem. These nodes, designed to perform singular or multiple tasks, communicate through a robust set of mechanisms including publishing and subscribing to topics, offering and utilizing services, and executing asynchronous tasks via actions.

The beauty of ROS, encompassing both its first and second iterations — ROS1 and ROS2 — lies in its modular approach to building complex robotic systems. This approach fosters greater flexibility, scalability, and code reusability, which are essential for the iterative process of robotics development. From controlling actuators and gathering sensor data to making real-time decisions, ROS nodes work in concert to bring robotics applications to life. But how do these nodes interact? How do they share information, request services, and configure themselves for optimal performance?

As we delve deeper into this article, we’ll explore the intricacies of the ROS graph, uncovering the roles and relationships of nodes, topics, services, parameters, actions, and the invaluable debugging tools provided by the RQT console. This journey will not only demystify the complex web of communications within a ROS system but also equip you with the knowledge to harness the full potential of ROS in your robotics projects. So, whether you’re aiming to build your first robot or looking to refine your existing systems, let’s embark on this enlightening journey together, uncovering the secrets of ROS and how it continues to shape the future of robotics.

Deep Dive into Nodes

Diving into the world of robotics with ROS2 (Robot Operating System version 2) introduces us to a fascinating concept known as nodes. Imagine nodes as individual workers in a factory, each dedicated to a specific task. Some might be tasked with controlling the wheels of robots, while others focus on gathering precious data from sensors like a laser-range finder. This division of labor, or modularity, not only makes the system more flexible and scalable but also simplifies maintenance, testing, and code reuse. It’s like having a team where each member knows their job inside out, making the whole operation smoother and more efficient.

from ROS website

In the ROS2 ecosystem, a single program, whether written in C++ or Python, can house one or several of these diligent workers (nodes). This setup allows for a highly versatile and effective design, where an entire robotic system is a symphony of nodes each playing their part — be it processing sensor data, controlling actuators, or making crucial decisions.

Getting to grips with how nodes operate in ROS2 opens up a whole new perspective on managing a robotic system. For starters, after sourcing ROS2 in each new terminal, you can quickly see which nodes are currently active using the ros2 node list command in the Command Line Interface (CLI). This command is like taking a roll call, ensuring all your robotic workers are present and accounted for. If you need to introduce a new node to the system, it’s as simple as specifying what job it has (its package name) and what tool it will use (the executable name). For example, activating the turtlesim_node from the turtlesim package will bring /turtlesim into your list of active nodes, ready to perform its duties.

But what if you want to customize how these nodes identify themselves or communicate? That’s where remapping comes into play. Remapping is akin to giving your worker a new badge or a new set of instructions on whom to talk to or listen for. By executing a command like ros2 run turtlesim turtlesim_node –ros-arg –remap __node=my_turtle, you're essentially renaming the /turtlesim node to my_turtle, allowing for a more personalized and organized system. This flexibility can lead to a more efficient allocation of tasks and resources within your robotic ecosystem.

To delve deeper into the specifics of a node, such as who it talks to (subscribers), who listens to it (publishers), and the services and actions it can perform, the ros2 node info <node_name> command comes in handy. It's like getting a detailed profile of a worker, understanding their role, responsibilities, and interactions within the larger system. This insight is invaluable for debugging, optimizing, and scaling your ROS2 applications, ensuring each node contributes effectively to the robotic symphony.

By breaking down the operations and capabilities of nodes in ROS2 into more relatable terms, we can appreciate the elegance and power of this system in orchestrating complex robotic tasks. It’s not just about managing a collection of robotic elements; it’s about harmonizing them into an efficient, scalable, and flexible system that stands at the forefront of robotics innovation.

Understanding Topics: The Heartbeat of Robot Communication

Imagine you’re at a bustling robot party, where each robot has something important to share but also needs to listen in to catch the latest updates. In the world of ROS (Robot Operating System), this lively exchange is made possible through something called topics. Think of topics as the buzzing conversation threads that robots use to chat with each other, sharing and receiving updates without ever needing to know who’s on the other end. This is the magic of decoupled communication, enabling robots to work together seamlessly, sharing insights and data to perform complex tasks effortlessly.

from ROS website

Ever wondered how these robots figure out who to listen to or talk with? Enter the RQT graph, a visual spyglass into the world of robot chatter. For instance, after setting up ROS2 and starting a couple of robots named /turtlesim and /teleop_turtle, you can peek into their conversation using a command called rqt_graph. This reveals a fascinating web of interactions: you'll see /teleop_turtle eagerly sharing data on the /turtle1/cmd_vel topic, with /turtlesim tuned in to catch every bit of it. It's like mapping the stars in the robot universe, showing who talks to whom and about what.

from ROS website

Curious about what other topics are buzzing with activity? A simple command, ros2 topic list, acts like opening a directory of all ongoing robot conversations. Want more details, like what language (message type) they're using to chat? Just add -t to the command, and voila! You'll understand how these robots ensure they're all speaking the same language, making sure their messages are perfectly understood across the board.

To listen in on what the robots are actually saying, there’s a tool for that too! By using ros2 topic echo <topic_name>, you can see the messages flying back and forth in real-time. It's like tuning into a live broadcast of robot gossip, where you can see exactly what instructions or data are being shared.

Just like in any good conversation, understanding each other is key. ROS makes sure of this by using specific message types for topics, which you can explore with ros2 interface show <message_type>. This ensures that when a robot shares information, it's in a format that the receiver can understand and act upon, making their interactions as smooth and effective as possible.

Finally, if you’re curious about the popularity of a topic, ros2 topic info <topic_name> can tell you how many subscribers or publishers. It's like seeing the guest list for the hottest topic parties, showing you the pulse of robot interactions.

The Significance of Services: The Robot’s Concierge

Imagine you’re in a high-tech hotel where robots manage everything. When you need something specific, like a room service or a quick fix in your room, you don’t broadcast your request for every robot to hear. Instead, you use a direct line to ask for exactly what you need and wait for a confirmation that it’s done. This is precisely how services work in the world of ROS (Robot Operating System).

Services in ROS are special communication channels allowing one robot (or node, in ROS terms) to ask another robot for a specific task and get a direct response. It’s a bit like sending a text and waiting for a reply, ensuring that your request is heard and acted upon promptly. This setup is perfect for tasks where you need an immediate answer, such as checking if a door is open or asking a robot to move to a specific location and confirm when it arrives.

from ROS website

Curious about what services are currently on offer in your ROS-powered robot hotel? Just type ros2 service list into the command line. This is like checking the hotel directory to see what services you can request. Each service listed is a task that your robots can perform, from fetching sensor data to adjusting settings.

Every service comes with its own “menu” — a specific format for requests and responses. To see what’s on the menu, use ros2 service list -t. This reveals the types of requests you can make and what responses to expect. It's organized neatly, with a "---" acting as a divider: the first part shows you how to place your order (Request), and the second part explains what response you'll get.

Want to make a service request? The command ros2 service call <service_name> <service_type> is your go-to. This is like dialing the concierge to ask for a specific service, specifying exactly what you need. Through this, you can ask your robots to perform tasks and await their confirmation, ensuring that your request is handled efficiently.

In contrast to the general announcements made through topics, where robots broadcast information for anyone listening, services are the direct and private conversations between two parties. One robot asks for something to be done, and another robot responds directly after completing the task. It’s a more intimate and precise way of getting things done in the robotic world, ensuring tasks are completed with a personal touch.

Tweaking the Robot’s Brain: The Power of ROS2 Parameters

Imagine you’re playing a video game where you can customize your character’s skills, appearance, and abilities on the fly, without starting over or editing the game’s code. In the ROS2 world, this kind of customization is made possible through something called parameters. Parameters are like individual dials and switches for each robot (or node, in ROS terms). They can hold different types of information: numbers, text, true/false values, lists, and more. Each node has its own set of parameters, allowing for a high degree of customization. Want to see what parameters a node has? Just type ros2 param list into your command line. It's like peeking into the control panel of your robot.

Each robot comes with its own unique settings. For example, the /turtlesim node (a virtual robot turtle) has parameters for the background color of its window (background_b, background_g, background_r). Want to change the color? No problem. Use the command ros2 param get <node_name> <parameter_name> to see the current setting and ros2 param set <node_name> <parameter_name> <value> to change it. It's as easy as adjusting the color settings on your TV.

Curious about all the settings at once? The ros2 param dump <node_name> command lets you see every parameter for a node in one go. It's like having a complete list of all the customizable features at your fingertips. What if you’ve got the perfect setup and don’t want to lose it? ROS2 lets you save these settings in a file and load them whenever you start your node, ensuring your robot always wakes up just the way you like it.

Mastering ROS Actions: The Art of Long-term Robot Tasks

Think of ROS actions like sending your robot on a mission, where you not only tell it what to do but also expect updates along the way, and a final report when the mission is completed. These missions can be anything from a long journey across different terrains to solving a complex puzzle. ROS actions are designed to handle these tasks smoothly, providing feedback throughout the process and allowing for changes or cancellations if needed.

from ROS website

Every action in ROS is built on three key components:

  1. Goal: The mission you assign to your robot. It’s like saying, “Please go to the kitchen and fetch me a snack.”
  2. Feedback: The updates you receive as your robot makes its way to the kitchen. It’s as if your robot is texting you, “I’m in the hallway,” then, “I’m in the kitchen.”
  3. Result: The final outcome, which in this case would be, “I’ve got your snack!”

These components work together through a mix of ROS topics (for ongoing updates) and services (for starting and ending the mission).

Actions operate on a client-server basis:

  • The Action Client is like you, asking for that snack.
  • The Action Server is your robot, working to complete the task.

You can check who’s who in your ROS setup with ros2 node info <node_name>, which tells you whether a node is playing the role of a client or a server in any given action.

To see all the missions (actions) available in your ROS network, a quick ros2 action list will give you the overview. Want more details, like the specifics of each mission? Add -t to peek into the types of actions available, or use ros2 action info <action_name> for a deep dive into any specific action, revealing all involved parties and their roles.

When you’re ready to send your robot on a mission, ros2 action send_goal <action_name> <action_type> <values> is your command. Here, you specify what you want done, in what manner, and with any particular details (values) that need to be in a YAML format. It's akin to giving your robot a detailed map and instructions for its journey.

Navigating the RQT Console: Your Window into ROS2’s Inner Workings

Think of the RQT console as the control center for watching over your robot’s health and thoughts. It’s a part of ROS’s suite of graphical tools designed to make your life easier when it comes to understanding what’s happening inside your ROS2-powered robot. With rqt_console, you get a clear, user-friendly dashboard that shows you the messages your robot systems are sending out—kind of like reading texts from your robot, telling you how it's feeling and what it's up to.

from ROS website

The RQT console has:

  • The Message Display Area: Right at the top, this is where you’ll see all the messages (logs) your robot sends. It’s the main feed where you can catch up on everything happening in real-time.
  • Message Filtering: In the middle part, you have the power to filter messages based on how critical they are. It’s like setting up a filter to only see messages from your most important contacts. Plus, there’s a handy button to add even more specific filters, helping you cut through the noise and focus on what matters.
  • Search and Highlight: Down at the bottom, this section lets you highlight messages containing specific words. It’s like searching for a keyword in a conversation to find exactly what you’re looking for.

The RQT console sorts messages by their severity, giving you a quick sense of how urgent or serious an issue might be:

  • Fatal: The robot is in big trouble and might need to shut down to save itself.
  • Error: There’s a significant problem that’s stopping the robot from doing its job right, though it’s not a total disaster.
  • Warn: Something odd happened, or there’s a minor issue. It’s not critical, but it’s worth looking into before it gets worse.
  • Info: Just your robot checking in, letting you know that everything’s going as planned. This is the default setting, giving you a steady stream of updates.
  • Debug: The nitty-gritty details of what the robot is doing at every step. It’s like having a running commentary on every action it takes.

Sometimes, you might want to focus only on more serious issues or get more detailed information. You can adjust what types of messages you see by changing the log level. For example, to only see warnings and above, you’d use a command like ros2 run turtlesim turtlesim_node –ros-args –log-level WARN. This switches the default from showing everything at the "Info" level to only showing you warnings, errors, and fatal messages.

In wrapping up our exploration of the Robot Operating System (ROS), we’ve navigated through the fundamental components that make ROS an indispensable framework in the realm of robotics. From understanding the dynamic interactions within the ROS graph, diving into the modular world of nodes, to the communicative channels of topics, services, and actions, we’ve peeled back the layers of complexity to reveal the core mechanisms that enable sophisticated robotic operations. The customization and debugging tools, like parameters and the RQT console, further showcase ROS’s flexibility and user-friendly design, making it accessible for both newcomers and seasoned developers alike.

As we conclude this journey, it’s clear that ROS’s architecture not only promotes efficiency and modularity but also fosters an environment where innovation and collaboration thrive. Whether you’re building a simple automated assistant or a complex robotic system, the insights and tools provided by ROS offer a solid foundation to bring your robotic dreams to life. As you continue to explore and experiment with ROS, remember that the true power of this platform lies in its community and the collective knowledge shared among its users. So, dive in, keep learning, and become an active participant in shaping the future of robotics with ROS at your side.

In my journey to grasp the essentials of ROS for my professional growth, I’ve acquired this theoretical foundation. If you found this insight useful, feel free to follow me on X & Github, and your feedback is the most valuable to me.

--

--

Naveed Ul Mustafa

Student, interested in Machine Learning & Gen AI, Computational Neuroscience & Computer Vision