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

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

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

Cipek gravatar image

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

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

In the bash script I have:

rosrun my_package

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

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

davrsky gravatar image

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

edit flag offensive delete link more


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

Cipek gravatar image Cipek  ( 2019-06-20 14:15:07 -0600 )edit

Question Tools

1 follower


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

Seen: 336 times

Last updated: Jun 20 '19