ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

catkin rospy package structure

asked 2017-03-09 11:31:03 -0500

gpldecha gravatar image

Hi have been writing a ros python package with the following structure (I checked my structure against moveit_commander).

 catkin_ws
    |_  src
         |_ python_package
                     |_ bin
                     |_src
                     |   |_ python_package
                     |_ CMakeLists.txt
                     |_ package.xml
                     |_setup.py

When package_python is in the folder src I am able to roscd and roslaunch this package.

However I would like to have package_name inside a root dummy folder python-package. When I do this I am no longer able to roscd, roslaunch, python_package.

 catkin_ws
    |_  src
         |_ python-package
                    |_ python_package

What should I do in order to have my python_package inside python-package and still be to call use it. For a C++ project this is not a problem.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-03-09 13:55:20 -0500

imcmahon gravatar image

You need to specify where your python module is in the setup.py . Using the moveit_commander example: https://github.com/ros-planning/movei...

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

d = generate_distutils_setup()
d['packages'] = ['moveit_commander']
d['package_dir'] = {'': 'src'}

setup(**d)

Because of this, the src directory is the where catkin will expect to find the python module.

Shameless plug, I can offer up a repo I maintain answer to your larger question about package structure a few folder layers deep, intera_interface : https://github.com/RethinkRobotics/in...

Generally speaking, the folder structure for a package containing both python modules and python scripts is as follows:

 catkin_ws
|_  src
     |_ python_package
                 |_ scripts
                 |    |_python_executable_script_1
                 |    |_python_executable_script_2
                 |_src
                 |   |_python_public_module
                 |   |_python_private_module_1
                 |   |_python_private_module_2
                 |_ CMakeLists.txt   # <-- invoke catkin_python_setup() in here
                 |_ package.xml
                 |_setup.py          # <--specify public module & directory in here
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-03-09 11:31:03 -0500

Seen: 2,503 times

Last updated: Mar 09 '17