Ask Your Question
1

map_server GetMap [closed]

asked 2011-09-11 14:33:10 -0500

ktomas gravatar image

updated 2014-01-28 17:10:22 -0500

ngrennan gravatar image

Goals: - Robot 1 to save a partial map - Robot 2 use Robot 1's saved map to build the rest of the entire map

Assumptions: - Robot 1 & 2 are using the same world, and everything is relative. Only difference is the start position of Robot 2.

Currently I'm using slam_gmapping to generate the map, and using map_server to save the map.

Using slam_gmapping, I want to call the service to retrieve the map instead of initializing it for Robot 2.

Map_server provides the service 'static_map', but I'm still confused on how to use this service using cpp code. I've looked at the AddTwoInts cpp example but I'm confused on applying it to the map_server service.

Any advice, or is there any tutorials or sample code's that I could look at?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Procópio
close date 2016-04-27 06:08:27.104656

1 Answer

Sort by » oldest newest most voted
4

answered 2011-09-11 19:01:10 -0500

You first have to create a service client somewhere:

    map_service_client_ = n_.serviceClient<nav_msgs::GetMap>("map");

Then, you can use it like this:

nav_msgs::GetMap srv_map;

if (map_service_client_.call(srv_map))
{
  ROS_INFO("Map service called successfully");
  const nav_msgs::OccupancyGrid& map (srv_map.response.map);
  //do something with the map
}
else
{
  ROS_ERROR("Failed to call map service");
  return;
}

This is the easy part. More difficult is initializing gmapping with an existing map. It keeps multiple map/pose hypotheses in memory, so initializing it would mean you have to initialize all those. This hasn't been done before AFAIK and will require that you change code inside the gmapping core, which internally uses a different map representation than ROS does. I'm sure it's doable, but it will require some work.

edit flag offensive delete link more

Comments

Indeed, I don't know of anybody who's used gmapping (or another FastSLAM implementation) in that fashion. I expect that it would be a LOT of work to figure out what internal state of the mapper to save and retrieve, and then I'd expect the resulting system to be pretty fragile. To be able to stop and resume, you really want a different approach to mapping that designed to have that capability.
Brian Gerkey gravatar image Brian Gerkey  ( 2011-09-12 16:27:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2011-09-11 14:33:10 -0500

Seen: 2,496 times

Last updated: Jan 28 '14