Ask Your Question

Save map before exiting launch file

asked 2014-03-16 16:25:34 -0500

clonzz gravatar image


I have a launch file which runs 2 nodes (i.e slam_gmapping and rosbag play). I set the rosbag node so that required="true" . So, the launch file and all other nodes running will be killed once the rosbag is finished.

My problem is, I want to save the map after the rosbag play is finished but before the launch file is killed. If I run the map_server in the launch file, it will save the initial map instead of the required final one. Is there any way to get the final map?

Thanks for any input. Appreciate it.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-03-18 22:10:12 -0500

clonzz gravatar image

updated 2014-03-18 22:27:55 -0500

I have successfully implement it using some trick. I compiled a c program with the following fraction of codes

system(roslaunch slam_gmapping.launch &); //In this launch file, put slam_gmapping node so that required='true'

system("rosbag play bagfile.bag");

system("rosrun map_server map_saver");

system("rosnode kill slam_gmapping");

Firstly, the program launch slam_gmapping.launch. This launch file was set such that required='true' for slam_gmapping node. Then, play the rosbag. After the rosbag play finished, the map is saved (at this time, the slam_gmapping.launch is still running and the map will definitely be available). Then, the slam_gmapping node is killed and thus killing the launch file safely (since the required='true' is set to the node).

edit flag offensive delete link more

answered 2014-03-16 23:50:44 -0500

dornhege gravatar image

This won't work like that. You could try some SIGINT -> Save map hacks, but that will be very unsafe. As soon as the bag runs out roslaunch will kill (nicely by SIGINT) all nodes - including gmapping which has the map. So if you have required=true as soon as that hits you have no guarantees that the map is still there.

Unfortunately I can't imagine a clear solution to this that doesn't involve some work. You could maybe just continuously save/overwrite the current map or supervise if the rosbag node is still there and save on that (without required=true).

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2014-03-16 16:25:34 -0500

Seen: 1,028 times

Last updated: Mar 18 '14