By default stating a dependency in manifest.xml adds the following path to your module:
<module_you_depend_on>/src/<module_you_depend_on>
You can check this by doing:
import roslib
roslib.load_manifest("your_package")
import sys
print sys.path
This convention is used when creating custom messages, as their implementation will go into a folder named after the package.
Therefore, in your package useful_python_functions, create a folder named again "useful_python_functions" in the src folder. You need an init.py file in the folder (even if it's empty) so that python knows that folder is a root module. Then the file utils.py will be available to any package that depends on useful_python_functions.
Hope it helps, and welcome to the wonderful python language!
Originally posted by Lorenzo Riano with karma: 1342 on 2011-11-03
This answer was ACCEPTED on the original site
Post score: 9
Original comments
Comment by Lorenzo Riano on 2011-11-03:
You're right, I forgot that! I am adding editing the answer. Thanks!
Comment by Sabrina on 2011-11-03:
Thank you, Lorenzo. This works with a small addition: I had to add an empty init.py to src/useful_python_functions. (Except when I run rosbuild_genmsg() in CMakeLists.txt. Then init.py is generated automatically.)
Comment by chao on 2014-01-21:
can this solution be used on groovy? cause i have tried it, but it showed "terminate called after throwing an instance of 'rospack::Exception'
what(): error parsing manifest of package state_boost at /home/chao/catkin_ws/src/state_boost/package.xml"
Comment by Sentinal_Bias on 2014-04-01:
I can get this working on catkin/groovy either. I added a run depend in the package.xml and did a catkin_make and it still can find the module. edit For groovy I think you need to use a setup.py file...