Ask Your Question
0

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
3

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

Miguel Prada gravatar image

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

http://answers.ros.org/question/501/spawn-and-kill-nodes-from-nodessmach

edit flag offensive delete link more
4

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 670 times

Last updated: Apr 03 '11