0
$\begingroup$

Rosanswers logo

I am attempting to use a custom set of ros_control headers (specifically for the controller_manager class) in a package that depends on nearly a dozen other packages, some of which I cannot modify. I am building the ROS ros_control package from source and I expected this to supersede the Debian version of ros_control, however, it is still using the Debian headers.

The problem appears to stem from the include path used by catkin_make. With verbosity turned on, catkin_make shows /opt/ros/indigo/include/ as the first include path. Ideally, this should be one of the last include paths. I'm guessing that one of my dependencies is messing up the include path, but I don't know find which one or if I can even modify the package.

How do I ensure that /opt/ros/indigo/include gets put at the end of the include path list? I would preferably like to only modify my current package's CMakeList.txt.

Edit 1: Additional Information:

I'm getting the following error. The getRunningControllersListRealTime(std::vector<std::string>& v) is a custom function that I know works in other parts of the system, so I know that the wrong set of headers are being used for some reason.

/home/USERNAME/flor_repo/catkin_ws/src/thor_control/valor_ros_control/valor_escher_controller/src/ValorEscherController.cpp:314:13: error: ‘class controller_manager::ControllerManager’ has no member named   ‘getRunningControllersListRealTime’
   mode_cm_->getRunningControllersListRealTime(running_controllers_list); // get list of all controllers currently loaded in this manager
             ^

With Catkin's verbose flag turned on, I get the following output indicating that the Indigo headers are first in the include list. I don't know how those headers got put first, but I need a way of moving them to the end of my include list using my package's CMakeList.txt.

[ 80%] Building CXX object thor_control/valor_ros_control/valor_escher_controller/CMakeFiles/valor_escher_controller.dir/src/ValorEscherController.cpp.o
cd /home/james/flor_repo/catkin_ws/build/thor_control/valor_ros_control/valor_escher_controller && /usr/bin/c++   -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"valor_escher_controller\" -Dvalor_escher_controller_EXPORTS -std=gnu++0x -O3 -DNDEBUG -fPIC **-I/opt/ros/indigo/include** -I/usr/include/eigen3 -I/home/james/flor_repo/catkin_ws/src/ros_control/hardware_interface/include -I/home/james/flor_repo/catkin_ws/src/ros_control/controller_manager/include -I/home/james/flor_repo/catkin_ws/src/ros_control/controller_interface/include ... [Additional paths]    -o CMakeFiles/valor_escher_controller.dir/src/ValorEscherController.cpp.o -c /home/james/flor_repo/catkin_ws/src/thor_control/valor_ros_control/valor_escher_controller/src/ValorEscherController.cpp

Edit 2: Added CMakeLists.txt file for package.

Here is my CMakeLists for the current package. I've stripped out the comments and boiler plate language, as well as the project specific packages that I know work in other locations.

cmake_minimum_required(VERSION 2.8.3)
project(valor_escher_controller)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")

find_package(Boost REQUIRED COMPONENTS system)
find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Eigen REQUIRED)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  eigen_stl_containers
  eigen_conversions
  hardware_interface
  controller_manager
 ... [Additional project specific packages])

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

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

SET(HEADERS
  [List of 12 in-package headers]
)

SET(SOURCE
  [List of 3 in-package source files]
)

SET(ASGARD_HEADER_PATHS
  [List of Non-ROS header locations]
)

SET(ASGARD_LIB_PATHS
  [Non-ROS library path]
)

catkin_package(
  INCLUDE_DIRS
    include
    ${ASGARD_HEADER_PATHS}
  LIBRARIES valor_escher_controller
  CATKIN_DEPENDS
    roscpp
    std_msgs
    hardware_interface
    controller_manager
    ... [Project specific packages]
  DEPENDS
    Eigen
    ... [Non-ROS dependencies]
  CFG-EXTRAS
    valor_escher_controllers-extras.cmake)

include_directories(
  include
  ${ASGARD_HEADER_PATHS}
  ${Boost_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

link_directories(
  ${ASGARD_LIB_PATHS}
)

add_library(${PROJECT_NAME} ${SOURCE} ${HEADERS} )
target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
  ... [Non-ROS libraries]
)

install( TARGETS ${PROJECT_NAME} #${PROJECT_NAME}_node ${PROJECT_NAME}_sim
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY launch
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  FILES_MATCHING PATTERN "*.launch")

install(DIRECTORY config
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  FILES_MATCHING PATTERN "*.yaml")

Originally posted by James Burton on ROS Answers with karma: 11 on 2015-03-03

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

If you have the modified version of ros_control in your workspace alongside the pakage you're trying to build, catkin should do this automatically (this is one of the core design goals of catkin).

Do you have any output from the compilation process (other than the include path order) that indicates that it isn't using your custom headers?

You could try adding an #error preprocessor defiintion in one of your custom headers to confirm that it is being included properly.


Originally posted by ahendrix with karma: 47576 on 2015-03-03

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by James Burton on 2015-03-04:
I've add some additional information. I'm sure that the standard ros_control headers are being used instead of the custom ones. For some reason, the Indigo headers are first in the include order.

Comment by gvdhoorn on 2015-03-04:
Could you add your CMakelists.txt as well? Please without all the verbose boilerplate comments.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Just some comments:

find_package(Boost REQUIRED COMPONENTS system)
find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Eigen REQUIRED)

find_package(catkin REQUIRED COMPONENTS ..)

Not sure if this is the cause of your issue, but don't invoke find_package(..) twice (or more than once actually) with the same find script (in this case catkin). They are not cumulative, and depending on the implementation, results will be overwritten, or the second invocation will return early (and use cached, earlier results).

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

Also not the cause of your issue, but this has been deprecated since the move to catkin.

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

[..]

include_directories(
  include
  ${ASGARD_HEADER_PATHS}
  ${Boost_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

Any particular reason to duplicate this (include path is set right after the second find_package(catkin ..))?


Originally posted by gvdhoorn with karma: 86574 on 2015-03-04

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by William on 2015-03-04:
I think the root of the issue is doing find_package(catkin) more than once. The find_package(catkin) will order the include directories to avoid exactly this issue, but if you do it more then once then the ordering is not done over the set.

$\endgroup$

Your Answer

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