Ubuntu Linux for Robotics · Lesson 87 of 96
Multi-robot coordination
Namespaces, shared resources, priorities and deadlock avoidance.
Estimated time · 60–90 min
Learning goals
What you will understand
- Explain multi-robot coordination in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
Robots that share corridors, doors or chargers need rules. A reservation table gives a resource to one robot at a time: robots request it, wait, and release it when done. Requests are served first-come or by priority. Deadlock (each robot holds what the other needs) is avoided by reserving whole routes or ordering resources.
Technically each robot needs its own namespace, unique TF frame names or namespaced TF, and its own Nav2 instance; they may share the map. Use ROS_DOMAIN_ID to separate independent fleets, and check ros2 node list and ros2 topic list for name clashes.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the multi-robot coordination commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
ros2 launch fleet_bringup robot.launch.py namespace:=robot1 x:=0.0 y:=0.0
# Start robot 1 in its own namespace at its start pose.
ros2 launch fleet_bringup robot.launch.py namespace:=robot2 x:=2.0 y:=0.0
# Start robot 2 at a different pose.
ros2 topic list | grep -c '^/robot1'
# Count the topics that belong to robot 1.
ros2 topic echo /traffic/reservations --once
# Read the shared reservation table (custom topic).
ros2 run tf2_tools view_frames
# Check that each robot has its own connected frame tree.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Mobile robot
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for Multi-robot coordination. Expected result: Two robots are running in separate namespaces
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: start robot2 from the launch file robot.launch.py of fleet_bringup with namespace:=robot2Expected output
Two robots are running in separate namespacesStuck? Show the full solution (try it yourself first)
ros2 launch fleet_bringup robot.launch.py namespace:=robot2 x:=2.0 y:=0.0Expected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Start two robots in namespaces, make both cross the same corridor, show they collide or block without reservations, then add a reservation node and show the conflict is gone.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.