> For the complete documentation index, see [llms.txt](https://campus-rover.gitbook.io/lab-notebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://campus-rover.gitbook.io/lab-notebook/fiiva/multi-robot-one-core.md).

# multi-robot-one-core.md

## Running multiple robots on a single roscore

Joshua Liu

## Normal behavior

Normally, running the bringup launch file will create a new roscore running on that robot. This, of course, is not desired.

## Step 0: Decide on your desired structure

These configurations should both be possible:

* Run roscore on one robot
* Run roscore on a seperate computer (probably your VNC environment)

We will assume the first configuration here.\
I have not actually testes the second one, but I see no reason it wouldn't work.

## Setp 1: Edit .bashrc file of your "auxiliary" robot(s)

SSH into your auxiliary robot (We will use "auxiliary" here to mean "not running roscore").

Open the .bashrc file in your editor of choice

Navigate to where it says

```
$(bru name ROBOTNAME -m 127.0.0.1)
```

Change the ROBOTNAME to the name of your computer (robot is computer too) that will run roscore. Change the IP address to the IP address of your core robot.\
Save your changes.

## Step 2: Copy and edit the bringup launch file

Do this for **each** robot, even your "core" (running roscore) one.

While still SSH'ed into that robot, run `roscd bringup`\
Navigate to the `launch` directory\
Run `cp turtlebot3_robot.launch turtlebot3_multi_robot.launch` to copy the file. Please do this.

Open the newly created `turtlebot3_multi_robot.launch` file in your editor of choice.

At the top, there should be two `<arg>` tags.

After them, put on a new line: `<group ns="$(arg multi_robot_name)">`

Then, right before the very bottom `</launch>`, add a closing `</group>` tag.\
The result should look something like:

```
<launch>
	<arg> lorem ipsum dolor sit amet ... </launch>
	<arg> lorem ipsum dolor sit amet ... </launch>
	<group ns="$(arg multi_robot_name)">
		<stuff> </stuff>
		<stuff> </stuff>
		<stuff> </stuff>
		<stuff> </stuff>
	</group>
</launch>
```

Repeat the two above steps on all your auxiliary robots.

What does this do? While it is not necessary, this will prefix all the nodes created by bringup with the robot's name.\
If you don't do this, there will be many problems.

## Launching the robots

When SSH'ed into a robot, you can't just run `bringup` anymore. Use this command instead:

`roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:=THEROBOTNAME`

This will cause the bringup nodes to be properly prefixed with the robot's name.\
For example, `raspicam_node/images/compressed` becomes `name/raspicam_node/images/compressed`.\
Additionally, the robot will also subscribe to some different nodes.\
The only one I can know of so far is `cmd_vel` which becomes `name/cmd_vel`. Keep this in mind if your robots don't move.

As long as you launch the core robot first, this should work.

See what it looks like by running `rostopic list` from your (properly configured to point at the core computer) vnc environment.

## Acknowledgments

Very many thanks to August Soderberg, who figured most of this out.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://campus-rover.gitbook.io/lab-notebook/fiiva/multi-robot-one-core.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
