ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:

  1. Create a node that uses scriptapi to start/stop a single node specified by params. (the scriptapi approach doesn't look like it can run launch files, just nodes- it is just a programmatic rosrun, not roslaunch?)
  2. Create a node that uses roslaunch directly to start a param defined launch file. (This method blocks so doesn't have a nice start/stop/is_alive interface like scriptapi)
  3. 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/

Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:

  1. Create a node that uses scriptapi to start/stop a single node specified by params. (the scriptapi approach doesn't look like it can run launch files, just nodes- it is just a programmatic rosrun, not roslaunch?)
  2. Create a node that uses roslaunch directly to start a param defined launch file. 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)
  3. 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/

Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution:solution.

  1. Create a node that uses scriptapi to start/stop a single node specified by params. (the scriptapi approach doesn't look like it can run launch files, just nodes- it is just a programmatic rosrun, not roslaunch?)
  2. Create a node that uses roslaunch directly to start a param defined launch file. import roslaunch; args=['roslaunch','pkg_name', 'foo.launch']; roslaunch.main(args)file, with a hack to get around the way roslaunch uses sys.argv. (This The main method blocks so doesn't have a nice start/stop/is_alive interface like scriptapi)scriptapi.

    sys.agv=['roslaunch','pkg_name', 'foo.launch']
    import roslaunch
    roslaunch.main(args)
    
  3. 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/

Unless the scriptapi actually can run launch files, here is my (somewhat confusing) solution.

  1. Create a node that uses scriptapi to start/stop a single node specified by params. (the scriptapi approach doesn't look like it can run launch files, just nodes- it is just a programmatic rosrun, not roslaunch?)
  2. 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)
    
  3. 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/