Replies: 2 comments
-
Hi @Ryanf55, thanks for your contribution. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If adding |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Purpose
As a user of FastDDSGen who is using this to generate ROS 2 compliant messages, it is quite difficult to call
FastDDSGen
from a CMake build system. It would be great if eProsima could distribute a CMake script that performs similar function torosidl_generate_interfaces
that makes this task a lot easier. People use FastDDS directly instead of ROS 2 for various reasons, but CMake is very common when consuming DDS. Developers expect when they compile a large piece of software, they do not need to callfastddsgen
in CLI or run some random bash script - instead, they want CMake to generate the C++ implemententation files.Use case
How this works today
Locate your IDL files from the ROS install:
And, their dependencies (manually)
Add
#pragma once
so they don't conflict - I copy the files locally into a work tree so I don't need root permissions.find IDL -name *.idl | xargs grep -L "#pragma once" | xargs sed -i -e "1i #pragma once"
Using CMake, form the FastDDSGen command into something like
execute_process
oradd_custom_target
so it runs a variation of thisDeal with the fact that it generates
builtin_interfaces/msg/Time.h
in thestd_msgs
directory (There's a few ways to work around the limitations of FastDDSGen) - I really like the new--no-dependencies
flag, but it requires CMake users to re-implement the dependency tree themselves.Add a new target and set the sources to all the generated *.h, *.cxx files (including the dependent ones)
add_library(std_msgs_fastdds SHARED ${CMAKE_CURRENT_BINARY_DIR}/std_msgs/msg/header.h ...
LInk dependencies manually
target_link_libraries(std_msgs_fastdds PUBLIC builtin_interfaces_fastdds)
Complexities
Header.idl
, then fastddsgen runs many times on the same fileNotes
I've now seen my 3rd internal implementation of this functionality in CMake. All of them have issues, suffer from caching problems or require changing include paths in your source code, and are trying to work around limitations in
fastddsgen
. If I can get approval, I can open source some of these implementations for your reference and work with the open source community to supply and maintain a better version to solve this use case.Dockerfile
To get started, here's just the start without any CMake.
Build the dockerfile
Note - with current master, there is an unrelated failure:
The
v2.1.2
branch of FastDDSGen does not have this error. I would like to use the latest FastDDSGen if possible.If you do that, you can see it generated everything in the same folder. The CMake script must work around this and move files back into folders.
Desired API
In
CMake
, I can call a function:fastddsgen_interfaces(${PROJECT_NAME} /opt/ros/humble/share/std_msgs/msg/Header.idl)
Beta Was this translation helpful? Give feedback.
All reactions