Using groups/namespaces

If you have worked intensely with ROS online tutorials, you will have kind of figured out how to solve this issue. Let's consider the turtlesim example for this. Launch the turtlesim node using the following commands.

In one Terminal, run the following commands:

$ initros1
$ roscore

In another Terminal, run the following commands:

$ initros1
$ rosrun turtlesim turtlesim_node

Check out the rostopic list to see cmd_vel and the pose of turtle1. Now, let's spawn another turtle into the GUI using the following command:

$ rosservice call /spawn 3.0 3.0 0.0 turtle2

Well, what just happened? You spawned in another turtle with the same topic names, but with an added prefix, /turtle2. This is the namespace technique in ROS that's used to spawn multiple robots. Now, our example will be refined, as shown here:

Modified communication between the same robots in the same network

As you can see, each robot has its own topics prefixed with the robot names, respectively. There could be some common topics among the robots too, such as the /map topic, since both robots are on the same environment. We'll learn how to use this namespace technique for the robot we created in Chapter 3Building an Industrial Mobile Manipulator, in the upcoming section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset