Robotics StackExchange | Archived questions

[Turtlebot3] show multi-robot in one map RVIZ

Hello, I'm working with multiple turtlebot3 (physically), I can successfully bring up and teleop as many as I want (3 until now, theoretically N ) using the namespace configuration. However, after building a map using one of them, if I want to show them on the same map, I haven't been able to make it work in RVIZ.

Have spent a lot of time on this without being able to solve it, so that's the reason I come over here looking up for help. If I need to provide further information please let me know. Thanks.

UPDATE: I've fresh installed both robot and PC, just to avoid a configuration problem...

My launch files:

turtlebot3_remote.launch

<!-- Soli Deo Gloria -->
<launch>
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <arg name="multi_robot_name" default=""/>

  <include file="$(find turtlebot3_bringup)/launch/includes/description.launch.xml">
    <arg name="model" value="$(arg model)" />
  </include>

  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
    <param name="publish_frequency" type="double" value="50.0" />
    <param name="tf_prefix" value="$(arg multi_robot_name)"/>
  </node>

  <!-- AMCL -->
  <include file="$(find turtlebot3_navigation)/launch/amcl.launch">
    <arg name="scan_topic"      value="/scan"/>
    <arg name="odom_topic"      value="$(arg multi_robot_name)/odom"/>
    <arg name="base_topic"      value="$(arg multi_robot_name)/base_footprint"/>    
    <arg name="initial_pose_x"  value="-2.0"/>
    <arg name="initial_pose_y"  value=" 0.5"/>
    <arg name="initial_pose_z"  value=" 0.0"/>
  </include>
</launch>

Loaded with: $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_remote.launch multi_robot_name:="tb3_0" (Now I'm loading each robot separately)

turtlebot3_navigation.launch

<!-- Soli Deo Gloria -->
<launch>
  <!-- Arguments -->
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
  <arg name="map_file" default="$(find turtlebot3_navigation)/maps/map.yaml"/>
  <arg name="open_rviz" default="true"/>

  <!-- Map server -->
  <node pkg="map_server" name="map_server" type="map_server" args="$(arg map_file)"/>

  <!-- rviz -->
  <group if="$(arg open_rviz)"> 
    <node pkg="rviz" type="rviz" name="rviz" required="true"
          args="-d $(find turtlebot3_navigation)/rviz/turtlebot3_nav.rviz"/>
  </group>
</launch>

Loaded with: $ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map20181108.yaml

amcl.launch

<!-- Soli Deo Gloria -->
<launch>
  <!-- Arguments -->
  <arg name="scan_topic"     default="scan"/>
  <arg name="odom_topic"     default="odom"/>
  <arg name="base_topic"     default="base_footprint"/>
  <arg name="initial_pose_x" default="0.0"/>
  <arg name="initial_pose_y" default="0.0"/>
  <arg name="initial_pose_z" default="0.0"/>

  <!-- AMCL -->
  <node pkg="amcl" type="amcl" name="amcl">

    <param name="min_particles"             value="500"/>
    <param name="max_particles"             value="3000"/>
    <param name="kld_err"                   value="0.02"/>
    <param name="update_min_d"              value="0.20"/>
    <param name="update_min_a"              value="0.20"/>
    <param name="resample_interval"         value="1"/>
    <param name="transform_tolerance"       value="0.5"/>
    <param name="recovery_alpha_slow"       value="0.00"/>
    <param name="recovery_alpha_fast"       value="0.00"/>
    <param name="initial_pose_x"            value="$(arg initial_pose_x)"/>
    <param name="initial_pose_y"            value="$(arg initial_pose_y)"/>
    <param name="initial_pose_a"            value="$(arg initial_pose_z)"/>
    <param name="gui_publish_rate"          value="50.0"/>

    <remap from="scan"                      to="$(arg scan_topic)"/>
    <param name="laser_max_range"           value="3.5"/>
    <param name="laser_max_beams"           value="180"/>
    <param name="laser_z_hit"               value="0.5"/>
    <param name="laser_z_short"             value="0.05"/>
    <param name="laser_z_max"               value="0.05"/>
    <param name="laser_z_rand"              value="0.5"/>
    <param name="laser_sigma_hit"           value="0.2"/>
    <param name="laser_lambda_short"        value="0.1"/>
    <param name="laser_likelihood_max_dist" value="2.0"/>
    <param name="laser_model_type"          value="likelihood_field"/>

    <param name="odom_model_type"           value="diff"/>
    <param name="odom_alpha1"               value="0.1"/>
    <param name="odom_alpha2"               value="0.1"/>
    <param name="odom_alpha3"               value="0.1"/>
    <param name="odom_alpha4"               value="0.1"/>
    <param name="odom_frame_id"             value="$(arg odom_topic)"/>
    <param name="base_frame_id"             value="$(arg base_topic)"/>
    <param name="global_frame_id"           value="/map" />
    <param name="use_map_topic"             value="true" />

  </node>
</launch>

turtlebot3_robot.launch

<launch>
  <arg name="multi_robot_name" default=""/>
  <arg name="set_lidar_frame_id" default="base_scan"/>

  <include file="$(find turtlebot3_bringup)/launch/turtlebot3_core.launch">
    <arg name="multi_robot_name" value="$(arg multi_robot_name)"/>
  </include>
  <include file="$(find turtlebot3_bringup)/launch/turtlebot3_lidar.launch">
    <arg name="set_frame_id" value="$(arg set_lidar_frame_id)"/>
  </include>

  <node pkg="turtlebot3_bringup" type="turtlebot3_diagnostics" name="turtlebot3_diagnostics" output="screen"/>
</launch>

UPDATE: fixed already the problem in the source code for the turtlebotcore.ino, now the frames /odom and `/basefootprint` are grabbing the NS configuration appropriately

Loaded with: $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_0" set_lidar_frame_id:="tb3_0/base_scan"

This is how Rviz looks like: (Updated 20181108) https://imgur.com/a/bPNDsge

TF tree here:(Updated 20181108) https://imgur.com/a/yqe0516

ROS nodes/topics graph https://imgur.com/a/0s0IEJK

$ roswtf

Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault

WARNING The following node subscriptions are unconnected:
 * /tb3_0/amcl:
   * /tb3_0/initialpose
   * /tb3_0/map
 * /rqt_gui_py_node_56568:
   * /statistics
 * /tb3_0/turtlebot3_core:
   * /tb3_0/sound
   * /tb3_0/reset
   * /tb3_0/motor_power
   * /tb3_0/cmd_vel

rostopic list

/diagnostics
/initialpose
/map
/map_metadata
/map_updates
/move_base/DWAPlannerROS/global_plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base_simple/goal
/rosout
/rosout_agg
/statistics
/tb3_0/amcl/parameter_descriptions
/tb3_0/amcl/parameter_updates
/tb3_0/amcl_pose
/tb3_0/battery_state
/tb3_0/cmd_vel
/tb3_0/cmd_vel_rc100
/tb3_0/diagnostics
/tb3_0/firmware_version
/tb3_0/imu
/tb3_0/initialpose
/tb3_0/joint_states
/tb3_0/magnetic_field
/tb3_0/map
/tb3_0/motor_power
/tb3_0/move_base/DWAPlannerROS/local_plan
/tb3_0/move_base/NavfnROS/plan
/tb3_0/move_base/current_goal
/tb3_0/move_base/local_costmap/costmap
/tb3_0/move_base/local_costmap/costmap_updates
/tb3_0/move_base/local_costmap/footprint
/tb3_0/odom
/tb3_0/particlecloud
/tb3_0/reset
/tb3_0/rpms
/tb3_0/scan
/tb3_0/sensor_state
/tb3_0/sound
/tb3_0/version_info
/tf
/tf_static

rosparam list:

/rosdistro
/roslaunch/uris/host_10_24_7_40___36549
/roslaunch/uris/host_10_24_7_41__33149
/roslaunch/uris/host_10_24_7_41__34283
/roslaunch/uris/host_10_24_7_41__36327
/roslaunch/uris/host_10_24_7_41__45497
/rosversion
/run_id
/tb3_0/amcl/base_frame_id
/tb3_0/amcl/beam_skip_distance
/tb3_0/amcl/beam_skip_threshold
/tb3_0/amcl/do_beamskip
/tb3_0/amcl/first_map_only
/tb3_0/amcl/global_frame_id
/tb3_0/amcl/gui_publish_rate
/tb3_0/amcl/initial_cov_aa
/tb3_0/amcl/initial_cov_xx
/tb3_0/amcl/initial_cov_yy
/tb3_0/amcl/initial_pose_a
/tb3_0/amcl/initial_pose_x
/tb3_0/amcl/initial_pose_y
/tb3_0/amcl/kld_err
/tb3_0/amcl/kld_z
/tb3_0/amcl/laser_lambda_short
/tb3_0/amcl/laser_likelihood_max_dist
/tb3_0/amcl/laser_max_beams
/tb3_0/amcl/laser_max_range
/tb3_0/amcl/laser_min_range
/tb3_0/amcl/laser_model_type
/tb3_0/amcl/laser_sigma_hit
/tb3_0/amcl/laser_z_hit
/tb3_0/amcl/laser_z_max
/tb3_0/amcl/laser_z_rand
/tb3_0/amcl/laser_z_short
/tb3_0/amcl/max_particles
/tb3_0/amcl/min_particles
/tb3_0/amcl/odom_alpha1
/tb3_0/amcl/odom_alpha2
/tb3_0/amcl/odom_alpha3
/tb3_0/amcl/odom_alpha4
/tb3_0/amcl/odom_alpha5
/tb3_0/amcl/odom_frame_id
/tb3_0/amcl/odom_model_type
/tb3_0/amcl/recovery_alpha_fast
/tb3_0/amcl/recovery_alpha_slow
/tb3_0/amcl/resample_interval
/tb3_0/amcl/restore_defaults
/tb3_0/amcl/save_pose_rate
/tb3_0/amcl/tf_broadcast
/tb3_0/amcl/transform_tolerance
/tb3_0/amcl/update_min_a
/tb3_0/amcl/update_min_d
/tb3_0/amcl/use_map_topic
/tb3_0/robot_description
/tb3_0/robot_state_publisher/publish_frequency
/tb3_0/robot_state_publisher/tf_prefix
/tb3_0/turtlebot3_core/baud
/tb3_0/turtlebot3_core/port
/tb3_0/turtlebot3_core/tf_prefix
/tb3_0/turtlebot3_lds/frame_id
/tb3_0/turtlebot3_lds/port

Thanks for the help

Asked by BrusAngel on 2018-10-23 23:38:57 UTC

Comments

Can you detail what is the actual error here ? Is it roslaunch failing to launch all the nodes or is it just the result in rviz not expected ? That could help us a lot to help you. (And the rviz config isn't that relevant, a screenshot of rviz would do)

Asked by Delb on 2018-10-24 03:05:55 UTC

But with all your group tags it could only be a remapping issue (not the right topics subscribed to). There is also this in your AMCL nodes : <arg name="set_scan" value="$(arg ns_r0)/scan" />, since you are in the group $(arg ns_r0) then <arg name="set_scan" value="scan" /> should be enough

Asked by Delb on 2018-10-24 03:08:34 UTC

Thanks Delb, made the edit and the fixes to amcl nodes... still same problem.... can't find out why the map frame is not being published. The $ rostopic list shows it.

Asked by BrusAngel on 2018-10-24 06:03:09 UTC

Thanks for the edit. Do you have only the /map topic or also /tb3_0/map and /tb3_1/map ? If you could also provide the tf_tree and the rostopic list that would be great.

Asked by Delb on 2018-10-24 07:23:55 UTC

No, I only have (or at least supposed to have) /map frame, if my understanding is correct I'd need /tb3_n/map if I would be working with more than one map at a time?. Added the tf_tree, rostopic list and also the roswtf output, btw... the latter output caught my attention for the last: WARNING

Asked by BrusAngel on 2018-10-24 08:01:43 UTC

You have to connect map to /tb3_0/odom and also /tb3_1/odom to make things work. Can you check with $rosparam list if there is : /tb3_0/amcl/global_frame_id and then with rosparam get /tb3_0/amcl/global_frame_id if it returns map ? Same with tb3_1.

Asked by Delb on 2018-10-24 08:15:32 UTC

For the robot_state_publisher it's weird that roswtf says that the node died but in the tf_tree the tf are broadcasted by this node. That might comes from how you launch turtlebot3_remote.launch.

Asked by Delb on 2018-10-24 08:20:12 UTC

Since the param multi_robot_name already set tf_prefix I would put the whole <include file="$(find turtlebot3_bringup)/launch/turtlebot3_remote.launch"> outside the <group ns = "$(arg ns_r1)"> (same for tb3_0)

Asked by Delb on 2018-10-24 08:22:18 UTC

no global_frame_id, only: base_frame_id, gui_publish_rate, initial_pose_a x & y, odom_alpha1~4, odom_frame_id, odom_model_type, transform_tolerance. and others that belong to amcl algorithm only. The ouput of rosparam get .../base_frame_id yields: base_footprint.

Asked by BrusAngel on 2018-10-24 08:22:49 UTC

Can you show in your question the full output of rosparam list please ? That's odd because you should definetly have params like /tb3_0/amcl/base_frame_id and /tb3_1/amcl/base_frame_id because of your groups.

Asked by Delb on 2018-10-24 08:33:02 UTC

I do have the /tb3_n/amcl/base_frame_id, that outputs: base_footprint, but you said: /tb3_n/amcl/global_frame_id... (added the $ rosparam list output)

Asked by BrusAngel on 2018-10-24 08:35:45 UTC

if I put the whole outside the , when launching shows: roslaunch file contains multiple nodes named [/robot_state_publisher]. Please check all 'name' attributes to make sure they are uni

Asked by BrusAngel on 2018-10-24 08:44:36 UTC

Alright leave it as before then. In your amcl launch file you need to add <param name="global_frame_id" value="/map"/> to set the connection with map.

Asked by Delb on 2018-10-24 09:00:39 UTC

isn't working yet, please check, I've updated the outputs for rviz, tf tree, rostopic list, roswtf and also updated the launch files. any ideas? thanks for the help, really appreciate it

Asked by BrusAngel on 2018-10-24 10:25:13 UTC

There is still things missing : in your amcl.launch add this too <param name="use_map_topic" value="true/>. Also I think there is an issue with the robot model, do you see the two turtlebot correctly if you set the fix frame to /tb3_0/base_link ?

Asked by Delb on 2018-10-24 12:29:30 UTC

updated the outputs, yes, it does show the robot, but now $ roswtf shows and error. will it be due to the base_scan not grabbing the name_space conf?

Asked by BrusAngel on 2018-10-25 03:01:16 UTC

Where does the core comes from ? How do you launch this ? It seems you launch it with another launch file which isn't in the same namespace. Have you seen this tutorial ? Section 16.5 shows how to correclty launch your robots.

Asked by Delb on 2018-10-25 03:21:57 UTC

I was missing the set_lidar_frame_id:="tb3_1/base_scan" for the launch file at the robot side, but still getting the same error out of $ roswtf, added the turtlebot3_robot.launch

Asked by BrusAngel on 2018-10-25 04:05:54 UTC

Instead of calling the other launch files separatly add this in the group tags:

<include file="$(find turtlebot3_bringup)/launch/turtlebot3_robot.launch">
   <arg name="model" value="$(arg model)" />
   <arg name="multi_robot_name" value="$(arg ns_r0)" />

</include>

Asked by Delb on 2018-10-25 04:15:48 UTC

I've updated the files, without success yet, this error got my mind:

ERROR TF multiple authority contention:
     * node [/tb3_0/turtlebot3_core] publishing transform [base_footprint] with parent [odom] already published by node [/tb3_1/turtlebot3_core]

I'm diving into the source file now

Asked by BrusAngel on 2018-10-26 08:26:41 UTC

thanks for your help, really appreciate, please don't get rid of me yet! haha

Asked by BrusAngel on 2018-10-26 08:27:40 UTC

You still haven't added the core.launch on your launch file with what I told you in my previous comment. Like that you don't launch it separately and avoid namespace issues (which is exactly your error)

Asked by Delb on 2018-10-26 09:35:23 UTC

Yes, the reason is I already got rid of the core.launch and put it directly under the robot.launch

Asked by BrusAngel on 2018-10-26 09:38:31 UTC

When launching the robot.launch I think you are missing set_tf_prefix:="tb3_0" and set_tf_prefix:="tb3_1". That's why I advise you to put the robot.launch inside your launch file.

Asked by Delb on 2018-10-27 09:36:59 UTC

the robot.launch is launched from the robot. From that side (robot), that launch file (robot.launch) is the only one. I do launch it: ROS_NAMESPACE=tb3_1 roslaunch turtlebot3_msnl turtlebot3_robot.launch set_tf_prefix:="tb3_1" set_lidar_frame_id:="tb3_1/base_scan", although I think found the probl

Asked by BrusAngel on 2018-10-29 08:57:45 UTC

please take a look to the new (just updated), tf tree, the turtlebot3_core source code is not able to parse namespaces, just to be sure made a whole new fresh installation for both the robot, as well as in the PC, and result is the same (can this be a bug??), I'm going now thru the source code..

Asked by BrusAngel on 2018-10-29 09:00:05 UTC

On the robot instead of roslaunch turtlebot3_msnl turtlebot3_robot.launch set_tf_prefix:="tb3_1" set_lidar_frame_id:="tb3_1/base_scan" it's roslaunch turtlebot3_msnl turtlebot3_robot.launch multi_robot_name:="tb3_1" set_lidar_frame_id:="tb3_1/base_scan"

Asked by Delb on 2018-10-29 09:10:46 UTC

And your new tf tree shows you're using gmapping but evreything else is related to AMCL, what have you changed ?

Asked by Delb on 2018-10-29 09:12:18 UTC

I just changed the arg name multi_robot_name for set_tf_prefix, that's all. About gmapping, I just wanted to make sure the problem was in my configuration and wasn't part of ROS at some point, that's why made a fresh install and tried the example you cited previously... :)

Asked by BrusAngel on 2018-10-30 01:24:02 UTC

I'm getting this warning on when launching the robot side: https://imgur.com/a/uYud34B and the TF tree still doesn't grab the namespace conf... https://imgur.com/a/RG4MiWe I'm going through the SerialClient.py but still no success...

Asked by BrusAngel on 2018-11-01 02:43:44 UTC

found the problem in: turtlebot3_core.ino, the ROS NodeHandle nh is throwing a timeout after the method updateTFprefix() is being called in line 80, specifically in line 349 nh.getParam("~tf_prefix", &get_tf_prefix);, the condition in line 351 becomes true (due to the timeout)

Asked by BrusAngel on 2018-11-01 03:16:19 UTC

and the frames get "labeled" by the default configuration and not following the TF prefix setup... Would you please help me taking a look to this?... turtlebot3_core.ino Thanks

Asked by BrusAngel on 2018-11-01 03:20:20 UTC

Try rosparam list after you launch everything and then search if there are multiple params. Also you seem to have modified a lot from the source files (which you shouldn't do) so maybe you modified some params/args name and it leads to this issue.

Asked by Delb on 2018-11-01 13:00:09 UTC

Hello, I've fixed the source code and freshly installed both robot & PC because of the many modifications made. Please take a look at the updated information. Thanks again

Asked by BrusAngel on 2018-11-08 08:15:11 UTC

In the turtlebot3_remote.launch inside the amcl include tags can you add :

<remap from="$(arg multi_robot_name)/map" to="/map"/>

Asked by Delb on 2018-11-08 08:36:20 UTC

done... no change...

Asked by BrusAngel on 2018-11-08 08:42:00 UTC

What about this (instead of the previous remapping) :

<node pkg="map_server" name="map_server" type="map_server" args="$(arg map_file)">
  <remap from="/map" to="/tb3_0/map"/>
<node/>

Asked by Delb on 2018-11-08 08:46:21 UTC

nice! that worked for one robot, now I can appropriately see the robot with ns tb3_0, how about if I want to add more?

Asked by BrusAngel on 2018-11-08 09:15:37 UTC

If you launch everything again but with the arg tb3_1 it doesn't work ?

Asked by Delb on 2018-11-08 09:26:34 UTC

launching the turtlebot3_navigation.launch again changing the remapping argument closes RViz and launches the new instance for the tb3_1 but the tb3_0 stops working...

Asked by BrusAngel on 2018-11-12 06:17:35 UTC

Answers