How to exit a terminal automatically after ROS is killed?

asked 2020-06-04 04:45:00 -0500

Py gravatar image

I have a keyboard teleoperation node launched as follows:

<node pkg="my_package" type="" name="teleoperation" output="screen"
      launch-prefix="gnome-terminal --command" />

This all functions fine but when I kill the ROS process (Ctrl + C on the main ROS terminal) the keyboard teleoperation terminal stays open. My question is how do I make this exit/close when I kill the ROS process? In iterative development and functionality checking I'm ending up with loads of terminals still open from previous times I've run the launch file.

edit retag flag offensive close merge delete



Terminal management is not something which is part of the roslaunch domain model (as far as it has one), so there is also no support for it.

Any 'solution' will most likely be a trick.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-04 05:19:55 -0500 )edit

Well, in Kinetic there a trick. You can launch the node using terminator.

<node pkg="my_package" type="" name="teleoperation" output="screen" launch-prefix="terminator -x python" />

it launches in another terminal and when the main terminal receives the `Ctrl + C, terminator kill the second terminal.

Note: As for anyone wanting to use this trick with newer versions of ROS (Melodic for instance), since terminator is being reimplemented with the new graphics of new Ubuntu versions, there a bug that prevent terminator for being launched when using the node launch parameter.

Weasfas gravatar image Weasfas  ( 2020-06-05 06:30:27 -0500 )edit