Ask Your Question

Revision history [back]

I think this tutorial covers what you would like to do:

  • http://www.ros.org/wiki/rospy_tutorials/Tutorials/Makefile#Installing_scripts_and_exporting_modules

__summary:__

__1.__ Create setup.py in your package root directory with these contents

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
setup_args = generate_distutils_setup(
    packages=['tutorial_package'],
    package_dir={'': 'src'},
    requires=['std_msgs', 'rospy'])
)

setup(**setup_args)

__2.__ Add the following line to your CMakeLists.txt

catkin_python_setup()

__3.__ Create a directory for your python scripts (if you have any python executables)

mkdir <pkg_root>/scripts

__4.__ Create a directory for your python modules (__NOTE__: - <python_mod> should typically be the same as <pkg_root>)

mkdir <pkg_root>/src/<python_mod>/

__5.__ Add an empty __init__.py to your python module directory

touch <pkg_root>/src/<python_mod>/__init__.py

__6.__ create your python mod

touch <pkg_root>/src/<python_mod>/mod1.py

__You should now be able to import this module as__

import python_mod.mod1


Hope that helps! Reference the tutorial for details.

I think this tutorial covers what you would like to do:

  • http://www.ros.org/wiki/rospy_tutorials/Tutorials/Makefile#Installing_scripts_and_exporting_modules

__summary:__

__1.__ summary:

1. Create setup.py in your package root directory with these contents

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
setup_args = generate_distutils_setup(
    packages=['tutorial_package'],
    package_dir={'': 'src'},
    requires=['std_msgs', 'rospy'])
)

setup(**setup_args)

__2.__ 2. Add the following line to your CMakeLists.txt

catkin_python_setup()

__3.__ 3. Create a directory for your python scripts (if you have any python executables)

mkdir <pkg_root>/scripts

__4.__ 4. Create a directory for your python modules (__NOTE__: (NOTE: - <python_mod> should typically be the same as <pkg_root>)

mkdir <pkg_root>/src/<python_mod>/

__5.__ 5. Add an empty __init__.py to your python module directory

touch <pkg_root>/src/<python_mod>/__init__.py

__6.__ 6. create your python mod

touch <pkg_root>/src/<python_mod>/mod1.py

__You You should now be able to import this module as__as

import python_mod.mod1


Hope that helps!

Reference the tutorial for details.

I think this tutorial covers what you would like to do:

  • http://www.ros.org/wiki/rospy_tutorials/Tutorials/Makefile#Installing_scripts_and_exporting_modules

summary:

1. Create setup.py in your package root directory with these contents

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
setup_args = generate_distutils_setup(
    packages=['tutorial_package'],
    package_dir={'': 'src'},
    requires=['std_msgs', 'rospy'])
)

setup(**setup_args)

2. Add the following line to your CMakeLists.txt

catkin_python_setup()

3. Create a directory for your python scripts (if you have any python executables)

mkdir <pkg_root>/scripts

4. Create a directory for your python modules (NOTE: - <python_mod> should typically be the same as <pkg_root>)

mkdir <pkg_root>/src/<python_mod>/

5. Add an empty __init__.py to your python module directory

touch <pkg_root>/src/<python_mod>/__init__.py

6. create your python mod

touch <pkg_root>/src/<python_mod>/mod1.py

You should now be able to import this module as

import python_mod.mod1


Hope that helps!

Reference the tutorial tutorial for details.

I think this tutorial covers what you would like to do:

  • http://www.ros.org/wiki/rospy_tutorials/Tutorials/Makefile#Installing_scripts_and_exporting_modules

summary:

1. Create setup.py in your package root directory with these contentscontents (where <python_mod> is replaced by the name of your python module, typically the same name as your catkin package)

## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
setup_args = generate_distutils_setup(
    packages=['tutorial_package'],
packages=['<python_mod>'],
    package_dir={'': 'src'},
    requires=['std_msgs', 'rospy'])
)

setup(**setup_args)

2. Add the following line to your CMakeLists.txt

catkin_python_setup()

3. Create a directory for your python scripts (if you have any python executables)

mkdir <pkg_root>/scripts

4. Create a directory for your python modules (NOTE: - <python_mod> should typically be the same as <pkg_root>)modules

mkdir <pkg_root>/src/<python_mod>/

5. Add an empty __init__.py to your python module directory

touch <pkg_root>/src/<python_mod>/__init__.py

6. create your python mod

touch <pkg_root>/src/<python_mod>/mod1.py

You should now be able to import this module as

import python_mod.mod1


Hope that helps!

Reference the tutorial for details.