Trying to achieve multiple turtlebot3 where each robot generates a map with rtab-map

Posted by gabriele97 on
URL: http://official-rtab-map-forum.206.s1.nabble.com/Trying-to-achieve-multiple-turtlebot3-where-each-robot-generates-a-map-with-rtab-map-tp10209.html

Hello,
I am relatively new to ROS and what I am trying to achieve as final goal is a system where I have multiple turtlebot3 that map a 3D world.

I am trying with RTAB-MAP but unsuccessfully for now.

My launch file is the following:
<launch>
  <!-- Arguments -->
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <arg name="first_tb3"  default="tb3_0"/>
  <arg name="second_tb3" default="tb3_1"/>
  <arg name="known_initial_pos" default="true"/>

  <arg name="first_tb3_x_pos" default="-10"/> <!-- Defaul -7.0-->
  <arg name="first_tb3_y_pos" default=" -2"/> <!-- Default -1.0-->

  <arg name="second_tb3_x_pos" default=" 4.0"/> <!-- Default 7.0-->
  <arg name="second_tb3_y_pos" default=" 2.0"/> <!-- Default -1.0-->

  <!-- Run the map expansion node -->
  <node pkg="multi_robot_exploration" type="map_node" name="multi_robot_exploration_map_node"/>

  <!-- Open two tb in gazebo and give spawn positions -->
  <include file="$(find multi_robot_exploration)/launch/spawn_robots.launch">
    <arg name="first_tb3_x_pos" value="$(arg first_tb3_x_pos)"/>
    <arg name="first_tb3_y_pos" value="$(arg first_tb3_y_pos)"/>

    <arg name="second_tb3_x_pos" value="$(arg second_tb3_x_pos)"/>
    <arg name="second_tb3_y_pos" value="$(arg second_tb3_y_pos)"/>
  </include>

  <!-- Open slam for each robot in their ns -->
  <include file = "$(find multi_robot_exploration)/launch/slam_online_synch.launch">
    <arg name="ns"  value="$(arg first_tb3)"/>
  </include>
  
  <include file = "$(find multi_robot_exploration)/launch/slam_online_synch.launch">
    <arg name="ns"  value="$(arg second_tb3)"/>
  </include>

  <!-- Merge the two robot maps -->
  <include file="$(find multi_robot_exploration)/launch/multi_robot_map_merge.launch">
    <arg name="known_initial_pos" value="$(arg known_initial_pos)"/>
  </include>

  <!-- Open rviz for two robots -->
  <node pkg="rviz" type="rviz" name="rviz"
    args="-d $(find multi_robot_exploration)/config/two_tb.rviz"/>
</launch>

and spawn_robots.launch is:

<launch>

  <!-- Initial position for the first turtlebot -->
  <arg name="first_tb3_x_pos" default="-7.0"/> <!-- Between -7.0 and 7.0 ???-->
  <arg name="first_tb3_y_pos" default=" -1.0"/> <!-- Between -7.0 and 7.0 ???-->

  <!-- Initial position for the second turtlebot -->
  <arg name="second_tb3_x_pos" default=" 7.0"/> <!-- Between -7.0 and 7.0 ???-->
  <arg name="second_tb3_y_pos" default=" -1.0"/> <!-- Between -7.0 and 7.0 ???-->

  <!-- Combine the inital positions into one argument for spawning -->
  <arg name="init_pose_0" default="-x $(arg first_tb3_x_pos) -y $(arg first_tb3_y_pos) -z 0.0" />
  <arg name="init_pose_1" default="-x $(arg second_tb3_x_pos) -y $(arg second_tb3_y_pos) -z 0.0" />

  <!-- Open the AWS bookstore gazebo world -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <!-- <arg name="world_name" value="$(find multi_robot_exploration)/worlds/bookstore.world"/> -->
    <!-- <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/empty.world" /> -->
    <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_world.world" />
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="true"/>
    <arg name="headless" value="false"/>
    <arg name="debug" value="false"/>
  </include> 

  <!-- Spawn tb3_0 and start it's robot descirption / robot state publisher -->
  <group ns="tb3_0">
    <param name="tf_prefix" value="tb3_0" />
    <include file="$(find multi_robot_exploration)/launch/tb3_0.launch" >
      <arg name="init_pose" value="$(arg init_pose_0)"/>
      <arg name="robot_name"  value="tb3_0" />
      <arg name="model" default="$(env TURTLEBOT3_MODEL)" />
    </include>


	<arg name="database_path" default="~/.ros/rtabmap.db" />

	<node name="rtabmap" pkg="rtabmap_slam" type="rtabmap" output="screen">
		<param name="databse_path" type="string" value="$(arg database_path)" />
		<param name="frame_id" type="string" value="tb3_0/base_link" />
		<param name="odom_frame_id" type="string" value="odom" />
		<param name="subscribe_depth" type="bool" value="true" />
		<param name="subscribe_laserScan" type="bool" value="false" />

		<remap from="rgb/image" to="camera/rgb/image_raw" />
		<remap from="depth/image" to="camera/depth/image_raw" />
		<remap from="rgb/camera_info" to="camera/rgb/camera_info" />
		<remap from="grid_map" to="map" />

		<param name="RGBD/ProximityBySpace" type="string" value="true"/>
		<param name="RGBD/OptimizeFromGraphEnd" type="string" value="false"/>
		<param name="Kp/MaxDepth" type="string" value="4.0"/>
		<param name="Reg/Strategy" type="string" value="2"/>
		<param name="Icp/CorrespondenceRatio" type="string" value="0.3"/>
		<param name="Vis/MinInliers" type="string" value="5"/>
		<param name="Vis/InlierDistance" type="string" value="0.1"/>
		<param name="RGBD/AngularUpdate" type="string" value="0.1"/>
		<param name="RGBD/LinearUpdate" type="string" value="0.1"/>
		<param name="Rtabmap/TimeThr" type="string" value="700"/>
		<param name="Mem/RehearsalSimilarity" type="string" value="0.30"/>
	</node>
    
  </group>

  <!-- Spawn tb3_1 and start it's robot descirption / robot state publisher -->
  <group ns="tb3_1">
    <param name="tf_prefix" value="tb3_1" />
    <include file="$(find multi_robot_exploration)/launch/tb3_1.launch" >
      <arg name="init_pose" value="$(arg init_pose_1)"/>
      <arg name="robot_name"  value="tb3_1" />
      <arg name="model" default="$(env TURTLEBOT3_MODEL)" />
    </include>
  </group>

</launch>

The error I see is

[ WARN] [1719348537.260067020, 61.759000000]: Could not get transform from tb3_0/base_link to base_footprint after 0.200000 seconds (for stamp=61.298000)! Error="canTransform: source_frame base_footprint does not exist.. canTransform returned after 0.2 timeout was 0.2.".

I don't knwo what I am doint wrong, hope you can help me. Thank you!