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

stop respawning node

asked 2021-02-23 03:06:53 -0500

felixN gravatar image


I'm using a launchfile (launched automatically during the boot process through rc.local), with several nodes set as respawn=true (which is the behaviour I want : if the node crashes, I want it to restart).

However, for debugging purposes, I sometimes want either to stop a node (for exemple if I want to send manually the commands it usually sends), or to run it in a terminal so I can see al its output in real time (including some cout prints I don't put in the logs).

Is there a way to do one (or both) of the above things without having first to kill all nodes, then modify the launchfile and launch everything again?

Ideally I would like something like "rosnode kill --no_respawn /my_node", or a command to disable the respawning of a given node so I can then kill it afterwards.

A command to redirect the output of a node to a terminal would also be interresting (for now, the output of all nodes is logged into a single file).

Thanks a lot in advance


PS : it's fine for me to modify the launchfile, as long as the node keep respawning when they crash

edit retag flag offensive close merge delete


Related: #q306382.

I'm not aware of any changes to that part of roslaunch, so I'm inclined to still say "no, this is not supported", but it would perhaps be best to check ros/ros_comm on Github and see for yourself.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-23 03:22:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-02-25 16:49:37 -0500

ejalaa12 gravatar image

Killing a node that is set to respawn=true is not possible as explained here

However, reading the output of the node from another terminal or even GUI is totally feasible!

  1. Use ros logging system ROS_[DEBUG/INFO/WARN/ERROR]_STREAM... for C++ instead of cout (rospy.log[debug/info...] instead of print for python).
  2. Remove the output=screen from your launch, this will avoid having the log printed out in the same terminal from which you launch all your nodes
  3. Set the logging level of your node to the level needed, from within the code, via rqt_logger_level, or even with a configuration file
  4. You can now read the logs with any of those solutions:
  5. via another terminal with rosconsole echo /node/name
  6. rqt_console , you'll need to filter out the node you're looking for
  7. swri_console which is a replacement for rqt_console, that is my prefered solution

Also note that you can use different logger names for different part of your code, and filter the logs you need by setting different log level for each logger via rosconsole, rqt_logger_level, or swri_console. If you need more debugging tools, you can event change the LOG_FORMAT to include the node name, function name, or even the ligne of code from which the log comes from.

Hope it helps !

edit flag offensive delete link more


Thanks! it's already quite usefull!

Just one more question : if I modify the code (and recompile), then I kill a respawning node, will it respawn with the new code or with the old one?

felixN gravatar image felixN  ( 2021-03-01 02:35:39 -0500 )edit

It will respawn with the new code in both Python and C++ :)

ejalaa12 gravatar image ejalaa12  ( 2021-03-01 14:58:24 -0500 )edit

Question Tools

1 follower


Asked: 2021-02-23 03:06:53 -0500

Seen: 896 times

Last updated: Feb 25 '21