Translate/transform map.data to x,y coordinates to send to move_base
So I'm working on moving to a random location on the map while GMapper is running. So, I'm choosing a random int in map.data and making sure it's not unoccupied or explored. I then want to translate this position in the list to an x,y coordinate goal that I send to move base. Is there a transform or function that converts the map.data[point] into an X,Y coordinate? I know it's in row-major order, but because of the offset of the origin, there needs to be negative values as well.
Edit: Basically, I'm trying to get the robot to move to a randomly chosen, known area.
Edit2 : Thanks Lorenz,
It was this: x = map.map.info.origin.position.x + int(point%map.map.info.width) * map.map.info.resolution y = map.map.info.origin.position.y + int(point/map.map.info.width) * map.map.info.resolution
Width is not what I was expecting it to be.
Thanks
Thanks Lorenz. That should do it. I THOUGHT it was straight forward, but was not getting it right. I haven't tested it yet, but I think I was mixing up the order of ops with the resolution, as in adding the origin first then multiplying by the resolution.
The orientation shouldn't matter....
Sorry. My bad. Of course it needs to be width and not height when calculating y. I updated my answer.