Ctrl+C can't kill the ros2 run

asked 2020-06-04 22:52:02 -0500

kk2105 gravatar image

updated 2020-06-06 04:52:15 -0500

Hi Guys,

I have one ROS2 subscriber and one ROS2 publisher. To ease the execution I have written a bash script which calls both nodes and executes them simultaneously.

Content of the bash script is as below:

ros2 run perception_publisher publisher &  
ros2 run behavior_planning_hmi hmi

Execution works fine, however when I try to kill the execution by pressing Ctrl+C script is not being terminated. It ends up running continuously that I have to kill using the process ID.

Is there a way I can kill the process gracefully?

Thank you,
KK

edit retag flag offensive close merge delete

Comments

Can you stop the execution with strg+c when you start only one node directly? If not you have maybe some blocking code or you do not spin.
To start multiple nodes i recommend to use a launchfile. see https://index.ros.org/doc/ros2/Tutori...

MrCheesecake gravatar image MrCheesecake  ( 2020-06-05 10:10:22 -0500 )edit

Thanks for your reply. Yes, I can stop using Ctrl+C when running single node.

kk2105 gravatar image kk2105  ( 2020-06-06 04:53:26 -0500 )edit