Map transformation from Pixel to world coordinates

asked 2020-08-19 04:25:15 -0500

rexrayne92 gravatar image

Hey Guys,

I need some help with the following problem.I have a map of a room. In this map I draw circle for the starting position of the robot and save this as an additional svg file which I can parse for the starting Position of the robot. Then I transform the pixel coordinates to real world coordinates with help of yaml file of the map (resolution and origin parameters). The problem is the trasnformation is wrong the real world coordinates don´t match with pixel coordinates. I use this formula for the transformation: pose.x / resolution + CenterOfOrigin[pixels] = cell_x

Here are the parameters of the yaml-File:

resolution: 0.050000
origin: [-50.000000, -50.000000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

I got a map of the room this map is 1984x1984 Pixel. Therefore (cell_x-50/0.05)*0.05=pose_x. I used the formula and used these pixel-coordinates for reference:

x=988
y=985

So I got this real worlds coordinates:

x_real= -0.6
y_real= -0.75

The x-real coordinate seems to be fine in rviz I checked the position and it was at x_real=-0.55, but the y_real was wrong rviz showed me for this coordinate y_real=-0.05. But then I should have used another CenterOfOrigin for the y-coordinate. So maybe someone could tell me what I missed with the transformation ? I add the map as a file map_room

kind regards

Rex

edit retag flag offensive close merge delete

Comments

Shouldn't you use something like this to convert from pixel to world in meters (not sure if it has to be + or - origin_x/y

pixel_x * res - origin_x = real_x
pixel_y * res - origin_y = real_y

Edit: with minus it seems to give same answers -0.6 and -0.75 so maybe you wrongly measured in rviz?

Combinacijus gravatar image Combinacijus  ( 2020-08-20 07:54:10 -0500 )edit