Ask Your Question
0

catkin make and running hrl_tilting_hokuyo

asked 2013-10-22 08:22:59 -0600

pwong gravatar image

updated 2014-01-28 17:18:19 -0600

ngrennan gravatar image

I'm running hydro and switching over from new rosbuild to using catkin. I read through the catkin conceptual overview and tutorials but have trouble implementing.

I'm trying to get the tilting hokuyo set up. I 'catkinized' the hrl_hardware_drivers but having trouble with the hrl_lib. It wasn't included in the package so I found it externally. When I run:

rosrun hrl_hokuyo hokuyo_processing.py

It goes me the error:

src/hrl_hokuyo/hokuyo_processing.py", line 43, in <module> import hrl_lib.transforms as tr ImportError: No module named hrl_lib.transforms

I believe the cmakelist and package.xml file was edit appropriately to include hrl_lib. I want to do it right and not just add the hrl_lib folder into the directory.

Thanks!

Heres is the cmake

cmake_minimum_required(VERSION 2.8.3)
project(hrl_hokuyo)

find_package(catkin REQUIRED COMPONENTS hokuyo_node sensor_msgs rospy hrl_lib)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

catkin_package(
    DEPENDS hokuyo_node sensor_msgs rospy hrl_lib
    CATKIN_DEPENDS # TODO
    INCLUDE_DIRS # TODO
    LIBRARIES # TODO
)

Here is the package.xml

<package>
  <name>hrl_hokuyo</name>
  <version>1.0.0</version>
  <description>Python class that uses hokuyo_node from ros-pkg to get scans from
  UTMs and player to get scans from URGs.</description>
  <maintainer email=""></maintainer>

  <license>New BSD</license>

  <url type="website"></url>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>hokuyo_node</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>hrl_lib</build_depend>

  <run_depend>hokuyo_node</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>hrl_lib</run_depend>

</package>

Edit #1

I'm still having trouble with it. Is the hrl_lib package just a folder with the python files in it? This doesn't feel right since there are other folders with the library as well. Here is my structure:

/path_to_workspace/
    /src
        /hrl_hokuyo
            /setup.py
            /src
                /hrl_hokuyo
                /hrl_lib

Thanks for the quick response and breaking it down for me.

Edit#2

I didn't edit it much except just setting the path.

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

d = generate_distutils_setup(
    packages=['hrl_lib'],
    package_dir={'/path_to_directory_containing_hrl_lib/': 'src'}
)

setup(**d)
edit retag flag offensive close merge delete

Comments

Thanks for the comment and telling me the preferred method to posting responses!

pwong gravatar imagepwong ( 2013-10-22 14:48:35 -0600 )edit

Can you post your setup.py? It is likely that you are not declaring your packages correctly.

William gravatar imageWilliam ( 2013-10-22 15:33:56 -0600 )edit

Another option is for you to push this to github (or something similar) and point me to it.

William gravatar imageWilliam ( 2013-10-22 15:36:03 -0600 )edit

I'll work on putting this onto github

pwong gravatar imagepwong ( 2013-10-22 16:05:45 -0600 )edit

I think you have the `package_dir` wrong, see my edit to my question and this: http://docs.python.org/2/distutils/setupscript.html#listing-whole-packages

William gravatar imageWilliam ( 2013-10-22 16:17:23 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-10-22 10:32:38 -0600

William gravatar image

updated 2013-10-22 15:35:13 -0600

In order to export python libraries you need to do two things:

  • Setup a setup.py file describing which Python packages your package has
  • Call the catkin_python_setup() macro in your CMakeLists.txt

Reference: http://docs.ros.org/api/catkin/html/user_guide/setup_dot_py.html

The setup.py should be in the root of your package and look like this:

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

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

setup(**d)

Where...

    packages=['mypkg'],

'mypkg' is the name of the python package you want, in your case probably 'hrl_lib', and...

    package_dir={'': 'src'}

'src' is the folder in your package where you keep these packages, so your folder structure would be:

/path/to/my/package
                   /setup.py
                   /src
                       /hrl_lib
                               /__init__.py
                               ...

And in your CMakeLists.txt you need to call before catkin_package(...):

catkin_python_setup()

Also, get rid of these lines:

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

This was someting that rosbuild had you do, but you shouldn't do this in catkin.

EDIT:

I would expect your setup.py to look like this:

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

d = generate_distutils_setup(
    packages=['hrl_hokuyo', 'hrl_lib'],
    package_dir={'': 'src'}
)

setup(**d)
edit flag offensive delete link more

Comments

Without the package path at package_dir it works. Thank you!

pwong gravatar imagepwong ( 2013-10-23 07:20:18 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-10-22 08:22:59 -0600

Seen: 194 times

Last updated: Oct 22 '13