VideoLibrary

Introduction to ROS Part 3: Nodes, Topics, Publishers, and Subscribers with Python | DigiKey

In this tutorial, we take the next big step in learning ROS 2 by writing your first nodes in Python. You’ll learn how to build a publisher and subscriber from scratch using rclpy, the official Python client library for ROS 2. These two fundamental node types allow your applications to send and receive messages using a publish/subscribe model. The written guide for this episode can be found here: https://www.digikey.com/en/maker/projects/intro-to-ros-part-3-nodes-topics-publishers-and-subscribers-python/c29a6de2cc1c4df3a44b122a42f6716e The GitHub repository containing the Docker image and example code for this series can be found here: https://github.com/ShawnHymel/introduction-to-ros We start by setting up a ROS 2 workspace inside a pre-configured Docker container and creating a new Python package using the ros2 pkg create command. You'll learn what each file and folder does, including package.xml, setup.py, and the resource/ directory. This foundational knowledge will help you understand the structure of any ROS 2 Python project and prepare you for building more complex packages in the future. Next, we walk through the complete code for a minimal publisher node that broadcasts “Hello world” messages to a topic. We register this node as an executable, build the package using colcon, and use the ROS 2 command line to verify that the messages are being sent. Then we create a minimal subscriber node that listens to the same topic and prints incoming messages to the console, demonstrating real-time communication between two nodes. We also explain how ROS 2 nodes are structured, how topics work under the hood, and why modular communication is essential for scalable robotics applications. Along the way, we introduce concepts like node subclassing, Quality of Service (QoS) settings, and how to use rqt_graph to visualize the connections between nodes and topics. By the end of this video, you'll understand how to create, build, and run basic ROS 2 Python nodes in a clean development environment. These skills form the backbone of all future ROS applications, from simulation to real-world robotics. Subscribe to follow the full series and continue building your ROS 2 expertise.

9/29/2025 6:44:24 PM