在程序中启动node:
运用python的subprocess
import subprocess
...
cmd = ["rosrun", "xx_package", "xx_node", "param:=value"]
node = subprocess.Popen(cmd)
杀死node:
调用subprocess的函数
node.terminate()
node.wait()
另外一种方式:
调用ROS提供的API
cmd = ["rosnode", "kill", "xx_node"]
terminate_node = subprocess.Popen(cmd)
terminate_node.wait()