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

Map Message C++

asked 2012-08-08 03:55:55 -0500

allenh1 gravatar image

Does anyone have some sample code for publishing a map given a set of coordinates? I am in need... I figured it would be pretty straight forward, then the documentation confused me... Any advice?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-08-08 04:20:42 -0500

DimitriProsser gravatar image

The OccupancyGrid message contains three parts:

1) The Header information. This will include the frame_id of the map. When specifying the origin of the map in the MapMetaData, the Pose that you use will be in this frame.

2) The meta data tells you the map resolution, the height, the width, and the time it was created. It also contains the origin of the map in the frame specified in the header's frame_id.

3) The actual data for the map. It's in row-major order, which means you will fill the data array like so: [row0, column0, row1, column1, row2, column2 ...].

NOTE: The catch with this message is that the data array only supports signed 8-bit integers (i.e. char) and can only be filled with values from -128 to +127. I'm not sure what you're trying to do with this map, but keep that in mind.

edit flag offensive delete link more

Comments

I'm implementing an old algorithm as a comparison to mine. It predates SLAM. It's a similar method to mine.

allenh1 gravatar image allenh1  ( 2012-08-08 04:24:17 -0500 )edit

Ok. I have a collection of points. I'm starting to understand how to work this... Since I have a list of occupied points, how do I include the blank space/uncharted space?

allenh1 gravatar image allenh1  ( 2012-08-08 04:41:50 -0500 )edit

Set those cells to -1 (unknown).

dornhege gravatar image dornhege  ( 2012-08-08 05:14:50 -0500 )edit

But where do I start with the map? I have the indices of only occupied. How should I approach iterating through the array to include the spaces that won't be indices of the array? Or is that just a problem for me...

allenh1 gravatar image allenh1  ( 2012-08-08 05:17:52 -0500 )edit

For a collection of points, you set those cells to occupied. Usually you'll have some functions like world2grid/grid2world that, given a map convert between points and coords/indices.

dornhege gravatar image dornhege  ( 2012-08-08 05:18:24 -0500 )edit

You'd initialize the whole map as unknown.

dornhege gravatar image dornhege  ( 2012-08-08 05:19:09 -0500 )edit
0

answered 2012-08-08 04:14:03 -0500

dornhege gravatar image

I don't have sample code, but my interpretation of the message semantics are as follows:

  • Cell (0, 0) is at info.origin.
  • Cell (i, j) is at (info.resolution * i, info.resolution * j) transformed by info.origin
  • Cell (i, j) can be found in data[j + i * info.width]
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-08 03:55:55 -0500

Seen: 652 times

Last updated: Aug 08 '12