Ask Your Question

Calling roscore from subprocess

asked 2016-08-02 20:08:48 -0500

dicegame gravatar image

updated 2016-08-05 10:50:14 -0500

gvdhoorn gravatar image

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)

        # launches gazebo
        self.huskyNavGazebo = subprocess.Popen(cmd + "roslaunch husky_gazebo husky_playpen.launch", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)

        #launches Rviz
        self.huskyNavRviz = subprocess.Popen(cmd + "roslaunch husky_viz view_robot.launch", stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)

        # 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: 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" 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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-05 10:51:10 -0500

gvdhoorn gravatar image

Looks like an environment issue: do you start your deployed UI / program from a shell that has sourced the appropriate setup.* files?

edit flag offensive delete link more


AH! I feel so dumb. I was sourcing ROS's setup.bash in my ~/.bashrc and not in my subprocess calls. I'm no longer getting the error. Thanks!

dicegame gravatar image dicegame  ( 2016-08-05 12:58:42 -0500 )edit

Subprocess calls weren't sourcing ROS's setup.bash in my subprocess calls.

dicegame gravatar image dicegame  ( 2016-08-05 12:59:50 -0500 )edit

Hi, I'm running into a similar problem, but I don't understand the solution : how do I source ROS's setup.bash in the subprocess call? Could you just put up the modified code where the problem is solved? Thanks!

kinglm gravatar image kinglm  ( 2018-10-02 11:43:50 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2016-08-02 20:08:48 -0500

Seen: 1,150 times

Last updated: Aug 05 '16