ros-planning / navigation

ROS Navigation stack. Code for finding where the robot is and how it can get somewhere else.
2.25k stars 1.79k forks source link

map_server: reload_map_from_file service? #279

Open MartinPeris opened 9 years ago

MartinPeris commented 9 years ago

Hi there,

I was wondering if it would be useful to implement a service on map_server to reload the map from a file. I think it would be beneficial in multi-floor environments where one needs to change the map due to the robot changing floors, instead of having to kill the map_server node and starting it again with the map of the new floor.

Please let me know if this can be already achieved by some other means

mikeferguson commented 9 years ago

One way I have seen folks do multi-floor is to lay all the floor maps next to each other on a single map and then "teleport" the robot between floors when it goes into an elevator.

That said, loading a new map seems a bit better. The only concern than would be that everything that consumes the map updates correctly.

MartinPeris commented 9 years ago

The "teleporting" option might be a quick hack, but I don't think that should be considered "best practice".

In my humble opinion, that the map consumers updates correctly should be a concern... for the map consumers, don't you think?

Anyway, I am going to implement this feature for my own project so, I will send a pull request :)

DLu commented 9 years ago

This is another use case where layered costmaps are useful. Rather than teleporting the robot, I've created several static maps that share the same coordinate system. Then, when a new map is published on the /map topic, the static data will be swapped out for the new data.

What I'd recommend doing is creating a map_mux that takes several published topics (/floor1_map /floor2_map etc) and switches which one of them is published to /map can be changed by the method of your choosing.

MartinPeris commented 9 years ago

Thanks for your suggestion David. I think it is a good idea, but what would be the advantage of having all the maps loaded in memory at the same time (which can be a non negligible amount of memory) in contrast with loading them from disk when needed?

DLu commented 9 years ago

I'd say its the ROS-iest way to do it, with the added benefit of having no changes to map_server. You could also have multiple robots on different floors, perhaps. I have no response about the amount of memory.

MartinPeris commented 9 years ago

From a ROS-iness point of view, sounds reasonable. I think I'll do it this way although we might want to give it some more thought.

How about this?

1 - Create package _map_servermux 2 - _map_servermux node will receive a list of map, _mapmetadata topics and _staticmap services + a default map topic (using rosparam perhaps?) 3 - _map_servermux will publish the map and _mapmetadata topics + _staticmap service according to the selected source 4 - _map_servermux will provide the service _switchsource that will effectively switch the map topics to be published and static_map service to be referenced.

The _switchmap.srv declaration would be something like:

string source_name

And a parameter configuration example could be:

map_sources : map1 map2
default_map : map1
map1 : { map : '/map1', map_metadata : '/map1_metadata', static_map : '/static_map1'}
map2 : { map : '/map2', map_metadata : '/map2_metadata', static_map : '/static_map2'}

Any comments?

mikeferguson commented 9 years ago

@MartinPeris My one suggestion would be: if making a mux, maybe don't make it specifically for maps. There already exists a topic_tools/mux node which is frequently used with cmd_vel (the Pr2 for instance uses this mux to switch between joystick and application commands, allowing the joystick to override the application so you can steer away from danger). Of course, mux doesn't work for multiple topics (like your map/map_metadata stated above), but this is a common thing (cameras for instance typically have a camera_info topic in addition to the actual camera data). I can imagine that a multi_topic_mux (n*m->n topics, where current is m->1) would be quite useful in general.

mikeferguson commented 9 years ago

Bah, right after hitting enter I noticed the static_map aspects. I guess that would be slightly different from a generic node. However, I would note that your mux already has the map (since it has to pass the map through itself), and so it should be able to just advertise the static_map service itself and return the last map passed through the mux (no need to even tell the mux about the other static map services, they won't be used by anybody).

MartinPeris commented 9 years ago

@mikeferguson you are right, there is no need to tell the mux about the other static_map services. Regarding a generic node... might be out of my time availability :p

pzy2253999075 commented 5 years ago

Hello everybody, I am using map_server to load my maps to navigate my robot. But the maps are not already exist. They are produced in real time. I don't want to respawn my map_server node frequently. So I want to know if there is a way to load my map dynamically with map_server .Could you tell me how to do in a appropriate way? Thank you .

pzy2253999075 commented 5 years ago

@MartinPeris @DLu @mikeferguson @Could you tell me how to solve my problem I raised above. Thank you all

mikeferguson commented 5 years ago

If the map is being created in realtime -- why is map_server even involved? I would expect that the mapping program (be it gmapping, karto, cartographer, etc) would be publishing the map directly.

pzy2253999075 commented 5 years ago

Dear @mikeferguson ,I want to use my UAV to capture the image data in the air, and the image can be changed to a map after some treatment like using deep learning. After that I want to use the map to navigate my robot.The only tool I can use is map_server because I am using move_base.So I want to know if I can use map_server to load my map dynamically. I don't need to use the map comes from gmapping. Do you have any idea?

MartinPeris commented 5 years ago

You can plug directly to move_base a topic (/map) published by the process that generates your maps. No need to go through map_server :)

El mié., 27 mar. 2019 a las 18:46, pzy2253999075 (notifications@github.com) escribió:

Dear @mikeferguson https://github.com/mikeferguson ,I want to use my UAV to capture the image data in the air, and the image can be changed to a map after some treatment like using deep learning. After that I want to use the map to navigate my robot.The only tool I can use is map_server because I am using move_base.So I want to know if I can use map_server to load my map dynamically. I don't need to use the map comes from gmapping. Do you have any idea?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ros-planning/navigation/issues/279#issuecomment-477066277, or mute the thread https://github.com/notifications/unsubscribe-auth/AFob0tFrK25J_CYwaCsSIghBvqjjdZubks5vaz3hgaJpZM4C6jmu .

pzy2253999075 commented 5 years ago

Dear @MartinPeris,I did think about it before ,but I don't know the process to publish a /map by myself ,is there any tutorial about this ?Or maybe I can only see how to do it from inside the code in map_server. could you tell me? Thanks

pzy2253999075 commented 5 years ago

I have found a tool to change sensor_msgs/Image to nav_msgs/OccupancyGrid . I wiil try it.