Error when running python script with ProcessBuilder()- rospkg.common.ResourceNotFound: rosgraph

asked 2019-06-14 05:58:06 -0500

Cipek gravatar image

updated 2019-06-14 05:59:13 -0500

I want to run a python script with ProcessBuilder(). This is my code:

new ProcessBuilder().inheritIO().command("/usr/bin/python", System.getProperty("user.dir")+"/WebRoot/result.py").start();

And this is code in result.py file:

    #! /usr/bin/env python
    import sys
    sys.path.append('/opt/ros/indigo/lib/python2.7/dist-packages')
    import rospy

    rospy.init_node('test_node')

It works fine when I run it manually via the console, but the problem appears when the above ProcessBuilder tries to do it. I get such an error then:

Traceback (most recent call last):
  File "/home/osboxes/Documents/MyFirstXText/org.xtext.example.helloweb.web/WebRoot/result.py", line 20, in <module>
    rospy.init_node('test_node')
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/client.py", line 306, in init_node
    rospy.core.configure_logging(resolved_node_name)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/core.py", line 300, in configure_logging
    _log_filename = rosgraph.roslogging.configure_logging('rospy', level, filename=filename)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rosgraph/roslogging.py", line 107, in configure_logging
    rosgraph_d = rospkg.RosPack().get_path('rosgraph')
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 203, in get_path
    raise ResourceNotFound(name, ros_paths=self._ros_paths)
rospkg.common.ResourceNotFound: rosgraph
edit retag flag offensive close merge delete