Summary
In this chapter, you have created your first node. Let’s do a quick recap of all the steps.
Before creating any node, you need to follow these steps:
- You first need to create and set up a ROS 2 workspace.
- In this workspace, you can create several packages (Python or C++) that represent different sub-parts of your application.
Then, in one package you can create one or several nodes. For each node, you will have to do the following:
- Create a file inside the package.
- Write the node (using the OOP template as a base).
- Set the build instructions (
setup.py
for Python,CMakeLists.txt
for C++). - Build the package.
To run the node, don’t forget to source the workspace first, and then start the node with ros2 run <
pkg_name> <executable_name>
.
Finally, you can introspect your nodes and even change their names when you start them, using the ros2 node
command line.
Feel free to come back to this chapter anytime...