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

Revision history [back]

By the OccupancyGrid.msg definition you know it is a row-major order 2D array, with a MapMetaData:

float32 resolution
# Map width [cells]
uint32 width
# Map height [cells]
uint32 height
# The origin of the map [m, m, rad].  This is the real-world pose of the
# cell (0,0) in the map.
geometry_msgs/Pose origin

You have already computed robotPoseGridX and robotPoseGridY (I assume it's correct), you know both dimensions of the map [cells], you can determine, using the integer divisions and modulo operations, the cells to change value around around (robotPoseGridX, robotPoseGridY) to -1.

image description

For the OX use % width, for the OY - / width.

By the OccupancyGrid.msg definition you know it is a row-major order 2D array, with a MapMetaData:

float32 resolution
# Map width [cells]
uint32 width
# Map height [cells]
uint32 height
# The origin of the map [m, m, rad].  This is the real-world pose of the
# cell (0,0) in the map.
geometry_msgs/Pose origin

You have already computed robotPoseGridX and robotPoseGridY (I assume it's correct), you know both dimensions of the map [cells], you can determine, using the integer divisions and modulo operations, the cells to change value around around (robotPoseGridX, robotPoseGridY) to -1.

image description

For the OX - use % width, for the OY - / width. to translate the (robotPoseGridX, robotPoseGridY) <--> row-major order map.

By the OccupancyGrid.msg definition you know it is a row-major order 2D array, with a MapMetaData:

float32 resolution
# Map width [cells]
uint32 width
# Map height [cells]
uint32 height
# The origin of the map [m, m, rad].  This is the real-world pose of the
# cell (0,0) in the map.
geometry_msgs/Pose origin

You have already computed robotPoseGridX and robotPoseGridY (I assume it's correct), you know both dimensions of the map [cells], you can determine, using the integer divisions and modulo operations, the cells to change value around around (robotPoseGridX, robotPoseGridY) to -1.

image description

For the OX - use % width, for the OY - / width to translate the between (robotPoseGridX, robotPoseGridY) <--> row-major order map.map (with relevant offset for the space the robot sweeps).