ros2 / rosidl_typesupport

Packages which provide the typesupport for ROS messages and services
Apache License 2.0
13 stars 34 forks source link

rosidl_typesupport_c assumes shared library names are called "<package name>__<typesupport name>" #120

Open sloretz opened 2 years ago

sloretz commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

Expected behavior

All of rcl's tests would pass

Actual behavior

Many tests fail with

85: [ RUN      ] TestSubscriptionFixture__rmw_fastrtps_dynamic_cpp.test_subscription_init_fini_and_is_valid
85: /home/osrf/ws/ros2/src/ros2/rcl/rcl/test/rcl/test_subscription.cpp:135: Failure
85: Expected equality of these values:
85:   0
85:   ret
85:     Which is: 1
85: Type support not from this implementation. Got:
85:     Could not load library libtest_msgs__rosidl_typesupport_introspection_c.so: dlopen error: libtest_msgs__rosidl_typesupport_introspection_c.so: cannot open shared object file: No such file or directory, at /home/osrf/ws/ros2/src/ros2/rcutils/src/shared_library.c:99, at /home/osrf/ws/ros2/src/ros2/rosidl_typesupport/rosidl_typesupport_c/src/type_support_dispatch.hpp:78
85:     Handle's typesupport identifier (rosidl_typesupport_c) is not supported by this library, at /home/osrf/ws/ros2/src/ros2/rosidl_typesupport/rosidl_typesupport_c/src/type_support_dispatch.hpp:113
85: while fetching it, at /home/osrf/ws/ros2/src/ros2/rmw_fastrtps/rmw_fastrtps_dynamic_cpp/src/subscription.cpp:117, at /home/osrf/ws/ros2/src/ros2/rcl/rcl/src/rcl/subscription.c:105
85: [  FAILED  ] TestSubscriptionFixture__rmw_fastrtps_dynamic_cpp.test_subscription_init_fini_and_is_valid (7 ms)
85: [ RUN      ] TestSubscriptionFixture__rmw_fastrtps_dynamic_cpp.test_subscription_bad_init

All failures:

      7 - test_client__rmw_cyclonedds_cpp (Failed)
     14 - test_graph__rmw_cyclonedds_cpp (Failed)
     15 - test_info_by_topic__rmw_cyclonedds_cpp (Failed)
     16 - test_count_matched__rmw_cyclonedds_cpp (Failed)
     17 - test_get_actual_qos__rmw_cyclonedds_cpp (Failed)
     22 - test_remap_integration__rmw_cyclonedds_cpp (Failed)
     24 - test_publisher__rmw_cyclonedds_cpp (Failed)
     25 - test_publisher_wait_all_ack__rmw_cyclonedds_cpp (Failed)
     26 - test_service__rmw_cyclonedds_cpp (Failed)
     27 - test_subscription__rmw_cyclonedds_cpp (Failed)
     28 - test_events__rmw_cyclonedds_cpp (Failed)
     31 - test_namespace__rmw_cyclonedds_cpp (Failed)
     33 - test_network_flow_endpoints__rmw_cyclonedds_cpp (Failed)
     34 - test_services__rmw_cyclonedds_cpp (Failed)
     36 - test_client__rmw_fastrtps_cpp (Failed)
     43 - test_graph__rmw_fastrtps_cpp (Failed)
     44 - test_info_by_topic__rmw_fastrtps_cpp (Failed)
     45 - test_count_matched__rmw_fastrtps_cpp (Failed)
     46 - test_get_actual_qos__rmw_fastrtps_cpp (Failed)
     51 - test_remap_integration__rmw_fastrtps_cpp (Failed)
     53 - test_publisher__rmw_fastrtps_cpp (Failed)
     54 - test_publisher_wait_all_ack__rmw_fastrtps_cpp (Failed)
     55 - test_service__rmw_fastrtps_cpp (Failed)
     56 - test_subscription__rmw_fastrtps_cpp (Failed)
     57 - test_events__rmw_fastrtps_cpp (Failed)
     60 - test_namespace__rmw_fastrtps_cpp (Failed)
     62 - test_network_flow_endpoints__rmw_fastrtps_cpp (Failed)
     63 - test_services__rmw_fastrtps_cpp (Failed)
     65 - test_client__rmw_fastrtps_dynamic_cpp (Failed)
     72 - test_graph__rmw_fastrtps_dynamic_cpp (Failed)
     73 - test_info_by_topic__rmw_fastrtps_dynamic_cpp (Failed)
     74 - test_count_matched__rmw_fastrtps_dynamic_cpp (Failed)
     75 - test_get_actual_qos__rmw_fastrtps_dynamic_cpp (Failed)
     80 - test_remap_integration__rmw_fastrtps_dynamic_cpp (Failed)
     82 - test_publisher__rmw_fastrtps_dynamic_cpp (Failed)
     83 - test_publisher_wait_all_ack__rmw_fastrtps_dynamic_cpp (Failed)
     84 - test_service__rmw_fastrtps_dynamic_cpp (Failed)
     85 - test_subscription__rmw_fastrtps_dynamic_cpp (Failed)
     86 - test_events__rmw_fastrtps_dynamic_cpp (Failed)
     89 - test_namespace__rmw_fastrtps_dynamic_cpp (Failed)
     91 - test_network_flow_endpoints__rmw_fastrtps_dynamic_cpp (Failed)
     92 - test_services__rmw_fastrtps_dynamic_cpp (Failed)

Additional information

I don't fully understand what's going on, but I'm pretty sure this code is wrong. It assumes the library name for a typesupport target is going to be "__", but that's an incorrect assumption. The first part is the target name passed to rosidl_generate_interfaces, not the package name.

https://github.com/ros2/rosidl_typesupport/blob/34f6e4b5296704c598037cb07299b12339afa8ab/rosidl_typesupport_c/src/type_support_dispatch.hpp#L57-L59

sloretz commented 2 years ago

IIUC from @hidmic , the instrospection typesupport assumes the library is named the same as the package in more places than this.

A temporary workaround would be to warn in rosidl_generate_interfaces() if the passed target name is anything other than ${PROJECT_NAME} with a link to this issue.

hidmic commented 2 years ago

@sloretz To add to this, I even added a macro quite recently to put together the library name given how often we do it elsewhere.

If we want to generalize library naming (and propagate them as a map? so downstream can fetch the right library for a given package), we have to make changes here and downstream. Otherwise, I agree that enforcing the name would be best.

sloretz commented 2 years ago

Similar issue in the past https://github.com/ros2/rosidl_python/issues/11

felixf4xu commented 10 months ago

I'm having the same issue but my case is a little different.

I am using msg from the same package. My exe is named by package name like this:

    add_executable(${PROJECT_NAME} src/pcl_mapping.cpp)

then I generate the msg lib in the same cmake file, I have to change the lib name to another name (here by adding _msg because the target name is already used by my exe (this is a cmake rule):

    rosidl_generate_interfaces(${PROJECT_NAME}_msg

then this will lead to the exactly same error message as reported by this issue.