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

Fail at ROS2 IDL generation

asked 2019-02-09 15:04:17 -0500

lelongg gravatar image

updated 2019-02-12 11:44:34 -0500

I tried to add support for ROS2 IDL generation with Rust.

It happens to work only when find_package are declared in packages containing message definitions with find_package(rosidl_default_generators REQUIRED) first.

It means that in std_msgs for example, the following will make the whole generation work.

find_package(rosidl_default_generators REQUIRED)
find_package(builtin_interfaces REQUIRED)

While this will fail :

find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)

With the following error.

CMake Error at /opt/ros/crystal/share/rosidl_cmake/cmake/rosidl_target_interfaces.cmake:44 (message):
  rosidl_target_interfaces() the second argument 'std_msgs' concatenated with
  the third argument 'rosidl_typesupport_c' using double underscores must be
  a valid target name
Call Stack (most recent call first):
  /home/sisyphe/Projects/tests/ros2_rust_ws/install/share/rosidl_generator_rs/cmake/rosidl_generator_rs_generate_interfaces.cmake:200 (rosidl_target_interfaces)
  /opt/ros/crystal/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:38 (include)
  /opt/ros/crystal/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:280 (ament_execute_extensions)
  CMakeLists.txt:49 (rosidl_generate_interfaces)

The file rosidl_generator_rs_generate_interfaces.cmake generating this error can be found in this repository.

I seems that the required target does not exist at the right time but I don't know what dependency to add to fix this.

I don't understand the whole ROS2 IDL generation process yet and any help on how to be more knowledgeable on this matter might be useful.

edit retag flag offensive close merge delete


Trying to build a workspace containing the referenced repository works fine for me (at least until rclrs_examples which fails to invoke cargo which I don't have installed). Please describe the exact steps when you see the error.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-11 13:13:12 -0500 )edit

You're right, the repository compiles because I have manually edited all message packages to reorder find_package.

I have created a dedicated branch std_msgs_fail which reproduce the issue and should not compile.

lelongg gravatar image lelongg  ( 2019-02-12 11:48:37 -0500 )edit

I just tried to build a workspace using the std_msgs_fail branch and it passed (at least as far as the previous build) without a problem.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-02-19 13:19:57 -0500 )edit

I've just figured that I cannot reproduce my issue without the --merge-install argument on colcon build, which I was always using until now. Could you try again ?

lelongg gravatar image lelongg  ( 2019-02-19 16:04:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-02-19 16:46:50 -0500

Dirk Thomas gravatar image

With colcon build --merge-install (for performance --packages-up-to std_msgs) I can reproduce the failure.

The problem is that when your code generator is being executed (the logic in rosidl_generator_rs_generate_interfaces.cmake) it tries to depend on the rosidl_typesupport_c target. But your package didn't make sure that rosidl_typesupport_c was find_package-ed. That needs to happen before you register your own message generator in rosidl_generator_rs_extras. Otherwise the rosidl_typesupport_c might only be found later and therefore will only try to generate its code after your package has done so.

The easiest fix is to insert the following line in before calling the macro:

find_package(rosidl_typesupport_c REQUIRED)

edit flag offensive delete link more


Nice! I wasn't able to figure where I should add it, so it's was there! Thanks

lelongg gravatar image lelongg  ( 2019-02-20 07:48:00 -0500 )edit

Question Tools

1 follower


Asked: 2019-02-09 15:04:17 -0500

Seen: 2,720 times

Last updated: Feb 19 '19