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

Automated node running

asked 2011-04-03 17:38:31 -0500

Homer Manalo gravatar image

updated 2011-04-03 18:01:11 -0500

Eric Perko gravatar image

Is there a way to automatically run a node using/inside a C++/Python program? Say some event happened and I want to run this node, then another event happened and I want to close the node. Or perhaps a launch file?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-04-03 22:37:13 -0500

Miguel Prada gravatar image

This similar question I asked a while back might help you out.

edit flag offensive delete link more

answered 2011-04-03 20:37:33 -0500

updated 2011-04-03 20:38:10 -0500

A ROS node is just an executable, so you can run (and kill) it as you run any other executable from your program (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.

edit flag offensive delete link more

Question Tools


Asked: 2011-04-03 17:38:31 -0500

Seen: 965 times

Last updated: Apr 03 '11