0
$\begingroup$

Rosanswers logo

(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


Originally posted by ASMIK2011ROS on ROS Answers with karma: 62 on 2011-05-22

Post score: 1


Original comments

Comment by Asomerville on 2012-08-06:
I accidentally pushed this to the top by correcting the formatting. :P

Comment by domikilo on 2013-12-18:
you must use system("/opt/ros/diamondback/bin/roscore");

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Maybe it is a problem with missing environment variables (python path?). You could try to run bash with the command as parameter, e.g. something like bash -i -c "/opt/ros/diamondback/ros/bin/roscore". -i makes the bash read ~/.bashrc where I assume you source /opt/ros/diamondback/setup.sh.


Originally posted by Felix Endres with karma: 6468 on 2011-05-22

This answer was ACCEPTED on the original site

Post score: 4

$\endgroup$
0
$\begingroup$

Rosanswers logo

Why do you want to launch this from inside a program? If you include your program in a launch file the roscore will also be launched.


Originally posted by KoenBuys with karma: 2314 on 2011-07-03

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.