Ask Your Question
0

Cannot include tf2_geometry_msgs.h

asked 2020-02-18 12:06:31 -0500

mdeegan gravatar image

I am trying to include tf2_geometry_msgs/tf2_geometry_msgs.h, however I keep getting the following include error:

In file included from /home/martin/ros2_ws/src/acrobat_packages/acrobat_common/tests/lie_group_conversions_test.cpp:3:0:
/home/martin/ros2_ws/src/acrobat_packages/acrobat_common/include/acrobat_common/lie_groups/lie_group_conversions.hpp:3:10: fatal error: tf2_geometry_msgs/tf2_geometry_msgs.h: No such file or directory
 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is my CMakeLists.txt:

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3)
find_package(Sophus REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)

include_directories(include)

add_library(${PROJECT_NAME} SHARED 

  # Lie groups
  src/lie_groups/lie_groups.cpp
  src/lie_groups/lie_group_conversions.cpp

)
target_include_directories(${PROJECT_NAME}
  PUBLIC
  "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
  "$<INSTALL_INTERFACE:include>"
)
set(AMENT_DEPENDENCIES 
  "Eigen3" 
  "Sophus" 
  "tf2" 
  "tf2_ros"
  "geometry_msgs"
  "tf2_geometry_msgs"
)

ament_target_dependencies(${PROJECT_NAME} ${AMENT_DEPENDENCIES})

And my package.xml

  <build_depend>eigen3_cmake_module</build_depend>
  <build_depend>Eigen3</build_depend>
  <build_depend>Sophus</build_depend>

  <depend>geometry_msgs</depend>
  <depend>tf2</depend>
  <depend>tf2_ros</depend>
  <depend>tf2_geometry_msgs</depend>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>
  <test_depend>ament_cmake_gtest</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>

I cannot see what I am doing wrong here. Does ament_target_dependencies not set target include directories?

edit retag flag offensive close merge delete

Comments

The error is originating from lie_group_conversions_test.cpp. Can you show the CMake for how that file is included in a target and built?

jdlangs gravatar image jdlangs  ( 2020-10-14 09:39:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
-1

answered 2020-10-14 03:44:14 -0500

wiyogo gravatar image

updated 2020-10-16 03:16:05 -0500

sudo apt install ros-melodic-tf2-geometry-msgs works in my workspace.

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

2 followers

Stats

Asked: 2020-02-18 12:06:31 -0500

Seen: 1,245 times

Last updated: Oct 16 '20