terminate & launch other node from code
Is there a ROS way to terminate and launch another node from one node's code?
For launching example in python, it's possible by doing something like this w/o using ROS:
import os
os.system('roslaunch turtlebot_navigation_ours amcl_customized.launch')
Any way to do the same in an official way in ROS?
How about terminating as well? If a node run as "respawn = true" receives "shutdown" msg/service request then shuts down itself? Better idea?
Update) I thought I'd better describe a situation when I need this...There is a node that gets to consume higher CPU in a process of time (eventually CPU load reaches 12.0 or above although it's not supposed to do so). And I found that restarting makes it stay calmer and still functions. Besides debugging that node itself, it would be nicer if I can just work around the issue for now by restarting the node.
Update-2) Found similar QA thread and roslaunch.scriptapi
might be good as well for launching from python
(I'm sure the argument for ROSLaunch.launch
is roslaunch.core.Node
instead of roslaunch.Node
as in API doc).