How to run ROS commands from C++ application?
(Original Author) want(s) to run ROS commands, like e.g. $ ROSCORE, from a C++ application. The following example does not work:
#include <stdlib.h>
int main()
{
system("/opt/ros/diamondback/ros/bin/roscore");
return 0;
}
Execution results in the following message:
Traceback (most recent call last):
File "/opt/ros/diamondback/ros/bin/roscore", line 34, in <module>
from ros import roslaunch
ImportError: No module named ros
Original Author was using Ubuntu 10.04.
Original Author notes that roscore successfully launches the master when executed from the command line
I accidentally pushed this to the top by correcting the formatting. :P
you must use system("/opt/ros/diamondback/bin/roscore");