Creating a Python node
Let’s create our first Python node, or in other words, our first ROS 2 Python program.
The processes of creating Python and C++ nodes are very different. That’s why I have written a separate section for each of them. We will start with Python, with complete step-by-step explanations. Then we will see how to do the same with C++. If you want to follow the C++ node section, make sure to read this one first.
To create a node, you will have to do the following:
- Create a file for the node.
- Write the node. We will use Object Oriented Programming (OOP), as officially recommended for ROS 2 (and almost every existing ROS 2 code you find uses OOP).
- Build the package in which the node exists.
- Run the node to test it.
Let’s get started with our first Python node.
Creating a file for the node
To write a node, we first need to create a file. Where should we create this file?
If you remember, when we created the...