ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Calling bash scripts work with Python, not with launch file

asked 2020-11-27 11:00:39 -0500

cstainer gravatar image

Hi all.

I'm writing a robot controller in Python 2 using an online platform called The Construct Sim, which uses Gazebo for simulation. My robot controller uses a call to a bash script to generate the model in Gazebo. When I run the robot controller with python, it works as expected. When I run the robot controller with the launch file roslaunch demo_2 run_all.launch, it causes an error which reads: sh: ./ No such file or directory (There is a second bash script that generates the same error: sh: ./ No such file or directory). The launch file, python file, and bash scripts are all in one package. The launch file in in demo_2/launch, the bash and python files are in demo_2/src.

The online platform I'm using uses Ubuntu 16.04 LTS, Python 2.7.12, ROS kinetic.

Launch file:

Python file:

Thanks for any and all help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-11-30 13:55:07 -0500

tryan gravatar image

The code in your repository does not reflect your question as stated. Your (now named, I guess) does not call the bash script but implements it directly, which is probably better than an external script anyway since it's only one line.

In case you want to take the external script approach elsewhere for some reason, you may have run into problems with the code being run from a different working directory as you appear to have used a relative path (./ You can determine whether that's the problem by trying it with an absolute path (e.g., /full/path/to/demo_2/src/ If that works, you can decide whether it makes more sense to just use an absolute path, or to check the working directory and use the appropriate relative path. Since you're using Python, the rospkg API may help with the latter option.

edit flag offensive delete link more

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: 2020-11-27 11:00:39 -0500

Seen: 163 times

Last updated: Nov 30 '20