ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ros2 node still running

asked 2023-05-12 08:59:38 -0500

Sam_Prt gravatar image

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?

edit retag flag offensive close merge delete

Comments

I have same problem :( You find any solution?

mustafakurban gravatar image mustafakurban  ( 2023-05-14 04:38:34 -0500 )edit

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.

ChuiV gravatar image ChuiV  ( 2023-05-16 08:09:18 -0500 )edit

Good point, I will try only calling it once.

Sam_Prt gravatar image Sam_Prt  ( 2023-05-17 03:42:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-16 05:16:12 -0500

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.

edit flag offensive delete link more

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 ?

Sam_Prt gravatar image Sam_Prt  ( 2023-05-17 03:41:34 -0500 )edit

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

Gaurav Gupta gravatar image Gaurav Gupta  ( 2023-05-17 05:14:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2023-05-12 08:59:38 -0500

Seen: 611 times

Last updated: May 16 '23