Ask Your Question
0

Scripts don't see ROS if executed by ProcessBuilder()

asked 2019-06-14 09:56:48 -0500

Cipek gravatar image

I want to execute a script with a ProcessBuilder(). My code is:

new ProcessBuilder().inheritIO().command("/bin/bash", "-c", "./deploy.sh").start();

In the bash script I have:

#!/bin/bash
rosrun my_package ardrone_test_1.py

It works if I run the bash script manually in the terminal, but if I do with the ProcessBuilder I got an error:

rosrun: command not found

The same if I run python scripts which uses ROS. There are errors that some package are not found, whereas it works fine if run via terminal.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-20 11:10:49 -0500

davrsky gravatar image

You need to source setup.bash first in order for the environment to work. In your deploy.sh add a line like "source /your/ros_ws/devel/setup.bash" before you call rosrun

edit flag offensive delete link more

Comments

I have been looking for the solution really long and that worked! Thank you.

Cipek gravatar imageCipek ( 2019-06-20 14:15:07 -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

Stats

Asked: 2019-06-14 09:56:48 -0500

Seen: 136 times

Last updated: Jun 20