0
$\begingroup$

Rosanswers logo

I am working on a Ubuntu 14.04 system with ROS Indigo. I currently have a python script in the /home/usr path that is launched by a desktop file using auto-start. I use roslaunch inside the python script to bring up other ROS nodes/packages elsewhere in the system using import roslaunch and rospy. I have sourced the ROS package (/opt/ros/indigo/setup.bash) in bashrc as well as the other packages I am running through the script. The problem is that when I reboot the system, my python script executes but comes up with the error message "no module named rospy" (or roslaunch). I tried starting a roscore using the subprocess.Popen('roscore') in the python script as well but the error was "No such file". I want to run some operations in the python program before the "roslaunch" operation and all this needs to execute at system boot each time. Any help is appreciated, thanks in advance!

  • Sneha

Originally posted by i_robot_flight on ROS Answers with karma: 36 on 2017-10-03

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You should probably add your autostart desktop file. The issue is likely that the Python script isn't being run from a bash environment that has sourced your .bashrc. Possible fixes: source the relevant workspace setup.bash files earlier in the boot process so that future processes inherit the env. This is done in the robot_upstart package. Easier might be to add an executable bash script (with #!/bin/bash as first line), that first sources the .bashrc, and then executes the Python script, and then put this in your autostart desktop file.

Could also probably get away with a one-liner to execute the Python script... something like bash -i -c "/home/user/Desktop/run_process.py"


Originally posted by jarvisschultz with karma: 9031 on 2017-10-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by i_robot_flight on 2017-10-03:
@jarvisschultz you were completely right. At boot the bash environment had not started the bashrc before this desktop file executed. I modified my script to switch the order. Thank you very much!

Comment by gvdhoorn on 2017-10-04:
@i_robot_flight: as @jarvisschultz answered your question, please accept his answer by ticking the checkmark to the left of his answer.

$\endgroup$

Your Answer

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