Skip to content

Instantly share code, notes, and snippets.

@keshuaixu
Last active November 15, 2017 02:37
Show Gist options
  • Save keshuaixu/03031ab455b5faac30e04d9998990cf9 to your computer and use it in GitHub Desktop.
Save keshuaixu/03031ab455b5faac30e04d9998990cf9 to your computer and use it in GitHub Desktop.
Converting between point coordinates and grid array indices

From /map coordinates to grid array indices:

gridx = int((pose.position.x - offsetX - (.5 * resolution)) / resolution)
gridy = int((pose.position.y - offsetY - (.5 * resolution)) / resolution)

From grid array indices to /map coordinates:

point.x = (array_index_x * resolution) + offsetX + (.5 * resolution)
point.y = (array_index_y * resolution) + offsetY + (.5 * resolution)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment