Save a map via a ROS node
Hi all,
I'm a ROS noob. I have a use case where I need to save the map (generated via gmapping on rviz), when I receive an event.
The use case is when I've detected 4 objects (turtlebot3), I need to save the image and this should be automated. So cannot use "rosrun mapserver mapsaver -f ~/map".
Is there anyway I can do this via a ROS node? Basically the same way how the map_server does it?
Thanks, Sachith
Asked by sachith on 2018-11-11 18:44:30 UTC
Answers
hi
you can clone map_server pkg and change what's you need and compile it.
for example you can change this par of code and add a subscriber for save map after you send some data to subscriber
remember you also must change this part of code
while(!mg.saved_map_ && ros::ok())
ros::spinOnce();
to
ros::spin();
Asked by Hamid Didari on 2018-11-12 00:16:15 UTC
Comments
This worked. Thanks!
Asked by sachith on 2018-11-12 11:39:54 UTC
can you add your code @sachith to see how you solved it. Thank you!!
Asked by Jose Susa on 2021-02-10 17:44:02 UTC
Comments
You can try a system call within your node to run the map server-save via rosrun. https://www.geeksforgeeks.org/system-call-in-c/
There are some warnings on the linked page about issues/constraints. YMMV.
Asked by billy on 2018-11-12 11:38:33 UTC