how to gracefully kill rosbag record using launchfile

asked 2019-02-20 04:42:32 -0500

winwinftw90 gravatar image

Hi guys,

I am trying to find a way to gracefully kill rosbag record using a launchfile.

I am type:

<launch> <pkg =="" "rosnode"="" type="rosnode" arg="kill -a" name="shutdown"/> </launch>

When i launch it, they can't find the node. Is there a better way to do this? As i want to use a system service to run this launch file when shutting down

edit retag flag offensive close merge delete

Comments

Just to clarify you want to kill rosbag record when your system is shutting down yes? If so this should be fairly straightforward with a bash script without using a launch file at all.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-02-20 06:35:39 -0500 )edit

Hi Peter, yes you are right. may you enlighten me on the ways to do it. I have tried bash scripts but none work. I thinking that using rosnode kill and using it via a launch script is the only way that I can think of as for now

winwinftw90 gravatar image winwinftw90  ( 2019-02-20 07:40:01 -0500 )edit

You should be able to use the command pkill rosbag the tricky part is that you will need to ensure that the user running that command has the permissions to kill that process. Also rosbag can take a while to finish writing the file, during system shutdown this could be problematic.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-02-20 09:04:06 -0500 )edit

I see, will give it a shot. Thanks for the advice

winwinftw90 gravatar image winwinftw90  ( 2019-02-20 09:09:46 -0500 )edit