Calling roscore from subprocess
I have a GUI written in python 2.7 using PyQt4 that launches various husky_navigation demos via python's subprocess command. Here is an example:
cmd = "%s; %s;" % (self.exportMaster, self.exportHostName)
self.huskyNavRoscore = subprocess.Popen(cmd + ROS_BIN + "roscore", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
time.sleep(2)
# launches gazebo
self.huskyNavGazebo = subprocess.Popen(cmd + "roslaunch husky_gazebo husky_playpen.launch", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
time.sleep(2)
#launches Rviz
self.huskyNavRviz = subprocess.Popen(cmd + "roslaunch husky_viz view_robot.launch", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
time.sleep(2)
# enables navigation
self.huskyNavMoveBase = subprocess.Popen(cmd + "roslaunch husky_navigation move_base_mapless_demo.launch", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
When executing these lines in my deployed executable, the console gets flooded with errors saying:
/opt/ros/indigo/lib/rosout/rosout: error while loading shared libraries: libroscpp.so: cannot open shared object file: No such file or directory
failed to start local process: /opt/ros/indigo/lib/rosout/rosout __name:=rosout __log:=/home/hatfield/.ros/log/f2ee00dc-5914-11e6-a8c3-4c3488a90e5c/rosout-1.log
failed to start local process: /opt/ros/indigo/lib/rosout/rosout __name:=rosout __log:=/home/hatfield/.ros/log/f2ee00dc-5914-11e6-a8c3-4c3488a90e5c/rosout-1.log
[rosout-1] process has died [pid 14653, exit code 127, cmd /opt/ros/indigo/lib/rosout/rosout __name:=rosout __log:=/home/hatfield/.ros/log/f2ee00dc-5914-11e6-a8c3-4c3488a90e5c/rosout-1.log].
log file: /home/hatfield/.ros/log/f2ee00dc-5914-11e6-a8c3-4c3488a90e5c/rosout-1*.log
However, when I run the raw GUI using "python GUI.py" these commands run and start the husky_navigation demo just fine. I believe this may be a problem with launching roscore within an executable file. Am I totally off?