Configuring nodes inside a launch file
So far, we have just started two nodes, with zero extra configuration. When you start a node with ros2 run
, as we have seen in the previous chapters in Part 2, you can rename it, rename topics/services/actions, add parameters, and so on.
In this section, you will learn how to do that inside a launch file. We will also introduce the concept of namespaces. All code examples will be in XML and Python.
Renaming nodes and communications
In an XML launch file, to rename a node, simply add a name
argument in a <
node>
tag:
<node pkg="your_package" exec="your_exec" name="new_name" />
Changing the name for a topic/service/action is actually named remapping. To remap a communication, you have to use a <remap>
tag, inside the <
node>
tag:
<node pkg="your_package" exec="your_exec"> <remap from="/topic1" to="/topic2"...