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

Revision history [back]

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.