ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Multi Robot simulation on gazebo

asked 2020-08-27 12:23:52 -0500

anonymous user

Anonymous

updated 2020-09-09 06:09:17 -0500

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:

C:\fakepath\Screenshot from 2020-08-27 18-21-18.png

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!

edit retag flag offensive close merge delete

Comments

But I would like to use tf2, instead of its predecessor

Can you clarify this please ?

From the question you have linked you are missing the param tf_prefix before including each one_robot.launch :

<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" >
Delb gravatar image Delb  ( 2020-08-28 05:10:50 -0500 )edit

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.

anonymous userAnonymous ( 2020-08-28 05:22:46 -0500 )edit

3 Answers

Sort by » oldest newest most voted
1

answered 2021-03-20 20:11:50 -0500

SamuelEsd gravatar image

Hey, I'm sorry but it seems like it's not possible to use tf_prefix in ros noetic since tf is deprecated. I have the same problem in a multirobot package, my code runs perfectly in melodic but in noetic the use of tf_prefix has no sense, so even whet the use of tf_prefix could be the solution, it's not possible to do it in noetic.

This same problems is also in this question. https://answers.ros.org/question/3612...

And this link may help http://wiki.ros.org/tf2/Migration

If I find a solution I'll reply my answer, hope if you found a solution you could reply my answer too.

edit flag offensive delete link more
0

answered 2023-06-25 04:00:46 -0500

Arshad gravatar image

This multi robot implementation in ROS2 may help -> https://github.com/arshadlab/turtlebo...

edit flag offensive delete link more
0

answered 2020-09-01 03:52:26 -0500

Roberto Z. gravatar image

updated 2020-09-02 06:47:04 -0500

As mentioned by @Delb, in robots.launch you are missing the tf_prefix parameter for both robots. Use the robots.launch file below and then post your tf tree again.

<launch>
  <param name="robot_description"
    command="$(find xacro)/xacro $(find turtlebot3_description)/urdf/turtlebot3_waffle_pi.urdf.xacro" />

  <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="robot_1" />
    </include>
  </group>

  <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="robot_2" />
    </include>
  </group>

</launch>
edit flag offensive delete link more

Comments

Thank you for the hint but sadly, the tf tree looks exactly the same as the one I posted before :( I'm starting to think that the issue is in multi_robot_simulation.launch because I am using

<include file="$(find gazebo_ros)/launch/empty_world.launch">

Which is probably launching something it shouldn't. Any tips on that? (I edited the question so that it now includes the tf_prefix)

anonymous userAnonymous ( 2020-09-02 04:29:49 -0500 )edit

Your multi_robot_simulation.launch file looks good to me.
From your tf view_frames output I can see that both robots have root parents "robot_1_tf/odom" and "robot_2_tf/odom". Those prefixes are ok. However there are no children tf connections to match them.

Normally wrapping <group ns="$(arg robot_id)"> around the launch file of the single robot will allow to run multiple instances of a node in namespaces and put topics and parameters into a nested namespace.

Declaring a nested tf_prefix parameter will prepend a namespace to the coordinate frames being published by each robot_state_publisher node based on the robot_description. And those are not showing in your tf tree.

Roberto Z. gravatar image Roberto Z.  ( 2020-09-02 06:10:45 -0500 )edit

I was able to reproduce your TF tree and I had to set the launch files like this:

one_robot.launch

  • spawn_urdf node

robots.launch

  • robot_description
  • includes for one_robot.launch wrapped around group tag and including a nested tf_prefix parameter
  • robot_state_publisher node

Which is wrong.

This:

<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" 
output="screen"/>

Has to be located inside the one_robot.launch file. I know that this is included on the launch file that you describe on your question. But this was the only way I could reproduce your error, considering that you have included the tf_prefix parameter. I can only suggest to double check your launch files.

Roberto Z. gravatar image Roberto Z.  ( 2020-09-02 07:59:46 -0500 )edit

Hey!

Thank you for trying to help me out. I have been stuck with this error for the past month and I really don't know what the issue can be.

I have checked the launch files many times now and I really don't know what else I can check :(

Did you copy/paste my code and everything ran as it should?

I also tried running rosnode list and the output is very similar to yours, with the addition of "/gazebo_gui"

anonymous userAnonymous ( 2020-09-02 10:28:51 -0500 )edit

Hello Pedro, I just created a new package and copy-pasted the three launch files that you posted on your question and the TF tree is looking good. Not sure why it is not working at your end. You mentioned that you have been stuck for a while and things can get tangled more quickly than you think. I would suggest to create a new package that only contains these tree launch files and test it. This will allow you to start fresh, isolate the issue and if you want I can also have a look at it.

Roberto Z. gravatar image Roberto Z.  ( 2020-09-03 08:37:03 -0500 )edit

Just tried creating a brand new package without anything but the launch files that I mentioned in my question and the tf tree looks exactly the same :(

Besides this, when I run rosrun tf2_tools view_frames.py to get the tf tree, I get a bunch of warnings saying Warning: TF_REPEATED_DATA .

I really don't understand why this is happening and it's even weirder because you managed to get the tf trees correctly. Are you also using ROS Noetic and running rosrun tf2_tools view_frames.py ?

anonymous userAnonymous ( 2020-09-03 11:06:09 -0500 )edit

It is a pity that I could not help, I can’t think of any other hint to give you... I am using Melodic + Gazebo 9 and rosrun tf view_frames

Roberto Z. gravatar image Roberto Z.  ( 2020-09-04 02:11:38 -0500 )edit

But thank you very much for all the help you provided. You did a lot :)

Do you think that the reason why I can't get it working has something to do with the use of ROS Noetic?

anonymous userAnonymous ( 2020-09-04 06:08:00 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-08-27 12:23:52 -0500

Seen: 1,979 times

Last updated: Jun 25 '23