How can I control roscore from a Python script?
I would like to start, stop, etc. the roscore from within a Python script.
I do already know how to spawn a child process and start roscore like suggested here. However I would like to avoid using subprocesses.
It seems like the class Master (in ros_comm) provides the required functionality. It can be used like in this function which starts a ROS master (in ros_comm), somehow like follows.
import rosmaster.master
from rosmaster.master_api import NUM_WORKERS
DEFAULT_PORT = 11311
master = rosmaster.master.Master(DEFAULT_PORT, NUM_WORKERS)
master.start()
master.stop()
However in this function there is stated something like Standalone zenmaster has been deprecated, please use 'roscore' instead
.
Q: Can I use the Master class to start/stop the roscore? Or could I use some other functionality in addition or instead?
The roscore
script calls roslaunch.main
. But it is not clear to me where the rosmaster
and the other required components are configured and started.
Asked by thinwybk on 2017-09-14 04:08:27 UTC
Comments
Although #q289514 is newer, there's active discussion, so closing this as duplicate.
Asked by 130s on 2018-04-24 05:23:45 UTC