stop respawning node
Hi,
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 --norespawn /mynode", 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
Felix
PS : it's fine for me to modify the launchfile, as long as the node keep respawning when they crash
Asked by felixN on 2021-02-23 04:06:53 UTC
Answers
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!
- Use ros logging system
ROS_[DEBUG/INFO/WARN/ERROR]_STREAM...
for C++ instead of cout (rospy.log[debug/info...]
instead ofprint
for python). - 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 - 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
- You can now read the logs with any of those solutions:
- via another terminal with
rosconsole echo /node/name
- rqt_console , you'll need to filter out the node you're looking for
- 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 !
Asked by ejalaa12 on 2021-02-25 17:49:37 UTC
Comments
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?
Asked by felixN on 2021-03-01 03:35:39 UTC
It will respawn with the new code in both Python and C++ :)
Asked by ejalaa12 on 2021-03-01 15:58:24 UTC
Comments
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 checkros/ros_comm
on Github and see for yourself.Asked by gvdhoorn on 2021-02-23 04:22:10 UTC