ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:
Maybe there is an idea to allow scriptapi to run launch files, but it isn't currently implemented: https://github.com/ros/ros_comm/blob/indigo-devel/tools/roslaunch/src/roslaunch/scriptapi.py#L74
This question is similar to http://answers.ros.org/question/223090/start-or-stop-the-ros-node-in-another-node/ and http://answers.ros.org/question/203154/is-it-possible-to-run-and-quit-launch-files-from-code-inside-a-node/
2 | No.2 Revision |
Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:
import roslaunch; args=['roslaunch','pkg_name', 'foo.launch']; roslaunch.main(args)
(This method blocks so doesn't have a nice start/stop/is_alive interface like scriptapi)Maybe there is an idea to allow scriptapi to run launch files, but it isn't currently implemented: https://github.com/ros/ros_comm/blob/indigo-devel/tools/roslaunch/src/roslaunch/scriptapi.py#L74
This question is similar to http://answers.ros.org/question/223090/start-or-stop-the-ros-node-in-another-node/ and http://answers.ros.org/question/203154/is-it-possible-to-run-and-quit-launch-files-from-code-inside-a-node/
3 | No.3 Revision |
Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:solution.
import roslaunch; args=['roslaunch','pkg_name', 'foo.launch']; roslaunch.main(args)
sys.agv=['roslaunch','pkg_name', 'foo.launch']
import roslaunch
roslaunch.main(args)
Maybe there is an idea to allow scriptapi to run launch files, but it isn't currently implemented: https://github.com/ros/ros_comm/blob/indigo-devel/tools/roslaunch/src/roslaunch/scriptapi.py#L74
This question is similar to http://answers.ros.org/question/223090/start-or-stop-the-ros-node-in-another-node/ and http://answers.ros.org/question/203154/is-it-possible-to-run-and-quit-launch-files-from-code-inside-a-node/
4 | No.4 Revision |
Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution.
Create a node that uses roslaunch directly to start a param defined launch file, with a hack to get around the way roslaunch uses sys.argv. The main method blocks so doesn't have a nice start/stop/is_alive interface like scriptapi.
sys.agv=['roslaunch','pkg_name', 'foo.launch']
sys.agv=['roslaunch', 'pkg_name', 'foo.launch', 'arg:=bar']
import roslaunch
roslaunch.main(args)
Start the second roslaunch raw node within the first scriptapi node, and then if the stop method is used it uses the scriptapi stop method which interrupts the roslaunch, kills all the child nodes as desired.
Maybe there is an idea to allow scriptapi to run launch files, but it isn't currently implemented: https://github.com/ros/ros_comm/blob/indigo-devel/tools/roslaunch/src/roslaunch/scriptapi.py#L74
This question is similar to http://answers.ros.org/question/223090/start-or-stop-the-ros-node-in-another-node/ and http://answers.ros.org/question/203154/is-it-possible-to-run-and-quit-launch-files-from-code-inside-a-node/