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) diff --git a/include/uxr/agent/middleware/Middleware.hpp b/include/uxr/agent/middleware/Middleware.hpp index b6e800250..d3b89786e 100644 --- a/include/uxr/agent/middleware/Middleware.hpp +++ b/include/uxr/agent/middleware/Middleware.hpp @@ -25,6 +25,9 @@ #include #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 { @@ -296,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/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..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_); + } + } /********************************************************************************************************************** @@ -62,7 +71,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)); @@ -102,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)); @@ -986,7 +1010,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; } @@ -1230,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