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!
Originally posted by Flash on ROS Answers with karma: 126 on 2022-03-21
Post score: 0
Original comments
Comment by ljaniec on 2022-03-21:
As I understand from documentation there: https://github.com/ros-planning/navigation2/tree/main/nav2_map_server and a description there: https://github.com/ros-planning/navigation2/tree/main/nav2_map_server, 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...
Comment by Flash on 2022-03-21:
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?
Comment by ljaniec on 2022-03-22:
I copied the same link twice, second link should be https://navigation.ros.org/configuration/packages/configuring-map-server.html, I cannot edit it now, sorry. I will check the source code and the format of this message in a moment :)
Comment by ljaniec on 2022-03-22:
Based on this https://github.com/ros-planning/navigation2/blob/main/nav2_map_server/include/nav2_map_server/map_server.hpp it should be this format http://docs.ros.org/en/lunar/api/nav_msgs/html/msg/OccupancyGrid.html - 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/navigation2/blob/main/nav2_msgs/srv/LoadMap.srv to get the map.
Comment by Flash on 2022-03-22:
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.
Comment by ljaniec on 2022-03-25:
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.
Comment by Flash on 2022-03-25:
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