0
$\begingroup$

Rosanswers logo

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.


Originally posted by gpldecha on ROS Answers with karma: 285 on 2017-03-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to specify where your python module is in the setup.py. Using the moveit_commander example: https://github.com/ros-planning/moveit/blob/kinetic-devel/moveit_commander/setup.py#L5-L6

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/intera_sdk/tree/master/intera_interface

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

Originally posted by imcmahon with karma: 790 on 2017-03-09

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.