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

Depend on package built in workspace

asked 2021-07-06 21:50:02 -0500

bscout2011 gravatar image

updated 2021-07-07 12:09:46 -0500

I have a driver package_a and I want modify its dependency package_b for use in my project. I downloaded the package_b source into my catkin workspace, made the modifications, and successfully built the dependency. However package_a is unable to reference the new changes. I think is is because CMake found a different version of package_b somewhere else which does not have my modifications. How should I modify my CMakeLists.txt to use the locally build package_b in the catkin ws? I run rospack find package_b and the path is catkin_ws/src/package_b.

/catkin_ws
 - /src
   - /package_a
     - CMakeLists.txt
     - package.xml
   - /package_b       
     - CMakeLists.txt
     - package.xml

The dependencies listed in package_a/CMakeLists.txt is

find_package(package_b REQUIRED)

find_package(catkin REQUIRED COMPONENTS ...)

catkin_package(
    INCLUDE_DIRS include
    CATKIN_DEPENDS
        ...
    DEPENDS package_b
    )

include_directories(
  include
  ${package_b_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
   )

target_link_libraries(${PROJECT_NAME}
  ${package_b_LIBRARIES}
  ${catkin_LIBRARIES}
)

For reference, the package_b is libcreate and package_a is create_robot.

edit retag flag offensive close merge delete

Comments

CMakeLists reads ok. Also 'rospack find package_b' command is also outputing correct path. Are you installing the resultant library?

prince gravatar image prince  ( 2021-07-07 00:40:47 -0500 )edit

Is package_b a ROS package? If yes, you should probably have it in the find_package(catkin...) command as a component, as well as in CATKIN_DEPENDS instead of DEPENDS. Also, how exactly do you add package_b to the include_Directories and target_link_libraries calls? Please edit your question with the relevant lines of your CMakeLIsts.txt.

mgruhler gravatar image mgruhler  ( 2021-07-07 07:25:36 -0500 )edit

After running catkin_make at least once, have you sourced the setup.bash in catkin_ws/devel ?

source ~/catkin_ws/devel/setup.bash

You have to do this for catkin_make to "see" the packages in your home directory.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-07 07:46:07 -0500 )edit

@prince I am not sure if I am creating an install for package_b.

@mgruhlerpackage_b is a ROS package and I have the package_b.so library in my /opt/ros/melodic/lib folder. I added the inlcude_directories and target_link_libraries to the posted question.

@Mike Scheutzow The build itself is failing, so sourcing the workspace would not solve the issue.

bscout2011 gravatar image bscout2011  ( 2021-07-07 12:02:13 -0500 )edit
1

@bscout2011 I'm assuming you followed the build instructions in libcreates Readme and used catkin_tools to build it? With a plain catkin_make the lib shouldn't compile. This is because libcreate is actually not a ROS package, but a plain CMake project (even though the package.xml exists), but the CMakeLIsts.txt does not find_package(catkin ...).

If you used catkin_tools, you actually need to source the workspace once again for the package path to be picked up. This is because catkin_tools by default builds the packages in isolation (same holds for catkin_make_isolated).

mgruhler gravatar image mgruhler  ( 2021-07-08 03:03:51 -0500 )edit

@mgruhler you should post your comment as the answer.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-08 06:11:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-08 13:42:12 -0500

bscout gravatar image

The build instructions in libcreate's Readme define how catkin_tools builds the lib. With a plain catkin_make the lib shouldn't compile. This is because libcreate is actually not a ROS package, but a plain CMake project (even though the package.xml exists), but the CMakeLIsts.txt does not find_package(catkin ...).

If you used catkin_tools, you actually need to source the workspace once again for the package path to be picked up. This is because catkin_tools by default builds the packages in isolation (same holds for catkin_make_isolated).

edit flag offensive delete link more

Comments

So did this solve your problem?

mgruhler gravatar image mgruhler  ( 2021-07-12 00:38:10 -0500 )edit

My solution just made the libcreate package a catkin package by editing CMakeLists.txt adding find_package(catkin REQUIRED) and catkin_package(). In general, I think your solution is better because it makes libcreate a system wide package, whereas my solution adds more dependencies to libcreate which may break other systems which do not use catkin.

bscout2011 gravatar image bscout2011  ( 2021-07-12 10:40:02 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-07-06 21:50:02 -0500

Seen: 415 times

Last updated: Jul 07 '21