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

Translate/transform to x,y coordinates to send to move_base

asked 2012-07-12 04:36:01 -0600

IFLORbot gravatar image

updated 2012-07-12 07:43:41 -0600

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 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[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 = + int( * y = + int(point/ *

Width is not what I was expecting it to be.


edit retag flag offensive close merge delete


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....

IFLORbot gravatar image IFLORbot  ( 2012-07-12 05:11:52 -0600 )edit

Sorry. My bad. Of course it needs to be width and not height when calculating y. I updated my answer.

Lorenz gravatar image Lorenz  ( 2012-07-12 07:45:27 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-07-12 04:47:25 -0600

Lorenz gravatar image

updated 2012-07-12 07:45:47 -0600

Given the width, height and the origin of the map, it should be fairly trivial:

x = + (point % *;
y = + static_cast<int>(point / *;

Node that this discards the orientation of the origin. However, I haven't seen it used so far. If you want to have a really clean solution, you need to first calculate the x and y coordinates without taking into account the origin transform, put it into a pose and multiply the origin with that pose.

edit flag offensive delete link more

Question Tools


Asked: 2012-07-12 04:36:01 -0600

Seen: 678 times

Last updated: Jul 12 '12