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

using nav msg map in UI

asked 2021-07-21 21:28:01 -0500

dinesh gravatar image

I am developoing a mission planner where nav_msgs/MapMeta data has been loaded into ui. Here i am trying to display the position of robot in given map with (x,y) coordinates. The map.yaml is as:

image: nic_map4.pgm
resolution: 0.050000
origin: [-51.224998, -51.224998, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196

Here for example if the robot position is comming as (1,1) a set the robot pose as x=1resolution, y=1resolution but the positions seems not correct. How exactly should i display the position of robot in given map.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-22 02:23:57 -0500

Immanuel gravatar image

Hi,

The origin of the map.yaml [-51.224998, -51.224998, 0.000000] refers to the position of the bottom left corner pixel of your map image with respect to your map frame. So, in order to represent your robot's position at (1,1) [with respect to the map frame], your pixel value from the bottom left corner of the map image would be: [1044.49996 pixels,1044.49996 pixels]

Calculation:

pixel value of the map origin in x: +51.224998 / resolution = +51.224998 / 0.05 = 1024.49996 pixels

pixel value of the map origin in y: +51.224998 / resolution = +51.224998 / 0.05 = 1024.49996 pixels

Now,

pixel value of the position (1,1) with respect to your map frame in x:

1024.49996 pixels + (1/resolution) = 1024.49996 pixels + (1/0.05) = 1044.49996 pixels

pixel value of the position (1,1) with respect to your map frame in y:

1024.49996 pixels + (1/resolution) = 1024.49996 pixels + (1/0.05) = 1044.49996 pixels

Please note: I am considering the pixel values with respect to the bottom left corner of the image.

edit flag offensive delete link more

Comments

I tried this in my code, the position of robot is somehow improved but still the robot seems to not be in exact place in given map as seen here. https://www.youtube.com/watch?v=lYn9n...

dinesh gravatar image dinesh  ( 2021-07-22 13:12:38 -0500 )edit

hmm. that is a little weird. It looks like there is some calculation error. What are your image dimensions (in pixels) (on ubuntu, right-click on the image, go to properties > image)

Immanuel gravatar image Immanuel  ( 2021-07-22 13:31:40 -0500 )edit

width, height = 384*384 map.yaml: image: ./map.pgm resolution: 0.050000 origin: [-10.000000, -10.000000, 0.000000] negate: 0 occupied_thresh: 0.65 free_thresh: 0.196

dinesh gravatar image dinesh  ( 2021-07-22 13:46:47 -0500 )edit

basically, if the robot pose is (x,y): your pixel values would be (200 + x/0.05 pix, 184 - y/0.05 pix) [where your 0,0 is at the top left corner]

Immanuel gravatar image Immanuel  ( 2021-07-22 14:16:11 -0500 )edit

This is working, but can you tell me why 184 value is used instead of 200?

dinesh gravatar image dinesh  ( 2021-07-22 23:51:42 -0500 )edit

so (200 + x/0.05, 200 + y/0.05) is the value when you consider it with respect to the bottom left corner but when you consider it with respect to the top left corner (which is the way in which pixels are considered for image processing), you will need to subtract image height 384 - (200+y/0.05) = 184 - y/0.05. so with respect to the top left corner, it would be (200 + x/0.05 pix, 184 - y/0.05 pix)

Immanuel gravatar image Immanuel  ( 2021-07-23 02:18:55 -0500 )edit

Also, your application looks interesting. Are you kind of using some GUI to switch between the mapping mode and the localization mode?

Immanuel gravatar image Immanuel  ( 2021-07-23 02:20:25 -0500 )edit

I am developing a qt quick based GUI from where user can send the mission command to any service robot deployed, here in mapping mode user can assign unique name for location selected in map.

dinesh gravatar image dinesh  ( 2021-07-23 02:55:28 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-07-21 21:28:01 -0500

Seen: 91 times

Last updated: Jul 22 '21