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

Publishing on /map topic only once and data output format

asked 2022-03-21 18:27:15 -0600

Flash gravatar image

updated 2022-03-21 20:08:05 -0600

Hi,
I am trying to run nav2_map_server. I am seeing map_server is publishing only once on topic /map even and this is published when I launch the node. I can provide the launch file if necessary.
And the echo on the topic looks something like this.

header:
  stamp:
    sec: 1647904550
    nanosec: 512909420
  frame_id: map
info:
  map_load_time:
    sec: 1647904550
    nanosec: 512906384
  resolution: 0.019999999552965164
  width: 632
  height: 799
  origin:
    position:
      x: -10.0
      y: -20.24
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
data:
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0

When I was working with ros1 I use to get data in form of an array/matrix but this is kind of new to me. Is this the right format of an output or is it something that I am missing?
Thanks in advance for the help!

edit retag flag offensive close merge delete

Comments

As I understand from documentation there: https://github.com/ros-planning/navig... and a description there: https://github.com/ros-planning/navig..., after map load request you have this map published on /map topic once. If you want to publish it more than 1 time, you have to request it again each time. I could be wrong, I am still learning Nav2...

ljaniec gravatar image ljaniec  ( 2022-03-21 20:03:15 -0600 )edit

okay, so do you mean I have to make a service call every time I want the map data. And do you know if the output data is in the correct format?

Flash gravatar image Flash  ( 2022-03-21 20:10:31 -0600 )edit

I copied the same link twice, second link should be https://navigation.ros.org/configurat..., I cannot edit it now, sorry. I will check the source code and the format of this message in a moment :)

ljaniec gravatar image ljaniec  ( 2022-03-22 04:10:48 -0600 )edit

Based on this https://github.com/ros-planning/navig... it should be this format http://docs.ros.org/en/lunar/api/nav_... - it seems to match what you got there. You can check it easily with ros2 node info /your_node_nametoo :) I would call this service https://github.com/ros-planning/navig... to get the map.

ljaniec gravatar image ljaniec  ( 2022-03-22 04:22:03 -0600 )edit

Thanks @ljaniec it helped :D.
Data provided on the map topic is in a 1D array with row-major, so I have to convert from 1D to 2D using other methods.
And to get the map data I have to run the map_server which only pub 1 time as you mentioned.
For my other problem, I need to add map_server to my launch file so that my other nodes get the data as soon as map_server launches. There must be another way I can request without launching but will work with this method until I find another solution.

Flash gravatar image Flash  ( 2022-03-22 16:31:56 -0600 )edit

I think it could be a new question overall, let's solve problems step by step, you can link it there too. I will paste these comments as an answer too, so you can upvote and mark question as solved.

ljaniec gravatar image ljaniec  ( 2022-03-25 09:55:41 -0600 )edit
1

I think my problem was in understanding if map_server publishes only once- which is true and the other was data format which is in form of a 1D row-major array. We can mark it as solved. Thanks for help @ljaniec

Flash gravatar image Flash  ( 2022-03-25 10:02:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-03-25 10:02:13 -0600

ljaniec gravatar image

As I understand from documentation there:

and a description there:

https://navigation.ros.org/configurat...

after map load request you have this map published on /map topic once. If you want to publish it more than 1 time, you have to request it again each time.

Based on this: https://github.com/ros-planning/navig...

it should be this format: http://docs.ros.org/en/lunar/api/nav_...

It seems to match what you got there. You can check it easily with ros2 node info /your_node_name too :)

I would call this service:

https://github.com/ros-planning/navig...

(it could be done within the code too normally, not only with launchers)

Copied from the discussion under question.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-03-21 18:27:15 -0600

Seen: 1,033 times

Last updated: Mar 25 '22