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 imagebilly ( 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 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 imagesachith ( 2018-11-12 10:39:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 198 times

Last updated: Nov 11 '18