Use topic_tools mux to load multiple maps?

asked 2019-06-25 12:20:15 -0500

JackB gravatar image

updated 2019-06-25 13:01:30 -0500

gvdhoorn gravatar image

Our robot is going to be operating in a large spread out environment where GPS will be used for localization in some areas, and AMCL in others. In the areas where GPS is used I just have a rough schematic of the environment that it can use for path planning. In the areas where I need to use AMCL (of which there will be several) I will use a more detailed map created using gmapping beforehand.

A map server can only load one map at a time, but as suggested here (#q270129) I am trying to use a topic_tools mux to coordinate each map server that contain the individual maps. Then using the mux features I can select which map will be loaded to the /map topic when I need to localize withing that specific map.

Unfortunately the mux node never publishes the the map that is selected. Does this happen because the map servers only publish each map once? Is there someway that I can make it so the mux works well with the map servers?

Attached is my launch file which launches the maps and the mux node.

<?xml version="1.0"?>
<launch>
  <arg name="map_file1" default="$(find husky_jack)/maps/room1.yaml"/>
  <arg name="map_file2" default="$(find husky_jack)/maps/room2.yaml"/>
  <arg name="map_file3" default="$(find husky_jack)/maps/room3.yaml"/>

  <!-- Run the map1 server -->
  <node name="map_server1" pkg="map_server" type="map_server" args="$(arg map_file1)" >
    <param name= "frame_id" value ="map1"/>
    <remap from="map" to ="map1" />
  </node>

  <!-- Run the map2 server -->
  <node name="map_server2" pkg="map_server" type="map_server" args="$(arg map_file2)" >
    <param name= "frame_id" value ="map2"/>
    <remap from="map" to ="map2" />
  </node>

  <!-- Run the map3 server -->
  <node name="map_server3" pkg="map_server" type="map_server" args="$(arg map_file3)" >
    <param name= "frame_id" value ="map3"/>
    <remap from="map" to ="map3" />
  </node>

  <node name ="mux_map_service" pkg ="topic_tools" type ="mux" args ="/map /map1 /map2 /map3 mux:=mux_map_service" output = "screen" >
    <param name ="initial_topic " value= "map3"/>

  </node>

</launch>
edit retag flag offensive close merge delete

Comments

1

I'm not sure (so this is just a guess and just something to check), but map_server uses a latched publisher (here). It could be that mux doesn't like that.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-25 13:05:53 -0500 )edit

Hmm ok, I am not sure if that is a problem but I posted the idea to another question to see if anyone knows. Still wondering if it might be a problem in the launch file cause for example even when I have the initial topic set to "map3" for some reason it still defaults to "map1". I just wish there was a better up to date way to deal with multiple maps lol.

JackB gravatar image JackB  ( 2019-06-25 13:53:36 -0500 )edit
1

Hmm ok, I am not sure if that is a problem but I posted the idea to another question to see if anyone knows.

I'm not sure what you mean by this.

In any case: in #q270129, @martin Peris also seems to suggest/confirm that because of the latching mux doesn't work:

You are right, the map server is latched, but since the multiplexer subscribes only once to each topic (when you launch the multiplexer) the map will not be resent through the multiplexer when you select the topic you want to listen to.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-25 13:57:54 -0500 )edit

Thanks for the help!

JackB gravatar image JackB  ( 2019-06-25 14:41:05 -0500 )edit