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

ROS2 Crystal member service linking rosidl_typesupport_cpp

asked 2019-04-17 01:42:25 -0500

JanOr gravatar image

updated 2019-04-17 06:37:36 -0500

Hi everyone,

I have a problem including services in ROS2 crystal packages. If I try to add and generate a custom service and use std service "Trigger", I get a rosidl linking error:

Error parsing

librobot_manager_lib.so: undefined reference to `rosidl_service_type_support_t const* rosidl_typesupport_cpp::get_service_type_support_handle<std_srvs::srv::trigger>()'

The service handle routine is implemented in the library lib.cpp and linked to the executable defined in test_node.cpp.

The package.xml looks like this:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>test</name>

   ...

  <buildtool_depend>ament_cmake</buildtool_depend>
  <buildtool_depend>rosidl_default_generators</buildtool_depend>

  <build_depend>ament_index_cpp</build_depend>
  <build_depend>class_loader</build_depend>
  <build_depend>rosidl_cmake</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>std_srvs</build_depend>
  <build_depend>builtin_interfaces</build_depend>

  <exec_depend>ament_index_cpp</exec_depend>
  <exec_depend>class_loader</exec_depend>
  <exec_depend>rclcpp</exec_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>std_srvs</exec_depend>
  <exec_depend>builtin_interfaces</exec_depend>

  <member_of_group>rosidl_interface_packages</member_of_group>

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

And the CMakeLists.txt accordingly:

cmake_minimum_required(VERSION 3.5)
project(test)

#Load required packages
find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(rcutils REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

#Build Messages/Services 1
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
  "srv/TestService.srv"
)

#Define the search space for the headers
include_directories(include)

#Build project library
add_library(${PROJECT_NAME}_lib SHARED src/lib.cpp)
ament_target_dependencies(${PROJECT_NAME}_lib rclcpp std_msgs rcutils class_loader)
rosidl_target_interfaces(${PROJECT_NAME}_lib ${PROJECT_NAME} "rosidl_typesupport_cpp") #Install srv hpp

install(TARGETS
  ${PROJECT_NAME}_lib
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin)

#Build&Install executable
add_executable(${PROJECT_NAME}_node src/test_node.cpp)
target_link_libraries(${PROJECT_NAME}_node ${PROJECT_NAME}_lib)
ament_target_dependencies(${PROJECT_NAME}_node rclcpp std_msgs rcutils class_loader)

#Install executable
install(TARGETS 
  ${PROJECT_NAME}_node
  DESTINATION lib/${PROJECT_NAME})

ament_export_dependencies(rosidl_default_runtime)
ament_package()

Do you have any idea what link I am missing here? Thanks a lot!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2019-04-17 14:37:35 -0500

Carl D gravatar image

Looks like you are missing find_package(std_srvs) in your CMakeLists.txt. Also add it to your ament_target_dependencies statements.

edit flag offensive delete link more

Comments

Thanks. You are completely right. -.-

JanOr gravatar image JanOr  ( 2019-04-26 07:16:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-17 01:42:25 -0500

Seen: 1,846 times

Last updated: Apr 17 '19