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

Save a map via a ROS node

asked 2018-11-11 17:44:30 -0500

sachith gravatar image

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 map_server map_saver -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

edit retag flag offensive close merge delete

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.

billy gravatar image billy  ( 2018-11-12 10:38:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-11 23:16:15 -0500

Hamid Didari gravatar image

updated 2018-11-11 23:16:34 -0500

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();
edit flag offensive delete link more

Comments

This worked. Thanks!

sachith gravatar image sachith  ( 2018-11-12 10:39:54 -0500 )edit
1

can you add your code @sachith to see how you solved it. Thank you!!

Jose Susa gravatar image Jose Susa  ( 2021-02-10 16:44:02 -0500 )edit

Question Tools

Stats

Asked: 2018-11-11 17:44:30 -0500

Seen: 1,559 times

Last updated: Nov 11 '18