ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I've uploaded this video Tutorial to show you an example of how to import to import python modules from other packages, or from any python realted scripts. Also how to install them. Hope it helps ;). Python import Module Tutorial
2 | No.2 Revision |
I've uploaded this video Tutorial to show you an example of how to import to import python modules from other packages, or from any python realted scripts. Also how to install them. Hope it helps ;). Python import Module Tutorial
UPDATE: following @gvdhoorn observation, here I leave the essential code to follow the video. Essentialy to import a python module from one package inside any other or even python stand alone programs you have to do the following: 1) Create a folder inside the src folder of your package, named as your package. Lets say your package is called "common_tools_pkg". Well you should have somthing like this: common_tools_pkg:
--->src:
--->--->common_tools_pkg:
--->--->-->__init__.py
--->--->--->mycommonmodule.py
2) Then Uncoment in the CMakelists.txt the line: catkin_python_setup()
3) Create inside the package a python file called "setup.py" with the contents:
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
setup_args = generate_distutils_setup(
packages=['common_tools_pkg'],
package_dir={'': 'src'},
)
setup(**setup_args)
4) Then catkinmake and source deve/setup.bash, and you will now be able to import that puython module anywhere.