ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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 robot_controller.py, 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: ./robot.sh: No such file or directory (There is a second bash script that generates the same error: sh: ./del_robot.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: https://github.com/cstainer/ECE-370/b...

Python file: https://github.com/cstainer/ECE-370/b...

robot.sh: https://github.com/cstainer/ECE-370/b...

del_robot.sh: https://github.com/cstainer/ECE-370/b...

Thanks for any and all help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

tryan gravatar image

The code in your repository does not reflect your question as stated. Your robot_controller.py (now named ddr_control.py, 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 (./robot.sh). You can determine whether that's the problem by trying it with an absolute path (e.g., /full/path/to/demo_2/src/robot.sh). 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

Question Tools

1 follower

Stats

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

Seen: 252 times

Last updated: Nov 30 '20