Http://wiki.ros.org/map_server
Overview
Map_server provides the map_server Ros node, which provides map data as a Ros server. the map_saver command line feature is also available to dynamically generate maps saved to a file.
Map format
Maps in packages that are manipulated by tools are stored in piles of files. YAML The file describes the metadata of the map and names Image file. Image file encoding occupies data.
Image Format
Image describes the occupied state of each cell in the world in the color of the corresponding unit. The white cell represents freedom, the black cell is occupied, and the cell between the two colors is unknown. Both color and grayscale images are used, but most maps are grayscale ( Although they are stored as if they were in color ). The threshold of the YAML file is divided into 3 classes, and the threshold is done inside the map_server.
When comparing threshold parameters, the image unit occupancy probability is calculated as follows:OCC = (255-color_avg)/255.0,Color_avgis on average from all channels.8bit value results, such as if the image is -bit color, the color of a unit0x0a0a0ahave a0.96the probability that this is a completely occupied((255-(0*16+10))/255.0=0.96). Color0xeeeeeethe probability is0.07 ((255-(14*16+14))/255.0=0.07),not occupied at all.
When communicating via ROS messages, occupies an integer expressed as an interval [0,100] ,0 means completely free, Represents full occupancy, and a special value of 1 means that it is completely unknown.
Image data is read through sdl_image , and relies on a special platform provided by Sdl_image to support format changes. In general, most popular image formats are widely supported. An exception to note is that PNG is not supported on OS X.
YAML Format
the YAML format is best explained by a simple and complete example:
Image:testmap.pngresolution:0.1origin: [0.0, 0.0, 0.0]occupied_thresh:0.65free_thresh:0.196negate:0
Required bytes :
Image: The path to the image file that contains the occupied information , either an absolute path or a relative path to a YAML file.
resolution: resolution of the map,Meters/pixel
Origin: 2 -dimensional postureof the lower left corner unit ( pixel ) of the map,(X,y,yaw), the yaw rotates counterclockwise (yaw=0 indicates no rotation ). Many parts of the system now ignore Yaw.
Occupied_thresh : The probability that the unit occupies more than this threshold is considered to be fully occupied.
Free_thresh: The probability that the unit occupies less than this threshold is considered completely free.
negate: whether white / black, free / occupied,semantics ( semantics / Symbol ) should be reversed (the interpretation of the threshold value is not affected).
Command-line tools
Map_server
Map_server is a Ros node that reads a map from disk and provides maps through the Ros service.
the current implementation of Map_server is to convert the color values in the map image data to ternary occupancy values:free(0), occupied (+), unknown ( -1). A future version of this tool uses a value between 0 and $ to communicate with a more granular level of occupancy.
Usage
Map_server <map.yaml>
Example
Rosrun Map_server Map_server Mymap.yaml
Note, the map data may be locked by either a topic(means sending only one time to each subscriber)or services to retrieve. The service may end up being eliminated.
Post a topic
Map_metadata (Nav_msgs/mapmetadata)
Accept map metadata through this latched topic (Map metadata).
Map (Nav_msgs/occupancygrid)
Receive the map via this latched topic.
Service
Static_map (Nav_msgs/getmap)
The map is obtained by the service.
Parameters
~FRAME_ID (String, Default: "Map")
Sets the coordinate system of the head (header) of the published map .
Map_saver
Map_saver Save the map to disk, for example, from the SLAM mapping service.
Usage
Map_saver [-F mapname]
Map_saver Gets the map data and writes it to map.pgm and map.yaml. Use the- f option to provide a different base name ( the underlying name )for the output file.
Example
Rosrun Map_server map_saver-f Mymap
Subscribe to Topics
Map (Nav_msgs/occupancygrid)
Get a map from this locked topic.
(ros/navigation/slam_gmapping) map_server Map Server