Multi Robot simulation on gazebo
Hey everyone!
I'm trying to create a launch file for a multi-robot system simulation. I found this excellent resource:
https://answers.ros.org/question/4143...
However, I'm having a hard time making the launch files for it. As of right now I have three different launch files:
multi_robot_simulation.launch;
robots.launch;
one_robot.launch.
They are called in this exact order and below I included the code for each of them:
multi_robot_simulation.launch:
<launch>
<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<!-- Start Robot world -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_world.world"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="debug" value="false"/>
</include>
<!-- include our robots -->
<include file="$(find gspn_framework_package)/ros/launch/multi_robot_new/robots.launch"/>
</launch>
robots.launch:
<launch>
<param name="robot_description"
command="$(find xacro)/xacro $(find turtlebot3_description)/urdf/turtlebot3_waffle_pi.urdf.xacro" />
<!-- BEGIN ROBOT 1-->
<group ns="robot_1">
<param name="tf_prefix" value="robot1_tf" />
<include file="$(find gspn_framework_package)/ros/launch/multi_robot_new/one_robot.launch" >
<arg name="init_pose" value="-x -0.5 -y 0.5 -z 0" />
<arg name="robot_name" value="Robot1" />
</include>
</group>
<!-- BEGIN ROBOT 2-->
<group ns="robot_2">
<param name="tf_prefix" value="robot2_tf" />
<include file="$(find gspn_framework_package)/ros/launch/multi_robot_new/one_robot.launch" >
<arg name="init_pose" value="-x 2 -y 1 -z 0" />
<arg name="robot_name" value="Robot2" />
</include>
</group>
</launch>
one_robot.launch:
<launch>
<arg name="robot_name"/>
<arg name="init_pose"/>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="$(arg init_pose) -urdf
-param /robot_description -model $(arg robot_name)" respawn="false" output="screen"/>
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher"
output="screen"/>
</launch>
I believe that this is not working because when I run rosrun tf2_tools view_frames.py
, I get the following tree:
which is clearly not correct, since I have an extra base_footprint and the base_footprints from robot_1 and robot_2 are not connected to anything.
[EDIT] When I take out the namespaces and only consider one robot, the tree looks well. So maybe I'm not using the namespace in the correct manner. Any tip on that?
[EDIT 2] I have come to the realization that the issue might be related to the way I'm launching the robot_state_publisher node on the file one_robot.launch. This package started using tf2 instead of tf and with this, the tf_prefix stopped being used. Does anyone know how to properly launch the robot_state_publisher node or know a good place to lookup resources on it?
I have been stuck with this issue for a long time. I am using ROS Noetic.
Thank you very much in advance!
Can you clarify this please ?
From the question you have linked you are missing the param
tf_prefix
before including eachone_robot.launch
:What I'm trying to say is that I am using tf2_tools instead of the tf package to get the tree and I thought that maybe that would make a difference regarding the launch file.
Initially I tried using the tf_prefix but I was getting the exact same tree so I concluded that it wasn't doing much. I think that I'm using the namespaces wrongly because when I take them out (meaning that I am executing a single robot system), the tree looks fine. But I don't know how to use them in any other way.