Unit 03 · lesson

Names, Namespaces, and Remapping

Reusable software becomes much more useful when names can change without rewriting the program.

ROS 2 supports remapping at startup.

Rename a node

The beginner node tutorial uses:

ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle

Inspect:

ros2 node list

The executable is still turtlesim_node. The graph name changed.

Remap a communication name

The Turtlesim tutorial demonstrates launching another teleop instance and redirecting its command/action names from turtle1 to turtle2:

ros2 run turtlesim turtle_teleop_key \
  --ros-args \
  --remap turtle1/cmd_vel:=turtle2/cmd_vel \
  --remap turtle1/rotate_absolute:=turtle2/rotate_absolute

That is a powerful idea:

same executable
+ different runtime naming
= different place in the system

Namespace mental model

A namespace groups names under a prefix. You will see this clearly in launch files later when multiple copies of a node need separate graph identities.

For now, recognize names such as:

/turtle1/cmd_vel
/turtle2/cmd_vel

as separate graph resources.

Evidence checkpoint

Create a before/after table:

PropertyDefaultRemapped
executable
node name
command topic

Then answer:

What changed in source code?

For the runtime remapping exercise: nothing.