Ask Your Question
1

What is the cmake catkin variable for the workspace root dir?

asked 2013-10-29 04:57:24 -0500

ounsworth gravatar image

updated 2013-10-29 08:19:12 -0500

Catkin puts the headers from my custom messages from package1 in

~/ros_ws/devel/include/<package1>/

I want to use them when compiling package2. I am assuming that the CMakeLists.txt for package2 needs a line like

include_directories(
  ${<WORSPACE_ROOT>}/devel/include
  ${catkin_INCLUDE_DIRS}
)

but I don't know the correct variable is for the workspace root, ie ~/ros_ws.

The other question is: is there a better way of doing than than manually specifying the top-level include dir?

Here are the CMakeLists.txt files:

ardrone_autonomy (project1) :

cmake_minimum_required(VERSION 2.8.3)
project(ardrone_autonomy)

find_package( catkin REQUIRED COMPONENTS roscpp rospy std_msgs image_transport sensor_msgs std_srvs tf camera_info_manager message_generation  )

#uncomment if you have defined messages or services
add_message_files( FILES
    matrix33.msg
    navdata_adc_data_frame.msg
    navdata_altitude.msg
    navdata_demo.msg
    navdata_euler_angles.msg
    navdata_games.msg
    navdata_gyros_offsets.msg
    navdata_hdvideo_stream.msg
    navdata_kalman_pressure.msg
    navdata_magneto.msg
    Navdata.msg
    navdata_phys_measures.msg
    navdata_pressure_raw.msg
    navdata_pwm.msg
    navdata_raw_measures.msg
    navdata_rc_references.msg
    navdata_references.msg
    navdata_time.msg
    navdata_trackers_send.msg
    navdata_trims.msg
    navdata_video_stream.msg
    navdata_vision_detect.msg
    navdata_vision.msg
    navdata_vision_of.msg
    navdata_vision_perf.msg
    navdata_vision_raw.msg
    navdata_watchdog.msg
    navdata_wifi.msg
    navdata_wind_speed.msg
    navdata_zimmu_3000.msg
    vector21.msg
    vector31.msg
)

add_service_files(
  FILES
  CamSelect.srv
  FlightAnim.srv
  LedAnim.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
  sensor_msgs
)

catkin_package(
  INCLUDE_DIRS include devel/include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS roscpp std_msgs message_runtime
  DEPENDS libsdl-dev
#  DEPENDS system_lib
)

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)


find_package(Boost REQUIRED COMPONENTS) 
set(SDK ARDroneLib/)
link_directories(${PROJECT_SOURCE_DIR}/lib/)
include_directories(${SDK} ${SDK}/FFMPEG/Includes ${SDK}/Soft/Common ${SDK}/Soft/Lib ${SDK}/VP_SDK ${SDK}/VP_SDK/VP_Os/linux )
add_executable(ardrone_driver src/ardrone_driver.cpp src/video.cpp src/ardrone_sdk.cpp src/teleop_twist.cpp)
target_link_libraries(ardrone_driver ${catkin_LIBRARIES} pc_ardrone avcodec avutil swscale vlib  sdk SDL )

mrl_ardrone (project2) :

cmake_minimum_required(VERSION 2.8.3)
project(mrl_ardrone)

find_package(catkin REQUIRED COMPONENTS roscpp std_msgs cv_bridge ardrone_autonomy )

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES mrl_ardrone
  CATKIN_DEPENDS roscpp std_msgs cv_bridge ardrone_autonomy
#  DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  # This is super sketchy, there must be an automated way to do this
  /home/mike/ros_ws/devel/include/
  ${ROS_ROOT}
  ${catkin_INCLUDE_DIRS}
)


## Declare a cpp executable
add_executable( tracker src/tracker/trackerMain.cpp src/tracker/tracker.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )

# make sure configure headers are built before any node using them
add_dependencies(tracker ardrone_autonomy) 


add_executable( testMain src/tracker/testMain.cpp src/tracker/drone_controller.cpp src/tracker/PID.cpp )
add_dependencies( testMain ardrone_autonomy )

## Specify libraries to link a library or executable target against
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})

find_package(cv_bridge)
include_directories(${cv_bridge_INCLUDE_DIRS})

target_link_libraries( tracker
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

target_link_libraries( testMain
  ${catkin_LIBRARIES}
  ${cv_bridge_INCLUDE_DIRS}
)

When I run

~/ros_ws $ catkin_make

I get:

Project 'mrl_ardrone' tried to find library 'ardrone_autonomy'.  The
library is neither a target nor built/installed properly.  Did you compile
project 'ardrone_autonomy'? Did you find_package() it before the
subdirectory containing its code is included?

which suggests to me that my problem is not with the include directory itself, but something more general with CMake not being able to find stuff. But ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2013-10-29 07:10:08 -0500

Dirk Thomas gravatar image

updated 2013-10-29 07:11:08 -0500

All you have to do is:

include_directories(${catkin_INCLUDE_DIRS})

Catkin and genmsg will take care of including the correct folder in devel space or in install space. This is under the assumption that you have called the following before:

find_package(catkin REQUIRED COMPONENTS package1)
edit flag offensive delete link more

Comments

I have 'include_directories(${catkin_INCLUDE_DIRS})', when I do 'find_package(catkin REQUIRED COMPONENTS package1)' I get: Project 'project2' tried to find library 'project1'. The library is neither a target nor built/installed properly. Did you compile project 'project1'? Did you find_package() it before the subdirectory containing its code is included?

ounsworth gravatar imageounsworth ( 2013-10-29 07:29:17 -0500 )edit

May be it helps if you would post the CMakeLists.txt files of both packages. I am just guessing that you export a library in package1 (in the catkin_package() call) which you don't have.

Dirk Thomas gravatar imageDirk Thomas ( 2013-10-29 07:32:39 -0500 )edit
3

It looks like I guessed right. Your project1 contains `catkin_package(... LIBRARIES ${PROJECT_NAME} ...)` but you don't build any library with that name. Remove that line from your CMake file.

Dirk Thomas gravatar imageDirk Thomas ( 2013-10-29 08:16:58 -0500 )edit

Wow, ok. Problem fixed. Thank you very much!!

ounsworth gravatar imageounsworth ( 2013-10-29 08:21:41 -0500 )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-29 04:57:24 -0500

Seen: 2,023 times

Last updated: Oct 29 '13