0

Is there a way to import Webots controller library in a simple python script running a ROS node inside a ROS workspace?

I have seen the Webots ROS_Python exmaple and understand the concept behind. But I am unable to import

from controller import Robot

and get the error

ImportError: No module named rospy

while running the ROS_Python example package provided already.

Edit: Changing python variable /usr/local/webots/lib/python35 finds the controller but now, a new error occurs:

ImportError: libCppController.so: cannot open shared object file: No such file or directory
Tahir Mahmood
  • 305
  • 1
  • 11

1 Answers1

3

Your approach of calling the libcontroller from within the ROS workspace is very good. This is actually the approach used for the Webots-ROS2 integration.

They are a few environmental variables that you need to set before starting your node. They are mainly LD_LIBRARY_PATH and PYTHONPATH, you can find a complete description of how to start a controller outside of Webots here:

https://www.cyberbotics.com/doc/guide/running-extern-robot-controllers#environment-variables

For the reference, this is implemented in the webots_ros2 package for ROS2:

David Mansolino
  • 1,713
  • 7
  • 13