# ros integration into another project fails with rosbuild_init

Hi there.

I am trying to integrate a few Rosnodes (packages) into another project that is not part of ros / does not contain further ros-nodes. In the project CMakeLists.txt (folder: /home/f/project/CMakeLists.txt) I simply included my ros CMakeLists files for the stacks.

The folder structure would be

/home/f/project/                # here is the main CMakeLists.txt
/home/f/project/myStack         # here is the stack.xml
/home/f/project/myStack/myNode  # here is the manifest.xml


The include looks like this:

ADD_SUBDIRECTORY(myStack/myNode)


When i now try to run

cmake /home/f/project/CMakeLists.txt


I get the following error:

CMake Error at /opt/ros/electric/ros/core/rosbuild/private.cmake:109 (message):
[rosbuild] rospack found package "project" at "", but
the current directory is
"/home/f/project/myStack/myNode".
You should double-check your ROS_PACKAGE_PATH to ensure that packages are
found in the correct precedence order.


in the mentioned private.cmake at line 106 (or so..) rosbuild tries to verify that the projectsource folder and the current source folder are the same -- this fails obviously. And i managed to find out, that the project name is set to 'project' and not 'myStack' which it should be, since rosbuild_init() is only called from the myStack/CMakeLists.txt

Does anyone know a solution to this problem? I tried to find an answer in this wiki already but that did not help me at all. Neither did the rosbuild documentation help me :/

EDIT: when set the following variables:

SET(ROSBUILD_DONT_REDEFINE_PROJECT 1)
SET(PROJECT_NAME "myNode")


Then the first thing just works find: e.g. finding the correct project and the rosbuild_init() routine passes the first few checks but breaks a few lines later when it tries to verify the manifest.xml - it seems to try to read the file '/manifest.xml' -- the complete path is missing... any ideas? has someone ever done this?! (im quite sure there must have been people who sucessfully integrated ros into other projects)

edit retag close merge delete

What is your \$ROS_PACKAGE_PATH? Does roscd myStack work?
( 2012-02-02 01:44:44 -0500 )edit
yep works fine. i end up in /path_to/myStack/
( 2012-02-02 01:59:13 -0500 )edit
The working directory for the python script, which tries to verify the manifest.xml is set to /home/f/project/... this looks like the reasen for the whole problem but i do not understand why it was set to that folder... because the main CMakeFile is located there?!
( 2012-02-02 02:03:14 -0500 )edit

Sort by » oldest newest most voted

The ROS CMake macros were never intended to be used like this. I don't think there is a clean way that doesn't require hacking the CMake macros for solving your case.

Instead of adding your stack using add_subdirectory, you could execute make in that directory using something like add_custom_command. If your ROS packages create messages or libraries, you'll then have to add the include paths and libraries by hand in your CMakeFile.txt. Note that you'll still be required to have ROS installed and your project or at least your stacks inside it need to be in the ROS_PACKAGE_PATH.

more

comment/delete the "rosbuild_init()" of the stack/package "CMakeLists.txt" files in the subdirectories

more