Set ROS 2 name and namespace
Configure the robot’s ROS node namespace to avoid topic collisions.
To avoid conflicts when running multiple robots on the same network, you must assign a unique name and namespace to your robot. ROS 2 uses these to prefix all topics and nodes so that multiple robots can share the same network without collisions.
# edit your profile
sudo nano ~/.profile
# add or update this line (replace n with your robot number)
export ROS_NAME=rcr00n
# save the file, then reload your profile
source ~/.profile
sudo nano ~/env.list
# add or update this line (replace n with your robot number)
ROS_NAMESPACE=/rcr00n
If your micro‑ROS firmware initializes the node with a namespace, you must update the source code as well. Open the RosInterface.cpp file in the firmware directory and change the third argument of rclc_node_init_default to your robot’s name:
```bash {id:”namespace:edit-firmware”, test:false}
cd ~/repos/common_platform/firmware/closed_loop/
sudo nano RosInterface.cpp
In the file, find the line that looks similar to:
```cpp
rclc_node_init_default(&node, "micro_ros_arduino_node", "", &support);
Replace the empty string with your robot name (e.g. rcr00n):
rclc_node_init_default(&node, "micro_ros_arduino_node", "rcr00n", &support);
Important: After modifying the firmware source code, you must recompile and flash the firmware to the Teensy for the namespace change to take effect. Return to the Teensy flashing procedure to rebuild and upload the updated firmware.