https://github.com/asorbini/rticonnextdds-ros2-msgs
rtiddsgen message type supports to use ROS 2 types with RTI Connext DDS
https://github.com/asorbini/rticonnextdds-ros2-msgs
Last synced: about 1 year ago
JSON representation
rtiddsgen message type supports to use ROS 2 types with RTI Connext DDS
- Host: GitHub
- URL: https://github.com/asorbini/rticonnextdds-ros2-msgs
- Owner: asorbini
- License: apache-2.0
- Created: 2021-04-18T12:00:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T07:41:46.000Z (almost 5 years ago)
- Last Synced: 2025-02-10T06:46:08.031Z (over 1 year ago)
- Language: C++
- Size: 777 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ROS 2 messages for RTI Connext DDS
The repository contains a library of C++11 message type supports generated by
`rtiddsgen`, which allows any DDS application to use most types included in ROS 2
with RTI Connext DDS.
The library is packaged in a ROS 2 package for convenience, but it may also be
built without ROS 2 as a stand-alone dependency.
The package is built with the help of [`rticonnextdds-ros2-helpers`](https://github.com/asorbini/rticonnextdds-ros2-helpers).
This repository takes inspiration from [`rticommunity/ros-data-types`](https://github.com/rticommunity/ros-data-types),
which offers a similar library that provides easy access to ROS 2 data types to
any Connext application.
- [Use `connext_msgs` in a ROS 2 package](#use-connext_msgs-in-a-ros-2-package)
- [Use `connext_msgs` in any DDS application](#use-connext_msgs-in-any-dds-application)
- [Example applications](#example-applications)
- [Included IDL files](#included-idl-files)
- [Included packages](#included-packages)
- [Unsupported types](#unsupported-types)
- [Alternative message variants](#alternative-message-variants)
- [CMake options](#cmake-options)
- [Other useful resources](#other-useful-resources)
## Use `connext_msgs` in a ROS 2 package
Since `connext_msgs` is a regular ROS 2 package, you can just add it to your
`package.xml` dependencies, and load it in your `CMakeLists.txt` like any other
package and library:
- `package.xml`:
```xml
my_package
connext_msgs
```
- `CMakeLists.txt`
```cmake
cmake_minimum_required(VERSION 3.5)
project(my_package)
# ...
# Load package
find_package(connext_msgs REQUIRED)
# ...
# Add dependency to your targets
ament_target_dependencies(my_target connext_msgs)
ament_export_dependencies(connext_msgs)
```
Make sure to clone the repository to your workspace, along with `rticonnextdds-ros2-helpers`,
and `colcon build` will automatically build everything a needed:
```sh
cd my-workspace/
git clone https://github.com/asorbini/rticonnextdds-ros2-msgs
git clone https://github.com/asorbini/rticonnextdds-ros2-helpers
colcon build
```
You can also use the included `ros2.repos` file to clone all required repositories
with `vcs`:
```sh
cd my-workspace/
wget https://raw.githubusercontent.com/asorbini/rticonnextdds-ros2-msgs/master/ros2.repos
vcs import < ros2.repos
```
In order to use the types, you must `#include` the appropriate file in your C++
code. The path is slightly different from the one used for standard ROS 2 messages,
in that the file name is not converted to all lowercase and "snake case" format,
instead retaining the same name as the input `.idl`.
For example, in order to use type `sensor_msgs::msg::PointCloud`:
```cpp
// typical ROS 2 include
#include "sensor_msgs/msg/point_cloud.hpp"
// DDS type include
#include "sensor_msgs/msg/PointCloud.hpp"
```
## Use `connext_msgs` in any DDS application
The type supprts library provided by this repository does not have any direct
dependency on ROS 2, and it may also be built as a stand-alone dependency.
In order to do this, you must clone all required dependencies and run `cmake`
by hand:
```sh
git clone https://github.com/asorbini/rticonnextdds-ros2-msgs
cd rticonnextdds-ros2-msgs
git clone https://github.com/asorbini/rticonnextdds-ros2-helpers
mkdir build
cd build
cmake ../connext_msgs -DCMAKE_INSTALL_PREFIX=../install
cmake --build . -- -j4 install
```
The library will be installed under `${CMAKE_INSTALL_PREFIX}/lib` while all
header files will be placed under `${CMAKE_INSTALL_PREFIX}/include`.
By default, the library will be named `connext_msgs`, but you can customize
this name with variable `MESSAGE_LIBRARY`.
If you prefer to clone `rticonnextdds-ros2-helpers` somewhere else, you can specify
its location using variable `CONNEXT_ROS2_HELPERS_DIR`.
You can also force the library to be built in standalone mode by setting
`MESSAGE_STANDALONE` to `true`.
## Example applications
Package `connext_msgs_examples` contains some example applications that link
`connext_msgs` and use types from the library.
The applications require `rmw_connextdds` to run:
```sh
source install/setup.bash
export RMW_IMPLEMENTATION=rmw_connextdds
ros2 run connext_msgs_examples listener &
ros2 run connext_msgs_examples talker
```
## Included IDL files
Package `connext_msg` contains a collection of IDL files extracted from the
ROS 2 Rolling distribution, and modified to compile with `rtiddsgen` so that
they may be compiled into a single, ready-to-use shared library.
The IDL files can be updated using script `copy_idls.sh`.
The script will scan a ROS 2 installation, and it will copy all IDL files
to the `./idl` directory. It will also perform some lightweight processing on
the files to remove some incompatibilities.
## Included packages
Types from the following packages are currently included in the library:
```txt
actionlib_msgs logging_demo statistics_msgs
action_msgs map_msgs std_msgs
action_tutorials_interfaces nav_msgs std_srvs
builtin_interfaces pcl_msgs stereo_msgs
composition_interfaces pendulum_msgs test_msgs
diagnostic_msgs rcl_interfaces tf2_msgs
example_interfaces rmw_dds_common trajectory_msgs
geometry_msgs rosgraph_msgs turtlesim
libstatistics_collector sensor_msgs unique_identifier_msgs
lifecycle_msgs shape_msgs visualization_msgs
```
The list of included message packages can be restricted by specifying variable
`MESSAGE_INCLUDE_PACKAGES`, e.g. `-DMESSAGE_INCLUDE_PACKAGES="std_msgs;builtin_interfaces"`, in
which case only messages from the specified packages will be included.
You can further customize the list of messages included in the generated
library using variables `MESSAGE_INCLUDE` and `MESSAGE_EXCLUDE`. Messages must
be specified as `/msg/`, and exclusions take precedence over includes.
## Unsupported types
The following types are currently unsupported:
```txt
action_tutorials_interfaces/action/Fibonacci
example_interfaces/action/Fibonacci
test_msgs/action/Fibonacci
test_msgs/msg/Arrays
test_msgs/msg/BoundedSequences
test_msgs/msg/MultiNested
test_msgs/msg/UnboundedSequences
test_msgs/msg/Defaults
test_msgs/srv/Arrays
```
## Alternative message variants
The repository contains automatically generated variants for each type to use
it with the Flat-Data and Zero-Copy features.
These variants are not built by default, and they must be explicitly enabled
with cmake options (`MESSAGE_VARIANT_`, e.g. `MESSAGE_VARIANT_FLAT`).
All types in the variants are placed in separate packages to distinguish them
from the originals:
- `ros2::flat`: Flat-Data versions.
- `ros2::flat_zc`: Flat-Data/Zero-Copy versions.
- `ros2::zc`: Zero-Copy versions.
- `ros2::xcdr2`:versions forcing use of XCDR2 serialization format.
These types might not be compatible with their original versions, because of
changes applied to them to make them conform
with the limitation of the features, particularly with respect to lack of support
for strings and sequences:
- All `string` (and `wstring`) field is converted to an array of `char` (or `wchar`).
Any `@default()` annotation will be discarded, since they are not supported on
array fields. If the field is unbounded, the array will be assigned an arbitrary
maximum length (by default: 255).
- All sequences are converted to an array of the contained type. Sequences of
`string` (or `wstring`) will be further expanded into multi-dimensional arrays
of `char` (or `wchar`). For example `sequence foo` will be converted
into `char foo[10][MAX_STR_LEN]`. If the field is unbounded, the array will be assigned an arbitrary maximum length (by default: 100).
## CMake options
| Variable | Default | Description |
|-----------|---------|-------------|
|`MESSAGE_BROKEN`|See `CMakeLists.txt`|List of messages that cannot be built by `rtiddsgen`|
|`MESSAGE_EXCLUDE`|Empty list (no message)|List of messages to be excluded from the build|
|`MESSAGE_EXCLUDE_REGEX`|`""` (no message)|Regex to match messages that should be excluded from the build|
|`MESSAGE_INCLUDE`|Empty list (all messages)|List of messages to be included in the build|
|`MESSAGE_INCLUDE_REGEX`|`""` (all messages)|Regex to match messages that should be included in the build|
|`MESSAGE_INCLUDE_PACKAGES`|Empty list (all packages)|List of packages to be included in the build|
|`MESSAGE_VARIANT_ALL`|`OFF`|Generate all possible type variants|
|`MESSAGE_VARIANT_FLAT`|`OFF`|Generate Flat-Data variants|
|`MESSAGE_VARIANT_FLAT_ZC`|`OFF`|Generate Flat-Data/Zero-Copy variants|
|`MESSAGE_VARIANT_ZC`|`OFF`|Generate Zero-Copy variants|
|`MESSAGE_VARIANT_XCDR2`|`OFF`|Generate XCDR2 variants|
## Other useful resources
- [`rticonnextdds-ros2-demos`](https://github.com/asorbini/rticonnextdds-ros2-demos)
- Collection of example hybrid ROS 2/Connext applications.
- [`rticonnextdds-ros2-helpers`](https://github.com/asorbini/rticonnextdds-ros2-helpers)
- Collection of utilities to built ROS 2 applications with RTI Connext DDS.