Robotics StackExchange | Archived questions

ros2 node still running

Hello,

I am using ROS2 Humble on Ubuntu 22.04. I sometimes have problems with "ghost" nodes that continue to run after I kill the launch file. I can still see them when running ros2 node list and running the launch file again creates several bugs due to duplicate nodes and topics.

I don't really know where to look to solve this problem. Has anyone observed this behavior and have any ideas on how to fix it?

Asked by Sam_Prt on 2023-05-12 08:59:38 UTC

Comments

I have same problem :( You find any solution?

Asked by mustafakurban on 2023-05-14 04:38:34 UTC

The only time I see this is when I repeatedly use ctrl-c on my launch process. Typically if I use it once and let launch actually clean itself up then I don't get left-over processes running.

Asked by ChuiV on 2023-05-16 08:09:18 UTC

Good point, I will try only calling it once.

Asked by Sam_Prt on 2023-05-17 03:42:17 UTC

Answers

There is a general solution which can also apply to ros2 nodes. Do this by using killall on Linux:

  • Install psmisc:

    sudo apt install psmisc
    
  • Create an alias for killing all processes to facilitate ease. Attached is just a sample of what you can include for repeated killing.

    alias killros2='killall -9 \
      ros2 \
      _ros2_daemon \
      rviz2 \
      gzserver \
      robot_state_publisher \
      gzclient controller_server \
      lifecycle_manager'
    
  • Add the above snippet to your ~./bashrc file.
    In a separate terminal, run:

    killros2
    

This should kill all ros2-related processes and provide you with a log on the screen showing which processes have been found and killed.

Asked by Gaurav Gupta on 2023-05-16 05:16:12 UTC

Comments

Thank you for the answer. This is what I do manually when it happens but it really is not very practical, especially when several nodes are running. The alias is a good idea. However I was looking for a way to prevent it in the first place. Any ideas ?

Asked by Sam_Prt on 2023-05-17 03:41:34 UTC

Consider doing ros2 daemon stop and then ros2 daemon start in that case. I do not have a prevention unfortunately.

Asked by Gaurav Gupta on 2023-05-17 05:14:57 UTC