Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The second robot map seems not in the right position #15

Closed
Vincent1923 opened this issue May 4, 2018 · 13 comments
Closed

The second robot map seems not in the right position #15

Vincent1923 opened this issue May 4, 2018 · 13 comments
Labels

Comments

@Vincent1923
Copy link

Vincent1923 commented May 4, 2018

Thank you for the package. It is discovering all robots and map topics perfectly. But there was some problem when it merged the maps. The two maps were published through two rosbag. When I used the “known_init_poses” mode, it seems the transform between the two maps is not right. I call the two maps “/robot1/map” and “/robot2/map”. And I set the world_frame to “/robot2/map”. The maps published by map_server are as follows. The starting point of both maps in the ground is the same.

map1.pgm:
qq 20180504102225

map1.yaml:
image
map2.pgm:
qq 20180504102801

map2.yaml:
image
Here is the map_merge.launch file and I add the initial poses in it.

<launch>
<group ns="map_merge">
  <node pkg="multirobot_map_merge" type="map_merge" respawn="false" name="map_merge" output="screen">
    <param name="robot_map_topic" value="map"/>
    <param name="robot_namespace" value=""/>
    <param name="merged_map_topic" value="map"/>
    <param name="world_frame" value="/robot2/map"/>
    <param name="known_init_poses" value="true"/>
    <param name="merging_rate" value="0.5"/>
    <param name="discovery_rate" value="0.05"/>
    <param name="estimation_rate" value="0.1"/>
    <param name="estimation_confidence" value="1.0"/>
  </node>
</group>

<group ns="/robot1/map_merge">
  <param name="init_pose_x" value="-122.356226"/>
  <param name="init_pose_y" value="-97.080847"/>
  <param name="init_pose_z" value="0.0"/>
  <param name="init_pose_yaw" value="0.0"/>
</group>
<group ns="/robot2/map_merge">
  <param name="init_pose_x" value="0.0"/>
  <param name="init_pose_y" value="0.0"/>
  <param name="init_pose_z" value="0.0"/>
  <param name="init_pose_yaw" value="0.0"/>
</group>

</launch>

Here is the merged map and I set the world_frame to “/robot2/map”. But the “/robot1/map” is not in the right position.
qq 20180504103857

I don't know if the parameters I set are correct. Could you please give me some help? Thank you!

@hrnr
Copy link
Owner

hrnr commented May 4, 2018

Hi,

you should set world_frame to something else, there should be no slashes. default is "world", you don't need to change it unless it conflicts with already existing frame (gps etc.). see http://wiki.ros.org/tf2/Migration#Removal_of_support_for_tf_prefix and http://www.ros.org/reps/rep-0105.html

Setting the initial positions can be quite non-intuitive currently, because the merger does not use maps' origins and the coordinate system is always fixed in (0,0), which is a corner. You may need to offset for the origin. You need to adjust params under /robot1/map_merge to align maps properly.

Have you tried using automatic merging mode (without known positions)? I see your maps do not have much overlapping space, but if you are able to put there more overlapping space, that should work for you out-of-the-box.

I can take a look at your maps, but I need to have original .pgm + .yaml files for both maps to be able to use it with map_server myself. Screenshots are not helpful for debugging. If you want to work without the known initial positions the maps need to have enough overlapping space (as much as possible). If you want to work with known initial positions you need to know the ground truth transformation between maps. Then I can take a look and see what is the problem.

Cheers,
Jiri

@hrnr hrnr added the question label May 4, 2018
@Vincent1923
Copy link
Author

Vincent1923 commented May 4, 2018

Thank you for your prompt reply!
I have tried merging the maps without known positions. I could not get the merged map as the two maps do not have much overlapping space. Here is the output of the terminal.
screenshot from 2018-05-04 17-38-18

I will appreciate you for helping me have a look at my maps. Here is my original .pgm + .yaml files for both maps.

Thank you very much!

@hrnr
Copy link
Owner

hrnr commented May 4, 2018

  1. Your maps seems to be broken. Marking of the free space, unknown space and occupation values are switched. What is the source of your maps? The maps should have correctly marked free space and unknown space according to the specification of the of the occupancy grid msg http://docs.ros.org/api/nav_msgs/html/msg/OccupancyGrid.html

  2. Are we using the same maps? I'm getting quite different results.

0 1
features: 39981 28580
matches: 628
inliers: 3
inliers/matches ratio: 0.00477707
confidence: 0.0152749
[-0.07158130290853876, 0.0264739041042349, 2523.265982276639;
 -0.0264739041042349, -0.07158130290853876, 2424.609337158685;
 0, 0, 1]
  1. What is the expected transformation between maps origins?

@Vincent1923
Copy link
Author

Vincent1923 commented May 6, 2018

Thank you for your answer. I am sorry that I reply so late!

  1. I use the google's cartographer_ros to get the maps. And I used the map_server to save the two maps. But I have changed a little of the source code of the “map_saver.cpp”. I think this is the reason why the maps looks different.

  2. We are using the same maps, but I got the results above when the two maps were generating.

  3. I want to merge the two maps but I don’t know if the parameters I set are correct.

@hrnr
Copy link
Owner

hrnr commented May 7, 2018

  1. You need to fix the marking of free space, unknown space and occupation. Even with correct transformation your maps can not be merged. Think about overlaying the values.

  2. makes sense

  3. when you use merging with known initial positions you are responsible for entering the correct transformation (initial position). Therefore the parameters (your initial position) were not correct.

@hrnr
Copy link
Owner

hrnr commented May 7, 2018

Also, when saving maps make sure to select lossless format. Your pngs are full of compression artefacts.

@hrnr hrnr added the invalid label May 7, 2018
@Vincent1923
Copy link
Author

  1. Dose it means that if I don't fix the marking of free space, unknown space and occupation in my maps, I can't get the correct merged map even with setting the correct parameters?

  2. Dose the correct transformation (initial position) means the lower left corner of each map?

  3. The map format I use is pmg. Do you mean my pgms are full of compression artefacts?

  4. If the yaml files of the two maps are as follows, could you please tell me the correct parameters?

map1.pgm:
11
map2.pgm:
22

@hrnr
Copy link
Owner

hrnr commented May 7, 2018

  1. yes

  2. it means the true starting possition of the robot in your frame of reference

  3. oh sorry, that was just the interpolation of my viewer. pgm is fine, always lossless.

  4. you can not tell that from the yaml files. You need to know true starting positions of the robots. For example measure the distance in x,y,z and angular difference between 2 robots in meters (with a ruler or your own localisation system).

@Vincent1923
Copy link
Author

Vincent1923 commented May 8, 2018

  1. The true starting positions of the robots are the same in the ground, and it is the position I have pointed out in the first picture and the second picture above.

  2. I have changed the marking of free space, unknown space and occupation in my maps. Here are the original .pgm + .yaml files of the new maps. How can I set the parameters to get the correct merged map?

Thank you!

@hrnr
Copy link
Owner

hrnr commented May 17, 2018

the problem with maps seems to be fixed. I'll take a look, but it'll take while since I'm busy these days.

@MerryMarry
Copy link

Hello
if you figured it out pls tell us
thank you

@Sadighi-Nicky
Copy link

If you are using gmapping, try to set the zero point in the middle of the map like this in your launch file:

<param name="xmin" value="-200" />
<param name="xmax" value="200" />
<param name="ymax" value="200" />
<param name="ymin" value="-200" />

then set the initial positions in your merging launch file to 0.0. This works fine for me, hope it helps you too.

@MerryMarry
Copy link

If you are using gmapping, try to set the zero point in the middle of the map like this in your launch file:

<param name="xmin" value="-200" />
<param name="xmax" value="200" />
<param name="ymax" value="200" />
<param name="ymin" value="-200" />

then set the initial positions in your merging launch file to 0.0. This works fine for me, hope it helps you too.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants