From 3ea93f27aa8d02ddbd1fc24bb7e4564d0cab5721 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Fri, 20 Mar 2020 14:31:03 -0500 Subject: [PATCH 1/9] Prevent undefined behavior when serializing empty vector (#122) Since m_get_const_function calls `std::vector::operator[]`, accessing the zeroth element causes undefined behavior. Instead, return a null pointer to make the function behave sanely when vector is empty. Fix #120 --- rmw_cyclonedds_cpp/src/TypeSupport2.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp index 0beadc1..55fceb7 100644 --- a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp +++ b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp @@ -245,6 +245,8 @@ public: } const void * sequence_contents(const void * ptr_to_sequence) const override { + if(sequence_size(ptr_to_sequence) == 0) + return nullptr; return m_get_const_function(ptr_to_sequence, 0); } }; From b04ec25b382be23c612674b17193c8535be9a7b9 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Mon, 23 Mar 2020 12:55:08 -0500 Subject: [PATCH 2/9] uncrustify (#124) --- rmw_cyclonedds_cpp/src/TypeSupport2.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp index 55fceb7..c3e065f 100644 --- a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp +++ b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp @@ -245,8 +245,9 @@ public: } const void * sequence_contents(const void * ptr_to_sequence) const override { - if(sequence_size(ptr_to_sequence) == 0) + if (sequence_size(ptr_to_sequence) == 0) { return nullptr; + } return m_get_const_function(ptr_to_sequence, 0); } }; From c481c10f5da64a680840a4f0810d42e5bdf78491 Mon Sep 17 00:00:00 2001 From: Miaofei Mei Date: Fri, 27 Mar 2020 05:24:27 -0700 Subject: [PATCH 3/9] Support for ON_REQUESTED_INCOMPATIBLE_QOS and ON_OFFERED_INCOMPATIBLE_QOS events (#125) Signed-off-by: Miaofei --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 73 +++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 4641485..7f33a4a 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -33,14 +33,15 @@ #include "rmw/allocators.h" #include "rmw/convert_rcutils_ret_to_rmw_ret.h" #include "rmw/error_handling.h" -#include "rmw/names_and_types.h" +#include "rmw/event.h" +#include "rmw/get_node_info_and_types.h" #include "rmw/get_service_names_and_types.h" #include "rmw/get_topic_names_and_types.h" -#include "rmw/get_node_info_and_types.h" -#include "rmw/event.h" -#include "rmw/validate_node_name.h" +#include "rmw/incompatible_qos_events_statuses.h" +#include "rmw/names_and_types.h" #include "rmw/rmw.h" #include "rmw/sanity_checks.h" +#include "rmw/validate_node_name.h" #include "Serialization.hpp" #include "rmw/impl/cpp/macros.hpp" @@ -1171,6 +1172,28 @@ static dds_qos_t * create_readwrite_qos( return qos; } +#if RMW_VERSION_GTE(0, 8, 2) +static rmw_qos_policy_kind_t dds_qos_policy_to_rmw_qos_policy(dds_qos_policy_id_t policy_id) +{ + switch (policy_id) { + case DDS_DURABILITY_QOS_POLICY_ID: + return RMW_QOS_POLICY_DURABILITY; + case DDS_DEADLINE_QOS_POLICY_ID: + return RMW_QOS_POLICY_DEADLINE; + case DDS_LIVELINESS_QOS_POLICY_ID: + return RMW_QOS_POLICY_LIVELINESS; + case DDS_RELIABILITY_QOS_POLICY_ID: + return RMW_QOS_POLICY_RELIABILITY; + case DDS_HISTORY_QOS_POLICY_ID: + return RMW_QOS_POLICY_HISTORY; + case DDS_LIFESPAN_QOS_POLICY_ID: + return RMW_QOS_POLICY_LIFESPAN; + default: + return RMW_QOS_POLICY_INVALID; + } +} +#endif + static bool dds_qos_to_rmw_qos(const dds_qos_t * dds_qos, rmw_qos_profile_t * qos_policies) { assert(dds_qos); @@ -1868,6 +1891,10 @@ static const std::unordered_map mask_map{ {RMW_EVENT_REQUESTED_DEADLINE_MISSED, DDS_REQUESTED_DEADLINE_MISSED_STATUS}, {RMW_EVENT_LIVELINESS_LOST, DDS_LIVELINESS_LOST_STATUS}, {RMW_EVENT_OFFERED_DEADLINE_MISSED, DDS_OFFERED_DEADLINE_MISSED_STATUS}, +#if RMW_VERSION_GTE(0, 8, 2) + {RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE, DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS}, + {RMW_EVENT_OFFERED_QOS_INCOMPATIBLE, DDS_OFFERED_INCOMPATIBLE_QOS_STATUS}, +#endif }; static bool is_event_supported(const rmw_event_type_t event_t) @@ -1961,6 +1988,25 @@ extern "C" rmw_ret_t rmw_take_event( } } +#if RMW_VERSION_GTE(0, 8, 2) + case RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE: { + auto ei = static_cast(event_info); + auto sub = static_cast(event_handle->data); + dds_requested_incompatible_qos_status_t st; + if (dds_get_requested_incompatible_qos_status(sub->enth, &st) < 0) { + *taken = false; + return RMW_RET_ERROR; + } else { + ei->total_count = static_cast(st.total_count); + ei->total_count_change = st.total_count_change; + ei->last_policy_kind = dds_qos_policy_to_rmw_qos_policy( + static_cast(st.last_policy_id)); + *taken = true; + return RMW_RET_OK; + } + } +#endif + case RMW_EVENT_LIVELINESS_LOST: { auto ei = static_cast(event_info); auto pub = static_cast(event_handle->data); @@ -1991,6 +2037,25 @@ extern "C" rmw_ret_t rmw_take_event( } } +#if RMW_VERSION_GTE(0, 8, 2) + case RMW_EVENT_OFFERED_QOS_INCOMPATIBLE: { + auto ei = static_cast(event_info); + auto pub = static_cast(event_handle->data); + dds_offered_incompatible_qos_status_t st; + if (dds_get_offered_incompatible_qos_status(pub->enth, &st) < 0) { + *taken = false; + return RMW_RET_ERROR; + } else { + ei->total_count = static_cast(st.total_count); + ei->total_count_change = st.total_count_change; + ei->last_policy_kind = dds_qos_policy_to_rmw_qos_policy( + static_cast(st.last_policy_id)); + *taken = true; + return RMW_RET_OK; + } + } +#endif + case RMW_EVENT_INVALID: { break; } From 12f977f3dfd14c01cf302bfb5704360b24dda765 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sun, 29 Mar 2020 16:19:37 +0200 Subject: [PATCH 4/9] Include incompatible_qos_events_statuses.h only if rmw >= 0.8.2 Signed-off-by: Erik Boasson --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 7f33a4a..7ec15ef 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -37,7 +37,6 @@ #include "rmw/get_node_info_and_types.h" #include "rmw/get_service_names_and_types.h" #include "rmw/get_topic_names_and_types.h" -#include "rmw/incompatible_qos_events_statuses.h" #include "rmw/names_and_types.h" #include "rmw/rmw.h" #include "rmw/sanity_checks.h" @@ -54,6 +53,7 @@ #if RMW_VERSION_GTE(0, 8, 2) #include "rmw/get_topic_endpoint_info.h" +#include "rmw/incompatible_qos_events_statuses.h" #include "rmw/topic_endpoint_info_array.h" #endif From 95cee7d77d5af7afba3eebeaead7f677dc461be8 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Mon, 30 Mar 2020 00:06:31 -0500 Subject: [PATCH 5/9] Add CI with GitHub actions (#130) Especially since we maintain compatibility across multiple ROS versions, which new contributors might not expect, this should help prevent accidental build-breaking. --- .github/workflows/CI.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..0da2097 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,20 @@ +name: ROS2 CI +on: [push, pull_request] +jobs: + build: + strategy: + matrix: + os: [ubuntu-18.04, macOS-latest, windows-latest] + rosdistro: [dashing, eloquent, source] + exclude: # issue in action-ros-ci@0.0.14 + - os: ubuntu-18.04 + rosdistro: source + runs-on: ${{ matrix.os }} + steps: + - uses: ros-tooling/setup-ros@0.0.15 + with: + required-ros-distributions: ${{ matrix.rosdistro }} + - uses: ros-tooling/action-ros-ci@0.0.14 + with: + package-name: rmw_cyclonedds_cpp + From 6effe6bbc016af2f71f10e6c76df57064a17a48d Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Tue, 31 Mar 2020 13:59:56 -0500 Subject: [PATCH 6/9] In CI, always build ROS from source (#133) Binary builds skip silently on non-Linux platforms, so we previously weren't *actually* testing Eloquent and Dashing on Windows and Mac. --- .github/workflows/CI.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0da2097..dd279e1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,18 +3,27 @@ on: [push, pull_request] jobs: build: strategy: + fail-fast: false matrix: os: [ubuntu-18.04, macOS-latest, windows-latest] - rosdistro: [dashing, eloquent, source] - exclude: # issue in action-ros-ci@0.0.14 - - os: ubuntu-18.04 - rosdistro: source + repos-url: + - https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos + - https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos + - https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos + exclude: + # pending https://github.com/ament/ament_cmake/pull/233 + - os: windows-latest + repos-url: https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos + # pending https://github.com/ament/ament_cmake/pull/234 + - os: windows-latest + repos-url: https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos runs-on: ${{ matrix.os }} steps: - - uses: ros-tooling/setup-ros@0.0.15 - with: - required-ros-distributions: ${{ matrix.rosdistro }} - - uses: ros-tooling/action-ros-ci@0.0.14 + - name: Acquire ROS dependencies + uses: ros-tooling/setup-ros@0.0.15 + - name: Build and test ROS + uses: ros-tooling/action-ros-ci@0.0.14 with: package-name: rmw_cyclonedds_cpp + vcs-repo-file-url: ${{ matrix.repos-url }} From 9a4f567c6bcef38d328bf10ace2ff3bff0be598b Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Wed, 1 Apr 2020 04:45:16 -0500 Subject: [PATCH 7/9] Freshen up the readme (#131) --- README.md | 57 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 9e0c15c..1879246 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,36 @@ -# A ROS2 RMW implementation for Eclipse Cyclone DDS +# ROS2 RMW for Eclipse Cyclone DDS -With the code in this repository, it is possible to use [*ROS2*](https://index.ros.org/doc/ros2) -with [*Eclipse Cyclone DDS*](https://github.com/eclipse-cyclonedds/cyclonedds) as the underlying DDS -implementation. +**Easy, fast, reliable, small [Eclipse Cyclone DDS](https://github.com/eclipse-cyclonedds/cyclonedds) middleware** for ROS2. Make your **🐢 run like a 🚀** [Eclipse Cyclone DDS has great adopters](https://iot.eclipse.org/adopters/) and contributors in the ROS community and is an [Eclipse Foundation](https://www.eclipse.org) open source project of [Eclipse IoT](https://iot.eclipse.org) and [OpenADx](https://openadx.eclipse.org) (autonomous driving). -## Getting, building and using it +This package lets [*ROS2*](https://index.ros.org/doc/ros2) use [*Eclipse Cyclone DDS*](https://github.com/eclipse-cyclonedds/cyclonedds) as the underlying DDS implementation. +Cyclone DDS is ready to use. It seeks to give the fastest, easiest, and most robust ROS2 experience. Let the Cyclone blow you away! -All it takes to get Cyclone DDS support into ROS2 is to clone this repository into the ROS2 workspace -source directory, and then run colcon build in the usual manner: +1. Install: - cd ros2_ws/src - git clone https://github.com/ros2/rmw_cyclonedds - git clone https://github.com/eclipse-cyclonedds/cyclonedds - cd .. + ``` + apt install ros-eloquent-rmw-cyclonedds-cpp + ``` + or + ``` + apt install ros-dashing-rmw-cyclonedds-cpp + ``` + +2) Set env variable and run ROS2 apps as usual: + + ```export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp``` + +3) Confirm RMW: In Eloquent, to confirm which RMW you're using: + + ```ros2 doctor --report``` + + +## Building from source and contributing + +Note the `master` branch maintains compatibility with ROS releases Dashing and later, including the not-yet-released [*Foxy*](https://index.ros.org/doc/ros2/Releases/Release-Foxy-Fitzroy/). + +If building ROS2 from source ([ros2.repos](https://github.com/ros2/ros2/blob/master/ros2.repos)), you already have this package and Cyclone DDS: + + cd /opt/ros/master rosdep install --from src -i colcon build export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp - -This seems to work fine on Linux with a binary ROS2 installation as well as when building ROS2 from -source. On macOS it has only been tested in a source build on a machine in an "unsupported" -configuration (macOS 10.14 with SIP enabled, instead of 10.12 with SIP disabled), and apart from a -few details that are caused by the machine configuration, that works fine, too. There is no reason -why it wouldn't work the same on Windows, but I haven't tried. - -If you want to use a pre-existing installation of Cyclone DDS, you don't need to clone it, but you -may have to tell CMake where to look for it using the `CycloneDDS_DIR` variable. That also appears -to be the case if there are other packages in the ROS2 workspace that you would like to use Cyclone -DDS directly instead of via the ROS2 abstraction. - -## Known limitations - -Cyclone DDS doesn't yet implement the DDS Security standard, nor does it fully implement -the Lifespan, Deadline and some of the Liveliness QoS modes. Consequently these features -of ROS2 are also not yet supported when using Cyclone DDS. From 754c7db7fb718dbf151c8d6bc1f618575f35603f Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Wed, 1 Apr 2020 15:21:54 -0500 Subject: [PATCH 8/9] better ci job names (#135) --- .github/workflows/CI.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index dd279e1..69cffb7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,18 +5,15 @@ jobs: strategy: fail-fast: false matrix: + rosdistro: [dashing, eloquent, master] os: [ubuntu-18.04, macOS-latest, windows-latest] - repos-url: - - https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos - - https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos - - https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos exclude: # pending https://github.com/ament/ament_cmake/pull/233 - - os: windows-latest - repos-url: https://raw.githubusercontent.com/ros2/ros2/eloquent/ros2.repos + - rosdistro: eloquent + os: windows-latest # pending https://github.com/ament/ament_cmake/pull/234 - - os: windows-latest - repos-url: https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos + - rosdistro: dashing + os: windows-latest runs-on: ${{ matrix.os }} steps: - name: Acquire ROS dependencies @@ -25,5 +22,4 @@ jobs: uses: ros-tooling/action-ros-ci@0.0.14 with: package-name: rmw_cyclonedds_cpp - vcs-repo-file-url: ${{ matrix.repos-url }} - + vcs-repo-file-url: https://raw.githubusercontent.com/ros2/ros2/${{ matrix.rosdistro }}/ros2.repos From 3b8d2e8ef7de5d0f10a7cdfdab7f8a59a89faa51 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 2 Apr 2020 09:30:28 -0500 Subject: [PATCH 9/9] Add backup apt sources (#134) --- .github/workflows/CI.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 69cffb7..486959c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,6 +16,9 @@ jobs: os: windows-latest runs-on: ${{ matrix.os }} steps: + - if: runner.os == 'Linux' + # azure ubuntu repo can be flaky so add an alternate source + run: sed -e 's/azure.archive.ubuntu.com/us.archive.ubuntu.com/g' -e t -e d /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/nonazure.list - name: Acquire ROS dependencies uses: ros-tooling/setup-ros@0.0.15 - name: Build and test ROS