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

ROS2 Foxy fail to link kdl_parser

asked 2021-02-18 20:17:53 -0500

hclin gravatar image

I followed the standard procedure to install ROS2 Foxy debian on Ubuntu20.04. I tried to build a package with kdl_parser. However, I got a Cmake error:

CMake Error at CMakeLists.txt:24 (add_executable): Target "robotKinematicsNode" links to target "urdf::urdf" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

CMake Generate step failed. Build files cannot be regenerated correctly. make: * [Makefile:266: cmake_check_build_system] Error 1

The following is my CMakeList.txt file:

cmake_minimum_required(VERSION 3.5)

project(robot_kinematics)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic)
endif()

#find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(kdl_parser REQUIRED)
find_package(orocos_kdl REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2_kdl REQUIRED)
find_package(tf2_ros REQUIRED)

## Add executable
add_executable(robotKinematicsNode src/robot_kinematics.cpp)
ament_target_dependencies(robotKinematicsNode rclcpp kdl_parser orocos_kdl sensor_msgs geometry_msgs tf2_kdl tf2_ros)


install(TARGETS
   robotKinematicsNode
   DESTINATION lib/${PROJECT_NAME})

ament_package()

The following is the package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>robot_kinematics</name>
 <version>0.0.0</version>
 <description>TODO: Package description</description>
  <maintainer email="xxx@todo.todo">xxx</maintainer>
   <license>TODO: License declaration</license>
    <buildtool_depend>ament_cmake</buildtool_depend>
     <depend>rclcpp</depend>
      <depend>kdl_parser</depend>
       <depend>orocos_kdl</depend>
      <depend>sensor_msgs</depend>
      <depend>tf2_kdl</depend>
      <depend>tf2_ros</depend>
     <test_depend>ament_lint_auto</test_depend>
     <test_depend>ament_lint_common</test_depend>

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

If I removed "kdl_parser" from the ament_target_dependencies in the CMakeList, the package can be built successfully. I wondered why it causeed the Cmake fail. It would be nice to hear any answer to resolve the issue. Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-02-19 00:18:44 -0500

hclin gravatar image

I found a workaround way is simply add the following line to the CMakeList.txt.

find_package(urdf REQUIRED)

However, I am still interested to know if there is other way to resolve this issue.

edit flag offensive delete link more

Comments

In Foxy, kdl_parser declared a PUBLIC dependency on urdf, but did not export that dependency. It looks like this was fixed for Humble by making the dependency on urdf PRIVATE: https://github.com/ros/kdl_parser/com...

clyde gravatar image clyde  ( 2022-12-01 12:51:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-02-18 20:17:53 -0500

Seen: 646 times

Last updated: Feb 19 '21