ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Please help with my CMakeLists.txt. Conflicting packages unable to build.

asked 2022-07-09 17:51:02 -0600

ericdusel77 gravatar image

Hello! I am really confused on how to construct an appropriate CMakeLists.txt. I am trying to create a package and I was able to create all of the necessary nodes and they work seperately, but when I try to build it all together, I get a lot of errors.

The two packages causing problems are pcl_ros and ocs2_ros_interfaces (https://github.com/leggedrobotics/ocs2).

I am using ros noetic. Below is my CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)
project(sara_arm)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
    actionlib
    actionlib_msgs
    pcl_msgs
    pcl_ros
    moveit_core
    moveit_ros_planning
    moveit_ros_planning_interface
    sensor_msgs
    tf2
    tf2_ros
    kinova_msgs
    moveit_visual_tools
    tf2_eigen
    ocs2_ros_interfaces
)

add_service_files(
  FILES
  image_to_cloud_point.srv
)

generate_messages(
  DEPENDENCIES
  geometry_msgs  # Or other packages containing msgs
  sensor_msgs
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_executable(ocs2_sara src/ocs2_sara.cpp)
target_link_libraries(ocs2_sara ${catkin_LIBRARIES})

add_executable(pcp_sara src/pcp_sara.cpp)
target_link_libraries(pcp_sara ${catkin_LIBRARIES})

add_executable(sara_arm src/sara_arm.cpp)
target_link_libraries(sara_arm ${catkin_LIBRARIES})

The errors that pop up are referencing a lot of issues with pcl.

  • If I comment out the pcp_sara add_executable and target_link_libraries calls, it builds fine (but I cannot use that node, obviously)
  • If I comment out the ocs2_sara add_executable and target_link_libraries calls, it does not build and tells me I have tons of errors with pcl, similar to if I leave it uncommented
  • If I comment out the ocs2_sara add_executable and target_link_libraries calls AND the ocs2_ros_interfaces from the find_pakage() call, it builds fine, but I cannot use the ocs2_sara node

I would appreciate any help, I am sure I am missing something (perhaps a catkin_package() call) but since everything works independently, I am not sure what to do to make sure they work together. Is there something I can look into in the ocs2_ros_interfaces that might be causing issues?

NOTE: ocs2_ros_interfaces is cloned to my catkin_ws, while pcl (and all the other packages listed) are installed via sudo apt-get install.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-10 11:07:00 -0600

ericdusel77 gravatar image

I fixed it. This way works:

cmake_minimum_required(VERSION 3.0.2)
project(sara_arm)

set(CATKIN_PACKAGE_DEPENDENCIES
    actionlib
    actionlib_msgs
    pcl_msgs
    pcl_ros
    moveit_core
    moveit_ros_planning
    moveit_ros_planning_interface
    sensor_msgs
    tf2
    tf2_ros
    kinova_msgs
    moveit_visual_tools
    tf2_eigen
    ocs2_ros_interfaces
)

find_package(catkin REQUIRED COMPONENTS
  ${CATKIN_PACKAGE_DEPENDENCIES}
)

find_package(PCL REQUIRED)

add_service_files(
  FILES
  image_to_cloud_point.srv
)

generate_messages(
  DEPENDENCIES
  geometry_msgs  # Or other packages containing msgs
  sensor_msgs
)
###################################
## catkin specific configuration ##
###################################

catkin_package(
  INCLUDE_DIRS
    include
  CATKIN_DEPENDS
    ${CATKIN_PACKAGE_DEPENDENCIES}
  # DEPENDS
)

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

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

# add_library(pcp_sara src/pcp_sara.cpp)

# add_library(sara_arm src/sara_arm.cpp)

add_executable(pcp_sara src/pcp_sara.cpp)
target_link_libraries(pcp_sara ${catkin_LIBRARIES} ${PCL_LIBRARIES})

add_executable(sara_arm src/sara_arm.cpp)
target_link_libraries(sara_arm ${catkin_LIBRARIES})

add_executable(ocs2_sara src/ocs2_sara.cpp)
target_link_libraries(ocs2_sara ${catkin_LIBRARIES})
edit flag offensive delete link more

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: 2022-07-09 17:51:02 -0600

Seen: 22 times

Last updated: Jul 09 '22