From caf8876ef7c2e0607d93df3b68a0516ffacc61a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20L=C3=BCtkebohle?= Date: Tue, 18 Apr 2023 08:08:14 +0200 Subject: [PATCH 1/3] Allow overriding the client's domain ID through reference (#331) * Allow overriding the client's domain ID through reference Signed-off-by: Ingo Luetkebohle (CR/AEX3) * Fix type conversion warning on Win32 Signed-off-by: Ingo Luetkebohle (CR/AEX3) --------- Signed-off-by: Ingo Luetkebohle (CR/AEX3) --- include/uxr/agent/middleware/Middleware.hpp | 2 ++ src/cpp/middleware/fast/FastMiddleware.cpp | 8 ++++++-- src/cpp/middleware/fastdds/FastDDSMiddleware.cpp | 16 ++++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/uxr/agent/middleware/Middleware.hpp b/include/uxr/agent/middleware/Middleware.hpp index b6e800250..419dbb3df 100644 --- a/include/uxr/agent/middleware/Middleware.hpp +++ b/include/uxr/agent/middleware/Middleware.hpp @@ -25,6 +25,8 @@ #include #include +#define UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF (255) + namespace eprosima { namespace uxr { diff --git a/src/cpp/middleware/fast/FastMiddleware.cpp b/src/cpp/middleware/fast/FastMiddleware.cpp index d80ac4b7b..e8c4afd0a 100644 --- a/src/cpp/middleware/fast/FastMiddleware.cpp +++ b/src/cpp/middleware/fast/FastMiddleware.cpp @@ -49,7 +49,9 @@ bool FastMiddleware::create_participant_by_ref( fastrtps::ParticipantAttributes attrs; if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(ref, attrs)) { - attrs.domainId = uint32_t(domain_id); + if(domain_id != UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF) { + attrs.domainId = domain_id; + } fastrtps::Participant* impl = fastrtps::Domain::createParticipant(attrs, &listener_); if (nullptr != impl) { @@ -773,7 +775,9 @@ bool FastMiddleware::matched_participant_from_ref( fastrtps::ParticipantAttributes attrs; if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(ref, attrs)) { - attrs.domainId = uint32_t(domain_id); + if(domain_id != UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF) { + attrs.domainId = domain_id; + } rv = it->second->match(attrs); } } diff --git a/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp b/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp index 4656dae5a..b90e6ff1f 100644 --- a/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp +++ b/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp @@ -62,7 +62,13 @@ bool FastDDSMiddleware::create_participant_by_ref( const std::string& ref) { bool rv = false; - std::shared_ptr participant(new FastDDSParticipant(domain_id)); + fastrtps::ParticipantAttributes attrs; + auto participant_domain_id = domain_id; + if(domain_id == UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF && XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(ref, attrs)) + { + participant_domain_id = static_cast(attrs.domainId); + } + std::shared_ptr participant(new FastDDSParticipant(participant_domain_id)); if (participant->create_by_ref(ref)) { auto emplace_res = participants_.emplace(participant_id, std::move(participant)); @@ -986,7 +992,13 @@ bool FastDDSMiddleware::matched_participant_from_ref( auto it = participants_.find(participant_id); if (participants_.end() != it) { - rv = (domain_id == it->second->domain_id()) && (it->second->match_from_ref(ref)); + fastrtps::ParticipantAttributes attrs; + auto participant_domain_id = domain_id; + if(domain_id == UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF && XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(ref, attrs)) + { + participant_domain_id = static_cast(attrs.domainId); + } + rv = (participant_domain_id== it->second->domain_id()) && (it->second->match_from_ref(ref)); } return rv; } From bd6ea2c4412256d38f8d1f222c8949234659c205 Mon Sep 17 00:00:00 2001 From: Jakub Delicat <109142865+delihus@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:19:52 +0300 Subject: [PATCH 2/3] Override domain_id with ROS_DOMAIN_ID provided by the agent (#333) * override domain_id with agent_domain_id from env Signed-off-by: Jakub Delicat * fix windows casting Signed-off-by: Jakub Delicat * trigger build Signed-off-by: Jakub Delicat * read XRCE_DOMAIN_ID_OVERRIDE global env Signed-off-by: Jakub Delicat --------- Signed-off-by: Jakub Delicat --- include/uxr/agent/middleware/Middleware.hpp | 3 +- .../middleware/fastdds/FastDDSMiddleware.hpp | 3 ++ .../middleware/fastdds/FastDDSMiddleware.cpp | 30 ++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/include/uxr/agent/middleware/Middleware.hpp b/include/uxr/agent/middleware/Middleware.hpp index 419dbb3df..d3b89786e 100644 --- a/include/uxr/agent/middleware/Middleware.hpp +++ b/include/uxr/agent/middleware/Middleware.hpp @@ -26,6 +26,7 @@ #include #define UXR_CLIENT_DOMAIN_ID_TO_USE_FROM_REF (255) +#define UXR_CLIENT_DOMAIN_ID_TO_OVERRIDE_WITH_ENV (255) namespace eprosima { namespace uxr { @@ -298,7 +299,7 @@ class Middleware /********************************************************************************************************************** * Members. **********************************************************************************************************************/ -protected: +protected: bool intraprocess_enabled_; }; diff --git a/include/uxr/agent/middleware/fastdds/FastDDSMiddleware.hpp b/include/uxr/agent/middleware/fastdds/FastDDSMiddleware.hpp index a1ae2f497..e69519378 100644 --- a/include/uxr/agent/middleware/fastdds/FastDDSMiddleware.hpp +++ b/include/uxr/agent/middleware/fastdds/FastDDSMiddleware.hpp @@ -284,6 +284,9 @@ class FastDDSMiddleware : public Middleware std::shared_ptr& participant, const fastrtps::ReplierAttributes& attrs); + int16_t get_domain_id_from_env(); + + int16_t agent_domain_id_ = 0; std::unordered_map> participants_; std::unordered_map> topics_; std::unordered_map> publishers_; diff --git a/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp b/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp index b90e6ff1f..ab6259c09 100644 --- a/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp +++ b/src/cpp/middleware/fastdds/FastDDSMiddleware.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -51,6 +52,14 @@ FastDDSMiddleware::FastDDSMiddleware(bool intraprocess_enabled) , repliers_() , callback_factory_(callback_factory_.getInstance()) { + agent_domain_id_ = get_domain_id_from_env(); + if (agent_domain_id_) + { + UXR_AGENT_LOG_INFO( + UXR_DECORATE_GREEN("Micro XRCE-DDS Agent DOMAIN_ID read from env"), + "domain_id: {}", agent_domain_id_); + } + } /********************************************************************************************************************** @@ -108,8 +117,17 @@ bool FastDDSMiddleware::create_participant_by_bin( uint16_t participant_id, const dds::xrce::OBJK_DomainParticipant_Binary& participant_xrce) { + auto participant_domain_id = static_cast(participant_xrce.domain_id()); + if(participant_domain_id == UXR_CLIENT_DOMAIN_ID_TO_OVERRIDE_WITH_ENV){ + participant_domain_id = agent_domain_id_; + UXR_AGENT_LOG_WARN( + UXR_DECORATE_YELLOW("Overriding Micro XRCE-DDS Client DOMAIN_ID"), + "domain_id: {}", participant_domain_id + ); + } + bool rv = false; - std::shared_ptr participant(new FastDDSParticipant((int16_t) participant_xrce.domain_id())); + std::shared_ptr participant(new FastDDSParticipant(participant_domain_id)); if (participant->create_by_bin(participant_xrce)) { auto emplace_res = participants_.emplace(participant_id, std::move(participant)); @@ -1242,5 +1260,15 @@ bool FastDDSMiddleware::matched_replier_from_bin( return rv; } +int16_t FastDDSMiddleware::get_domain_id_from_env(){ + int16_t agent_domain_id = 0; + const char * agent_domain_id_env = std::getenv( "XRCE_DOMAIN_ID_OVERRIDE" ); + if (nullptr != agent_domain_id_env) + { + agent_domain_id = static_cast(std::atoi(agent_domain_id_env)); + } + return agent_domain_id; +} + } // namespace uxr } // namespace eprosima \ No newline at end of file From f3f704e3b48603e67fc4c12dd6ac3606f1f96a02 Mon Sep 17 00:00:00 2001 From: acuadros95 Date: Mon, 10 Jul 2023 10:44:53 +0200 Subject: [PATCH 3/3] Bump version Signed-off-by: acuadros95 --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69bb87d1f..9c46afc55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ option(UAGENT_SECURITY_PROFILE "Build security profile." OFF) option(UAGENT_BUILD_EXECUTABLE "Build Micro XRCE-DDS Agent provided executable." ON) option(UAGENT_BUILD_USAGE_EXAMPLES "Build Micro XRCE-DDS Agent built-in usage examples" OFF) -set(UAGENT_P2P_CLIENT_VERSION 2.4.0 CACHE STRING "Sets Micro XRCE-DDS client version for P2P") -set(UAGENT_P2P_CLIENT_TAG v2.4.0 CACHE STRING "Sets Micro XRCE-DDS client tag for P2P") +set(UAGENT_P2P_CLIENT_VERSION 2.4.1 CACHE STRING "Sets Micro XRCE-DDS client version for P2P") +set(UAGENT_P2P_CLIENT_TAG v2.4.1 CACHE STRING "Sets Micro XRCE-DDS client tag for P2P") option(UAGENT_BUILD_CI_TESTS "Build CI test cases.") if(UAGENT_BUILD_CI_TESTS) @@ -80,8 +80,8 @@ set(_deps "") if(UAGENT_USE_SYSTEM_FASTCDR) set(_fastcdr_version 1) else() - set(_fastcdr_version 1.0.27) - set(_fastcdr_tag v1.0.27) + set(_fastcdr_version 1.1.0) + set(_fastcdr_tag v1.1.0) endif() list(APPEND _deps "fastcdr\;${_fastcdr_version}") @@ -95,8 +95,8 @@ if(UAGENT_FAST_PROFILE) if(UAGENT_USE_SYSTEM_FASTDDS) set(_fastdds_version 2) else() - set(_fastdds_version 2.10) - set(_fastdds_tag 2.10.x) + set(_fastdds_version 2.11) + set(_fastdds_tag 2.11.x) set(_foonathan_memory_tag v0.7-3) # This tag should be updated every time it gets updated in foonathan_memory_vendor eProsima's package endif() list(APPEND _deps "fastrtps\;${_fastdds_version}") @@ -117,7 +117,7 @@ endif() ############################################################################### set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) if(NOT UAGENT_SUPERBUILD) - project(microxrcedds_agent VERSION "2.4.0" LANGUAGES C CXX) + project(microxrcedds_agent VERSION "2.4.1" LANGUAGES C CXX) else() project(uagent_superbuild NONE) include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)