ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ktomas's profile - activity

2012-09-25 01:38:49 -0500 received badge  Notable Question (source)
2012-09-25 01:38:49 -0500 received badge  Famous Question (source)
2012-05-26 13:21:27 -0500 received badge  Popular Question (source)
2011-11-17 11:10:30 -0500 marked best answer map_server GetMap

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.

2011-09-12 05:34:34 -0500 received badge  Student (source)
2011-09-11 14:33:10 -0500 asked a question map_server GetMap

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?