ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
A ROS node is just an executable, so you can run (and kill) it as you run any other executable from your program (in C++ man system
or man popen
). The main problem might be, that ros stuff that is setup in your bashrc (e.g. the environment variables ROS_PACKAGE_PATH and ROS_MASTER_URI) are not available. In that case you might be successful running a bash to interpret your command. You may need to run it as interactive shell "-i" to make sure it executes .bashrc. So altogether something like system("bash -i -c roslaunch somepackage somefile.launch") should work. To kill a node you could use rosnode kill [node]
started in the above way.
2 | No.2 Revision |
A ROS node is just an executable, so you can run (and kill) it as you run any other executable from your program (in (for C++ see man system
or man popen
). The main problem might be, that ros stuff that is setup in your bashrc (e.g. the environment variables ROS_PACKAGE_PATH and ROS_MASTER_URI) are not available. In that case you might be successful running a bash to interpret your command. You may need to run it as interactive shell "-i" to make sure it executes .bashrc. So altogether something like system("bash -i -c roslaunch somepackage somefile.launch") should work. To kill a node you could use rosnode kill [node]
started in the above way.