Robotics StackExchange | Archived questions

Working with namespace correctly - Multiple Turtlebot3 robots inside the same simulation in Gazebo

Hi everyone! First time using ROS, and I spent the last 3 weeks studying it and working on really small examples.

Now I moved to the actual task for a university side project: the goal is to simulate multiple robots working together.

I spent three days figuring out how a single Turtlebot3 Burger is spawned inside the empty_world simulation inside Gazebo. Yesterday I was finally able to spawn multiple robots using a modified version of empty_world.launch.py.

I created a new burger.model file that contains the following code to include a new (modified) Turtlebot3:

<include>
    <uri>model://turtlebot3_burger_2</uri>
    <name>turtlebot3_burger_2</name>
    <pose>5 5 0 0 0 0</pose>
</include>

and a new model.sdf file to provide a new namespace (/tb3_second) to the second robot's nodes like in this example

<plugin name="turtlebot3_laserscan" filename="libgazebo_ros_ray_sensor.so">
    <ros>
        <namespace>/tb3_second</namespace>
        <remapping>~/out:=scan</remapping>
    </ros>
    <output_type>sensor_msgs/LaserScan</output_type
    <frame_name>base_scan</frame_name>
</plugin>

After all of this, I am able to spawn multiple robots and control them individually, but I am wondering if I am doing it kind of right or if there's an easier way to obtain the same result.

If it is ok, how do I manage the creation of multiple (5/10) robots in a suitable way? Is there a way to not create 10 different model.sdf files for providing 10 different namespaces?

Thank you in advance for your help!


My setup is the following:
ROS Env variables:
    ROS_VERSION=2
    ROS_PYTHON_VERSION=3
    ROS_DOMAIN_ID=30
    ROS_LOCALHOST_ONLY=0
    ROS_DISTRO=foxy
Ubuntu 20.04

Asked by blue_screen_0f_death on 2022-07-02 04:30:07 UTC

Comments

Answers