From 5bc4d7c40fb9842169019e792b37f019a68d6aa2 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:36:22 +0000 Subject: [PATCH 01/13] rmw_fastrtps_shared: adapt shared type support Signed-off-by: Mario Dominguez --- .../rmw_fastrtps_shared_cpp/TypeSupport.hpp | 20 +++++-- .../src/TypeSupport_impl.cpp | 53 +++++++++++++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index df370b0f5..1a60bdcab 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -25,6 +25,7 @@ #include "fastcdr/FastBuffer.h" #include "fastcdr/Cdr.h" +#include "fastrtps/utils/md5.h" #include "rcutils/logging_macros.h" @@ -61,15 +62,14 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType virtual bool deserializeROSmessage( eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const = 0; + virtual bool get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const = 0; + RMW_FASTRTPS_SHARED_CPP_PUBLIC bool getKey( void * data, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, - bool force_md5 = false) override - { - (void)data; (void)ihandle; (void)force_md5; - return false; - } + bool force_md5 = false) override; RMW_FASTRTPS_SHARED_CPP_PUBLIC bool serialize(void * data, eprosima::fastrtps::rtps::SerializedPayload_t * payload) override; @@ -110,6 +110,12 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType return is_plain_ && rep == eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION; } + RMW_FASTRTPS_SHARED_CPP_PUBLIC + inline bool is_key_unbounded() const + { + return key_is_unbounded_; + } + RMW_FASTRTPS_SHARED_CPP_PUBLIC virtual ~TypeSupport() {} @@ -119,6 +125,10 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType bool max_size_bound_; bool is_plain_; + bool key_is_unbounded_; + mutable size_t key_max_serialized_size_; + mutable MD5 md5_; + mutable std::vector key_buffer_; }; RMW_FASTRTPS_SHARED_CPP_PUBLIC diff --git a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp index 62f8cc24f..00cedab09 100644 --- a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp +++ b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp @@ -64,6 +64,59 @@ void * TypeSupport::createData() return new eprosima::fastcdr::FastBuffer(); } +bool TypeSupport::getKey( + void * data, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5) +{ + assert(data); + + bool ret = false; + + if (!m_isGetKeyDefined) + { + return ret; + } + + auto ser_data = static_cast(data); + + switch (ser_data->type) + { + case FASTRTPS_SERIALIZED_DATA_TYPE_ROS_MESSAGE: + { + ret = this->get_key_hash_from_ros_message(ser_data->data, ihandle, force_md5, ser_data->impl); + break; + } + + case FASTRTPS_SERIALIZED_DATA_TYPE_CDR_BUFFER: + { + // TODO + // We would need a get_key_hash_from_payload method + break; + } + + case FASTRTPS_SERIALIZED_DATA_TYPE_DYNAMIC_MESSAGE: + { + + auto m_type = std::make_shared(); + + // Retrieves the key (ihandle) from the dynamic data stored in data->data + return m_type->getKey( + static_cast(ser_data->data), + ihandle, + force_md5); + + break; + } + default: + { + break; + } + } + + return ret; +} + bool TypeSupport::serialize( void * data, eprosima::fastrtps::rtps::SerializedPayload_t * payload) { From 83295dfa653f4430bb8812dda936bd8920df62f0 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:37:56 +0000 Subject: [PATCH 02/13] rmw_fastrtps_cpp: update type support and implementation for keys adoption Signed-off-by: Mario Dominguez --- .../include/rmw_fastrtps_cpp/TypeSupport.hpp | 4 ++ rmw_fastrtps_cpp/src/type_support_common.cpp | 72 +++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp index 6323ca35a..01763d0e2 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp @@ -42,6 +42,9 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport bool deserializeROSmessage( eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; + bool get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; + TypeSupport(); protected: @@ -49,6 +52,7 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport private: const message_type_support_callbacks_t * members_; + const message_type_support_key_callbacks_t* key_callbacks_; bool has_data_; }; diff --git a/rmw_fastrtps_cpp/src/type_support_common.cpp b/rmw_fastrtps_cpp/src/type_support_common.cpp index eb3d38232..4d25848ed 100644 --- a/rmw_fastrtps_cpp/src/type_support_common.cpp +++ b/rmw_fastrtps_cpp/src/type_support_common.cpp @@ -28,6 +28,11 @@ TypeSupport::TypeSupport() m_isGetKeyDefined = false; max_size_bound_ = false; is_plain_ = false; + key_is_unbounded_ = false; + key_max_serialized_size_ = 0; + members_ = nullptr; + key_callbacks_ = nullptr; + has_data_ = false; } void TypeSupport::set_members(const message_type_support_callbacks_t * members) @@ -57,6 +62,18 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members) m_typeSize = 4 + data_size; // Account for RTPS submessage alignment m_typeSize = (m_typeSize + 3) & ~3; + + if (nullptr != members->key_callbacks) + { + key_callbacks_ = members->key_callbacks; + m_isGetKeyDefined = true; + + key_max_serialized_size_ = key_callbacks_->max_serialized_size_key(key_is_unbounded_); + if (!key_is_unbounded_) + { + key_buffer_.reserve(key_max_serialized_size_); + } + } } size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const void * impl) const @@ -129,6 +146,61 @@ bool TypeSupport::deserializeROSmessage( return true; } +bool TypeSupport::get_key_hash_from_ros_message( + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5, + const void * impl) const +{ + assert(ros_message); + (void)impl; + + // retrieve estimated serialized size in case key is unbounded + if (key_is_unbounded_) + { + key_max_serialized_size_ = (std::max) ( + key_max_serialized_size_, + key_callbacks_->get_serialized_size_key(ros_message)); + key_buffer_.reserve(key_max_serialized_size_); + } + + eprosima::fastcdr::FastBuffer fast_buffer( + reinterpret_cast(key_buffer_.data()), + key_max_serialized_size_); + + eprosima::fastcdr::Cdr ser( + fast_buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::CdrVersion::XCDRv1); + + key_callbacks_->cdr_serialize_key(ros_message, ser); + + const size_t max_serialized_key_length = 16; + + auto ser_length = ser.get_serialized_data_length(); + + // check for md5 + if (force_md5 || key_max_serialized_size_ > max_serialized_key_length) + { + md5_.init(); + md5_.update(key_buffer_.data(), static_cast(ser_length)); + md5_.finalize(); + + for (uint8_t i = 0; i < max_serialized_key_length; ++i) + { + ihandle->value[i] = md5_.digest[i]; + } + } + else + { + memset(ihandle->value, 0, max_serialized_key_length); + for (uint8_t i = 0; i < ser_length; ++i) + { + ihandle->value[i] = key_buffer_[i]; + } + } + + return true; +} + MessageTypeSupport::MessageTypeSupport(const message_type_support_callbacks_t * members) { assert(members); From 36411eb5e99834dba7271aeeed0d1490c5b6e1f4 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:38:43 +0000 Subject: [PATCH 03/13] rmw_fastrtps_dynamic_cpp: update type support and implementation for keys adoption Signed-off-by: Mario Dominguez --- .../src/MessageTypeSupport_impl.hpp | 8 + .../src/ServiceTypeSupport_impl.hpp | 16 ++ rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp | 41 +++++ .../src/TypeSupport_impl.hpp | 163 +++++++++++++++++- .../src/type_support_proxy.cpp | 9 + 5 files changed, 232 insertions(+), 5 deletions(-) diff --git a/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp index c56945ae1..d039fae5a 100644 --- a/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp @@ -60,6 +60,14 @@ MessageTypeSupport::MessageTypeSupport( } else { this->m_typeSize++; } + + if (this->members_->has_any_key_member_) + { + this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(members); + this->m_isGetKeyDefined = true; + this->key_buffer_.reserve(this->key_max_serialized_size_); + } + // Account for RTPS submessage alignment this->m_typeSize = (this->m_typeSize + 3) & ~3; } diff --git a/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp index b7152480a..d6cb98a07 100644 --- a/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp @@ -59,6 +59,14 @@ RequestTypeSupport::RequestTypeSupport( } else { this->m_typeSize++; } + + if (this->members_->has_any_key_member_) + { + this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(this->members_); + this->m_isGetKeyDefined = true; + this->key_buffer_.reserve(this->key_max_serialized_size_); + } + // Account for RTPS submessage alignment this->m_typeSize = (this->m_typeSize + 3) & ~3; } @@ -92,6 +100,14 @@ ResponseTypeSupport::ResponseTypeSupport } else { this->m_typeSize++; } + + if (this->members_->has_any_key_member_) + { + this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(this->members_); + this->m_isGetKeyDefined = true; + this->key_buffer_.reserve(this->key_max_serialized_size_); + } + // Account for RTPS submessage alignment this->m_typeSize = (this->m_typeSize + 3) & ~3; } diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp index 627e4d5c2..053375562 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp @@ -138,6 +138,9 @@ class TypeSupportProxy : public rmw_fastrtps_shared_cpp::TypeSupport bool deserializeROSmessage( eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; + + bool get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; }; class BaseTypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport @@ -170,28 +173,66 @@ class TypeSupport : public BaseTypeSupport bool deserializeROSmessage( eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; + bool get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; + protected: explicit TypeSupport(const void * ros_type_support); size_t calculateMaxSerializedSize(const MembersType * members, size_t current_alignment); + size_t calculateMaxSerializedKeySize(const MembersType * members); const MembersType * members_; private: + + size_t calculateMaxSerializedSize( + const MembersType * members, + size_t current_alignment, + bool compute_key, + bool& is_key_unbounded); + size_t getEstimatedSerializedSize( const MembersType * members, const void * ros_message, size_t current_alignment) const; + size_t getEstimatedSerializedKeySize( + const MembersType * members, + const void * ros_message) const; + + size_t getEstimatedSerializedSize( + const MembersType * members, + const void * ros_message, + size_t current_alignment, + bool compute_key) const; + bool serializeROSmessage( eprosima::fastcdr::Cdr & ser, const MembersType * members, const void * ros_message) const; + bool serializeKeyROSmessage( + eprosima::fastcdr::Cdr & ser, + const MembersType * members, + const void * ros_message) const; + + bool serializeROSmessage( + eprosima::fastcdr::Cdr & ser, + const MembersType * members, + const void * ros_message, + bool compute_key) const; + bool deserializeROSmessage( eprosima::fastcdr::Cdr & deser, const MembersType * members, void * ros_message) const; + + bool get_key_hash_from_ros_message( + const MembersType * members, + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5) const; }; } // namespace rmw_fastrtps_dynamic_cpp diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp index 142648fbf..48a9e0b8a 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp @@ -65,6 +65,7 @@ TypeSupport::TypeSupport(const void * ros_type_support) m_isGetKeyDefined = false; max_size_bound_ = false; is_plain_ = false; + key_is_unbounded_ = false; } // C++ specialization @@ -196,12 +197,37 @@ bool TypeSupport::serializeROSmessage( eprosima::fastcdr::Cdr & ser, const MembersType * members, const void * ros_message) const +{ + return serializeROSmessage(ser, members, ros_message, false); +} + +template +bool TypeSupport::serializeKeyROSmessage( + eprosima::fastcdr::Cdr & ser, + const MembersType * members, + const void * ros_message) const +{ + return serializeROSmessage(ser, members, ros_message, true); +} + +template +bool TypeSupport::serializeROSmessage( + eprosima::fastcdr::Cdr & ser, + const MembersType * members, + const void * ros_message, + bool compute_key) const { assert(members); assert(ros_message); for (uint32_t i = 0; i < members->member_count_; ++i) { const auto member = members->members_ + i; + + if (compute_key && !member->is_key_ && members->has_any_key_member_) + { + continue; + } + void * field = const_cast(static_cast(ros_message)) + member->offset_; switch (member->type_id_) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOL: @@ -255,7 +281,7 @@ bool TypeSupport::serializeROSmessage( { auto sub_members = static_cast(member->members_->data); if (!member->is_array_) { - serializeROSmessage(ser, sub_members, field); + serializeROSmessage(ser, sub_members, field, compute_key); } else { size_t array_size = 0; @@ -277,7 +303,7 @@ bool TypeSupport::serializeROSmessage( return false; } for (size_t index = 0; index < array_size; ++index) { - serializeROSmessage(ser, sub_members, member->get_function(field, index)); + serializeROSmessage(ser, sub_members, member->get_function(field, index), compute_key); } } } @@ -290,6 +316,58 @@ bool TypeSupport::serializeROSmessage( return true; } +template +bool TypeSupport::get_key_hash_from_ros_message( + const MembersType * members, + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5) const +{ + assert(members); + assert(ros_message); + + // get estimated serialized size in case key is unbounded + if (this->key_is_unbounded_) + { + this->key_max_serialized_size_ = this->getEstimatedSerializedKeySize(members, ros_message); + key_buffer_.reserve(this->key_max_serialized_size_); + } + + eprosima::fastcdr::FastBuffer buffer( + reinterpret_cast(this->key_buffer_.data()), + this->key_max_serialized_size_); + + eprosima::fastcdr::Cdr ser( + buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::CdrVersion::XCDRv1); + + // serialize + serializeKeyROSmessage(ser, members_, ros_message); + + // check for md5 + if (force_md5 || this->key_max_serialized_size_ > 16) + { + md5_.init(); + + md5_.update(this->key_buffer_.data(), static_cast(ser.get_serialized_data_length())); + + md5_.finalize(); + + for (uint8_t i = 0; i < 16; ++i) + { + ihandle->value[i] = md5_.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + ihandle->value[i] = this->key_buffer_[i]; + } + } + + return true; +} + // C++ specialization template size_t next_field_align( @@ -459,6 +537,24 @@ size_t TypeSupport::getEstimatedSerializedSize( const MembersType * members, const void * ros_message, size_t current_alignment) const +{ + return getEstimatedSerializedSize(members, ros_message, current_alignment, false); +} + +template +size_t TypeSupport::getEstimatedSerializedKeySize( + const MembersType * members, + const void * ros_message) const +{ + return getEstimatedSerializedSize(members, ros_message, 0, true); +} + +template +size_t TypeSupport::getEstimatedSerializedSize( + const MembersType * members, + const void * ros_message, + size_t current_alignment, + bool compute_key) const { assert(members); assert(ros_message); @@ -468,6 +564,12 @@ size_t TypeSupport::getEstimatedSerializedSize( for (uint32_t i = 0; i < members->member_count_; ++i) { const auto member = members->members_ + i; void * field = const_cast(static_cast(ros_message)) + member->offset_; + + if (compute_key && !member->is_key_ && members->has_any_key_member_) + { + continue; + } + switch (member->type_id_) { case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_BOOL: current_alignment = next_field_align(member, field, current_alignment); @@ -514,7 +616,7 @@ size_t TypeSupport::getEstimatedSerializedSize( { auto sub_members = static_cast(member->members_->data); if (!member->is_array_) { - current_alignment += getEstimatedSerializedSize(sub_members, field, current_alignment); + current_alignment += getEstimatedSerializedSize(sub_members, field, current_alignment, compute_key); } else { size_t array_size = 0; @@ -539,7 +641,8 @@ size_t TypeSupport::getEstimatedSerializedSize( current_alignment += getEstimatedSerializedSize( sub_members, member->get_function(field, index), - current_alignment); + current_alignment, + compute_key); } } } @@ -801,6 +904,24 @@ bool TypeSupport::deserializeROSmessage( template size_t TypeSupport::calculateMaxSerializedSize( const MembersType * members, size_t current_alignment) +{ + bool is_key_unbounded{false}; //unused + return calculateMaxSerializedSize(members, current_alignment, false, is_key_unbounded); +} + +template +size_t TypeSupport::calculateMaxSerializedKeySize( + const MembersType * members) +{ + return calculateMaxSerializedSize(members, 0, true, this->key_is_unbounded_); +} + +template +size_t TypeSupport::calculateMaxSerializedSize( + const MembersType * members, + size_t current_alignment, + bool compute_key, + bool& is_key_unbounded) { assert(members); @@ -813,6 +934,12 @@ size_t TypeSupport::calculateMaxSerializedSize( const auto * member = members->members_ + i; size_t array_size = 1; + + if (compute_key && !member->is_key_ && members->has_any_key_member_) + { + continue; + } + if (member->is_array_) { array_size = member->array_size_; @@ -864,6 +991,13 @@ size_t TypeSupport::calculateMaxSerializedSize( { this->max_size_bound_ = false; this->is_plain_ = false; + + if (compute_key) + { + std::cout << "Setting is key unbounded !" << std::endl; + is_key_unbounded = true; + } + size_t character_size = (member->type_id_ == rosidl_typesupport_introspection_cpp::ROS_TYPE_WSTRING) ? 4 : 1; size_t extra_char = @@ -879,7 +1013,7 @@ size_t TypeSupport::calculateMaxSerializedSize( { auto sub_members = static_cast(member->members_->data); for (size_t index = 0; index < array_size; ++index) { - size_t curr = calculateMaxSerializedSize(sub_members, current_alignment); + size_t curr = calculateMaxSerializedSize(sub_members, current_alignment, compute_key, is_key_unbounded); current_alignment += curr; last_member_size += curr; } @@ -979,6 +1113,25 @@ bool TypeSupport::deserializeROSmessage( return true; } +template +bool TypeSupport::get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const +{ + + assert(ros_message); + assert(members_); + + bool ret = false; + + (void)impl; + if (members_->member_count_ != 0) + { + ret = TypeSupport::get_key_hash_from_ros_message(members_, ros_message, ihandle, force_md5); + } + + return ret; +} + } // namespace rmw_fastrtps_dynamic_cpp #endif // TYPESUPPORT_IMPL_HPP_ diff --git a/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp b/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp index f4924c7a4..99a5f7b07 100644 --- a/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp @@ -23,6 +23,8 @@ TypeSupportProxy::TypeSupportProxy(rmw_fastrtps_shared_cpp::TypeSupport * inner_ m_typeSize = inner_type->m_typeSize; is_plain_ = inner_type->is_plain(); max_size_bound_ = inner_type->is_bounded(); + m_isGetKeyDefined = inner_type->m_isGetKeyDefined; + key_is_unbounded_ = inner_type->is_key_unbounded(); } size_t TypeSupportProxy::getEstimatedSerializedSize( @@ -46,4 +48,11 @@ bool TypeSupportProxy::deserializeROSmessage( return type_impl->deserializeROSmessage(deser, ros_message, impl); } +bool TypeSupportProxy::get_key_hash_from_ros_message( + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const +{ + auto type_impl = static_cast(impl); + return type_impl->get_key_hash_from_ros_message(ros_message, ihandle, force_md5, impl); +} + } // namespace rmw_fastrtps_dynamic_cpp From b7f72351efd8a0743e5fb269bd341cbf27028b90 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:40:02 +0000 Subject: [PATCH 04/13] rmw_fastrtps_shared_cpp: new apply_qos_resource_limits_for_keys() Signed-off-by: Mario Dominguez --- .../include/rmw_fastrtps_shared_cpp/utils.hpp | 15 +++++++++++++++ rmw_fastrtps_shared_cpp/src/utils.cpp | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp index 67f1a5ad6..f4c9b1c81 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp @@ -126,6 +126,21 @@ create_datareader( CustomDataReaderListener * listener, eprosima::fastdds::dds::DataReader ** data_reader); +/** +* Apply specific resource limits when using keys. +* Max samples per instance is set to history depth if KEEP_LAST +* else UNLIMITED. +* +* \param[in] hitory_qos History entitiy QoS. +* \param[in, out] res_limits_qos Resource limits entitiy QoS. +* +*/ +RMW_FASTRTPS_SHARED_CPP_PUBLIC +void +apply_qos_resource_limits_for_keys( + const eprosima::fastdds::dds::HistoryQosPolicy & history_qos, + eprosima::fastdds::dds::ResourceLimitsQosPolicy & res_limits_qos); + } // namespace rmw_fastrtps_shared_cpp #endif // RMW_FASTRTPS_SHARED_CPP__UTILS_HPP_ diff --git a/rmw_fastrtps_shared_cpp/src/utils.cpp b/rmw_fastrtps_shared_cpp/src/utils.cpp index 47429680a..ba5d4eec3 100644 --- a/rmw_fastrtps_shared_cpp/src/utils.cpp +++ b/rmw_fastrtps_shared_cpp/src/utils.cpp @@ -184,5 +184,21 @@ create_datareader( return true; } +void +apply_qos_resource_limits_for_keys( + const eprosima::fastdds::dds::HistoryQosPolicy & history_qos, + eprosima::fastdds::dds::ResourceLimitsQosPolicy & res_limits_qos) +{ + res_limits_qos.max_instances = 0; + res_limits_qos.max_samples = 0; + if (history_qos.kind == eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS) + { + res_limits_qos.max_samples_per_instance = history_qos.depth; + } + else + { + res_limits_qos.max_samples_per_instance = 0; + } +} } // namespace rmw_fastrtps_shared_cpp From 37ef330637ef4474529df51abe88ea6a6d591314 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:40:43 +0000 Subject: [PATCH 05/13] rmw_fastrtps_cpp: add apply_qos_resource_limits_for_keys() Signed-off-by: Mario Dominguez --- rmw_fastrtps_cpp/src/publisher.cpp | 9 +++++++++ rmw_fastrtps_cpp/src/rmw_client.cpp | 18 ++++++++++++++++++ rmw_fastrtps_cpp/src/rmw_service.cpp | 18 ++++++++++++++++++ rmw_fastrtps_cpp/src/subscription.cpp | 18 ++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/rmw_fastrtps_cpp/src/publisher.cpp b/rmw_fastrtps_cpp/src/publisher.cpp index c16db932d..202163d0c 100644 --- a/rmw_fastrtps_cpp/src/publisher.cpp +++ b/rmw_fastrtps_cpp/src/publisher.cpp @@ -264,6 +264,15 @@ rmw_fastrtps_cpp::create_publisher( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter with a mask enabling publication_matched calls for the listener info->data_writer_ = publisher->create_datawriter( info->topic_, diff --git a/rmw_fastrtps_cpp/src/rmw_client.cpp b/rmw_fastrtps_cpp/src/rmw_client.cpp index d94ae4859..101462dee 100644 --- a/rmw_fastrtps_cpp/src/rmw_client.cpp +++ b/rmw_fastrtps_cpp/src/rmw_client.cpp @@ -323,6 +323,15 @@ rmw_create_client( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (response_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + // Creates DataReader info->response_reader_ = subscriber->create_datareader( response_topic_desc, @@ -381,6 +390,15 @@ rmw_create_client( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (request_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter with a mask enabling publication_matched calls for the listener info->request_writer_ = publisher->create_datawriter( info->request_topic_, diff --git a/rmw_fastrtps_cpp/src/rmw_service.cpp b/rmw_fastrtps_cpp/src/rmw_service.cpp index 118b4e2f9..3d2b9492f 100644 --- a/rmw_fastrtps_cpp/src/rmw_service.cpp +++ b/rmw_fastrtps_cpp/src/rmw_service.cpp @@ -322,6 +322,15 @@ rmw_create_service( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (request_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + // Creates DataReader info->request_reader_ = subscriber->create_datareader( request_topic_desc, @@ -384,6 +393,15 @@ rmw_create_service( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (response_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter with a mask enabling publication_matched calls for the listener info->response_writer_ = publisher->create_datawriter( info->response_topic_, diff --git a/rmw_fastrtps_cpp/src/subscription.cpp b/rmw_fastrtps_cpp/src/subscription.cpp index 2375f45cb..471e72916 100644 --- a/rmw_fastrtps_cpp/src/subscription.cpp +++ b/rmw_fastrtps_cpp/src/subscription.cpp @@ -392,6 +392,15 @@ __create_dynamic_subscription( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + info->datareader_qos_ = reader_qos; // create_datareader @@ -659,6 +668,15 @@ __create_subscription( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + info->datareader_qos_ = reader_qos; // create_datareader From ef98a3d4e7867ecd8bd8cc01aea2e845ede1f7dc Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 26 Mar 2024 15:40:57 +0000 Subject: [PATCH 06/13] rmw_fastrtps_dynamic_cpp: add apply_qos_resource_limits_for_keys() Signed-off-by: Mario Dominguez --- rmw_fastrtps_dynamic_cpp/src/publisher.cpp | 9 +++++++++ rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp | 18 ++++++++++++++++++ rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp | 18 ++++++++++++++++++ rmw_fastrtps_dynamic_cpp/src/subscription.cpp | 9 +++++++++ 4 files changed, 54 insertions(+) diff --git a/rmw_fastrtps_dynamic_cpp/src/publisher.cpp b/rmw_fastrtps_dynamic_cpp/src/publisher.cpp index 6d597abe7..377e26bf5 100644 --- a/rmw_fastrtps_dynamic_cpp/src/publisher.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/publisher.cpp @@ -272,6 +272,15 @@ rmw_fastrtps_dynamic_cpp::create_publisher( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter (with publisher name to not change name policy) info->data_writer_ = publisher->create_datawriter( info->topic_, diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp index d8626b54c..54db1bf84 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp @@ -354,6 +354,15 @@ rmw_create_client( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (response_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + // Creates DataReader info->response_reader_ = subscriber->create_datareader( response_topic_desc, @@ -412,6 +421,15 @@ rmw_create_client( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (request_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter info->request_writer_ = publisher->create_datawriter( info->request_topic_, diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp index 4e1fe8341..495bf989b 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp @@ -353,6 +353,15 @@ rmw_create_service( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (request_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + // Creates DataReader info->request_reader_ = subscriber->create_datareader( request_topic_desc, @@ -415,6 +424,15 @@ rmw_create_service( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (response_fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + writer_qos.history(), + writer_qos.resource_limits()); + } + // Creates DataWriter info->response_writer_ = publisher->create_datawriter( info->response_topic_, diff --git a/rmw_fastrtps_dynamic_cpp/src/subscription.cpp b/rmw_fastrtps_dynamic_cpp/src/subscription.cpp index c3d3433e3..28da07c3d 100644 --- a/rmw_fastrtps_dynamic_cpp/src/subscription.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/subscription.cpp @@ -276,6 +276,15 @@ create_subscription( return nullptr; } + // Apply resource limits QoS if the type is keyed + if (fastdds_type->m_isGetKeyDefined && + !participant_info->leave_middleware_default_qos) + { + rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( + reader_qos.history(), + reader_qos.resource_limits()); + } + eprosima::fastdds::dds::DataReaderQos original_qos = reader_qos; switch (subscription_options->require_unique_network_flow_endpoints) { default: From 2a97541e41ea35ae948b63fb36040f67600e7e29 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Mon, 1 Apr 2024 10:10:38 +0000 Subject: [PATCH 07/13] Apply review changes Signed-off-by: Mario Dominguez --- rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp | 2 +- rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp | 3 +-- .../include/rmw_fastrtps_shared_cpp/TypeSupport.hpp | 1 + rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp index 01763d0e2..62f71c3ef 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp @@ -52,7 +52,7 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport private: const message_type_support_callbacks_t * members_; - const message_type_support_key_callbacks_t* key_callbacks_; + const message_type_support_key_callbacks_t * key_callbacks_; bool has_data_; }; diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp index 48a9e0b8a..ec38ae2e3 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp @@ -329,7 +329,7 @@ bool TypeSupport::get_key_hash_from_ros_message( // get estimated serialized size in case key is unbounded if (this->key_is_unbounded_) { - this->key_max_serialized_size_ = this->getEstimatedSerializedKeySize(members, ros_message); + this->key_max_serialized_size_ = (std::max) (this->key_max_serialized_size_, this->getEstimatedSerializedKeySize(members, ros_message)); key_buffer_.reserve(this->key_max_serialized_size_); } @@ -994,7 +994,6 @@ size_t TypeSupport::calculateMaxSerializedSize( if (compute_key) { - std::cout << "Setting is key unbounded !" << std::endl; is_key_unbounded = true; } diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index 1a60bdcab..a202d9ba1 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -129,6 +129,7 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType mutable size_t key_max_serialized_size_; mutable MD5 md5_; mutable std::vector key_buffer_; + mutable std::mutex mtx_; }; RMW_FASTRTPS_SHARED_CPP_PUBLIC diff --git a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp index 00cedab09..cfc423434 100644 --- a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp +++ b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp @@ -84,6 +84,7 @@ bool TypeSupport::getKey( { case FASTRTPS_SERIALIZED_DATA_TYPE_ROS_MESSAGE: { + std::lock_guard lock(this->mtx_); ret = this->get_key_hash_from_ros_message(ser_data->data, ihandle, force_md5, ser_data->impl); break; } From 4478f5939096e73873b4088641e7fc7189a14690 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Mon, 1 Apr 2024 10:18:11 +0000 Subject: [PATCH 08/13] Linters Signed-off-by: Mario Dominguez --- .../include/rmw_fastrtps_cpp/TypeSupport.hpp | 5 +- rmw_fastrtps_cpp/src/publisher.cpp | 2 +- rmw_fastrtps_cpp/src/rmw_client.cpp | 4 +- rmw_fastrtps_cpp/src/rmw_service.cpp | 4 +- rmw_fastrtps_cpp/src/subscription.cpp | 4 +- rmw_fastrtps_cpp/src/type_support_common.cpp | 32 ++++----- .../src/MessageTypeSupport_impl.hpp | 3 +- .../src/ServiceTypeSupport_impl.hpp | 6 +- rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp | 9 +-- .../src/TypeSupport_impl.hpp | 68 +++++++++---------- rmw_fastrtps_dynamic_cpp/src/publisher.cpp | 2 +- rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp | 4 +- rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp | 4 +- rmw_fastrtps_dynamic_cpp/src/subscription.cpp | 2 +- .../src/type_support_proxy.cpp | 3 +- .../rmw_fastrtps_shared_cpp/TypeSupport.hpp | 3 +- .../src/TypeSupport_impl.cpp | 17 +++-- rmw_fastrtps_shared_cpp/src/utils.cpp | 7 +- 18 files changed, 84 insertions(+), 95 deletions(-) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp index 62f71c3ef..57888b107 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp @@ -43,7 +43,8 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const override; TypeSupport(); @@ -52,7 +53,7 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport private: const message_type_support_callbacks_t * members_; - const message_type_support_key_callbacks_t * key_callbacks_; + const message_type_support_key_callbacks_t * key_callbacks_; bool has_data_; }; diff --git a/rmw_fastrtps_cpp/src/publisher.cpp b/rmw_fastrtps_cpp/src/publisher.cpp index 202163d0c..82ec2ebeb 100644 --- a/rmw_fastrtps_cpp/src/publisher.cpp +++ b/rmw_fastrtps_cpp/src/publisher.cpp @@ -266,7 +266,7 @@ rmw_fastrtps_cpp::create_publisher( // Apply resource limits QoS if the type is keyed if (fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_cpp/src/rmw_client.cpp b/rmw_fastrtps_cpp/src/rmw_client.cpp index 101462dee..4382bc2d6 100644 --- a/rmw_fastrtps_cpp/src/rmw_client.cpp +++ b/rmw_fastrtps_cpp/src/rmw_client.cpp @@ -325,7 +325,7 @@ rmw_create_client( // Apply resource limits QoS if the type is keyed if (response_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), @@ -392,7 +392,7 @@ rmw_create_client( // Apply resource limits QoS if the type is keyed if (request_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_cpp/src/rmw_service.cpp b/rmw_fastrtps_cpp/src/rmw_service.cpp index 3d2b9492f..5a299c4fd 100644 --- a/rmw_fastrtps_cpp/src/rmw_service.cpp +++ b/rmw_fastrtps_cpp/src/rmw_service.cpp @@ -324,7 +324,7 @@ rmw_create_service( // Apply resource limits QoS if the type is keyed if (request_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), @@ -395,7 +395,7 @@ rmw_create_service( // Apply resource limits QoS if the type is keyed if (response_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_cpp/src/subscription.cpp b/rmw_fastrtps_cpp/src/subscription.cpp index 471e72916..576e3f8fb 100644 --- a/rmw_fastrtps_cpp/src/subscription.cpp +++ b/rmw_fastrtps_cpp/src/subscription.cpp @@ -394,7 +394,7 @@ __create_dynamic_subscription( // Apply resource limits QoS if the type is keyed if (fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), @@ -670,7 +670,7 @@ __create_subscription( // Apply resource limits QoS if the type is keyed if (fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), diff --git a/rmw_fastrtps_cpp/src/type_support_common.cpp b/rmw_fastrtps_cpp/src/type_support_common.cpp index 4d25848ed..126718cf9 100644 --- a/rmw_fastrtps_cpp/src/type_support_common.cpp +++ b/rmw_fastrtps_cpp/src/type_support_common.cpp @@ -63,14 +63,12 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members) // Account for RTPS submessage alignment m_typeSize = (m_typeSize + 3) & ~3; - if (nullptr != members->key_callbacks) - { + if (nullptr != members->key_callbacks) { key_callbacks_ = members->key_callbacks; m_isGetKeyDefined = true; key_max_serialized_size_ = key_callbacks_->max_serialized_size_key(key_is_unbounded_); - if (!key_is_unbounded_) - { + if (!key_is_unbounded_) { key_buffer_.reserve(key_max_serialized_size_); } } @@ -147,17 +145,16 @@ bool TypeSupport::deserializeROSmessage( } bool TypeSupport::get_key_hash_from_ros_message( - void * ros_message, - eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, - bool force_md5, - const void * impl) const + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5, + const void * impl) const { assert(ros_message); (void)impl; // retrieve estimated serialized size in case key is unbounded - if (key_is_unbounded_) - { + if (key_is_unbounded_) { key_max_serialized_size_ = (std::max) ( key_max_serialized_size_, key_callbacks_->get_serialized_size_key(ros_message)); @@ -178,23 +175,18 @@ bool TypeSupport::get_key_hash_from_ros_message( auto ser_length = ser.get_serialized_data_length(); // check for md5 - if (force_md5 || key_max_serialized_size_ > max_serialized_key_length) - { + if (force_md5 || key_max_serialized_size_ > max_serialized_key_length) { md5_.init(); md5_.update(key_buffer_.data(), static_cast(ser_length)); md5_.finalize(); - for (uint8_t i = 0; i < max_serialized_key_length; ++i) - { + for (uint8_t i = 0; i < max_serialized_key_length; ++i) { ihandle->value[i] = md5_.digest[i]; } - } - else - { + } else { memset(ihandle->value, 0, max_serialized_key_length); - for (uint8_t i = 0; i < ser_length; ++i) - { - ihandle->value[i] = key_buffer_[i]; + for (uint8_t i = 0; i < ser_length; ++i) { + ihandle->value[i] = key_buffer_[i]; } } diff --git a/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp index d039fae5a..0f03983f4 100644 --- a/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/MessageTypeSupport_impl.hpp @@ -61,8 +61,7 @@ MessageTypeSupport::MessageTypeSupport( this->m_typeSize++; } - if (this->members_->has_any_key_member_) - { + if (this->members_->has_any_key_member_) { this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(members); this->m_isGetKeyDefined = true; this->key_buffer_.reserve(this->key_max_serialized_size_); diff --git a/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp index d6cb98a07..6635e3f4e 100644 --- a/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/ServiceTypeSupport_impl.hpp @@ -60,8 +60,7 @@ RequestTypeSupport::RequestTypeSupport( this->m_typeSize++; } - if (this->members_->has_any_key_member_) - { + if (this->members_->has_any_key_member_) { this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(this->members_); this->m_isGetKeyDefined = true; this->key_buffer_.reserve(this->key_max_serialized_size_); @@ -101,8 +100,7 @@ ResponseTypeSupport::ResponseTypeSupport this->m_typeSize++; } - if (this->members_->has_any_key_member_) - { + if (this->members_->has_any_key_member_) { this->key_max_serialized_size_ = this->calculateMaxSerializedKeySize(this->members_); this->m_isGetKeyDefined = true; this->key_buffer_.reserve(this->key_max_serialized_size_); diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp index 053375562..622ca9318 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp @@ -140,7 +140,8 @@ class TypeSupportProxy : public rmw_fastrtps_shared_cpp::TypeSupport eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const override; }; class BaseTypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport @@ -174,7 +175,8 @@ class TypeSupport : public BaseTypeSupport eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const override; + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const override; protected: explicit TypeSupport(const void * ros_type_support); @@ -185,12 +187,11 @@ class TypeSupport : public BaseTypeSupport const MembersType * members_; private: - size_t calculateMaxSerializedSize( const MembersType * members, size_t current_alignment, bool compute_key, - bool& is_key_unbounded); + bool & is_key_unbounded); size_t getEstimatedSerializedSize( const MembersType * members, diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp index ec38ae2e3..fc2f7d000 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp @@ -223,8 +223,7 @@ bool TypeSupport::serializeROSmessage( for (uint32_t i = 0; i < members->member_count_; ++i) { const auto member = members->members_ + i; - if (compute_key && !member->is_key_ && members->has_any_key_member_) - { + if (compute_key && !member->is_key_ && members->has_any_key_member_) { continue; } @@ -303,7 +302,9 @@ bool TypeSupport::serializeROSmessage( return false; } for (size_t index = 0; index < array_size; ++index) { - serializeROSmessage(ser, sub_members, member->get_function(field, index), compute_key); + serializeROSmessage( + ser, sub_members, member->get_function(field, index), + compute_key); } } } @@ -327,9 +328,10 @@ bool TypeSupport::get_key_hash_from_ros_message( assert(ros_message); // get estimated serialized size in case key is unbounded - if (this->key_is_unbounded_) - { - this->key_max_serialized_size_ = (std::max) (this->key_max_serialized_size_, this->getEstimatedSerializedKeySize(members, ros_message)); + if (this->key_is_unbounded_) { + this->key_max_serialized_size_ = + (std::max) (this->key_max_serialized_size_, + this->getEstimatedSerializedKeySize(members, ros_message)); key_buffer_.reserve(this->key_max_serialized_size_); } @@ -344,25 +346,22 @@ bool TypeSupport::get_key_hash_from_ros_message( serializeKeyROSmessage(ser, members_, ros_message); // check for md5 - if (force_md5 || this->key_max_serialized_size_ > 16) - { - md5_.init(); + if (force_md5 || this->key_max_serialized_size_ > 16) { + md5_.init(); - md5_.update(this->key_buffer_.data(), static_cast(ser.get_serialized_data_length())); + md5_.update( + this->key_buffer_.data(), + static_cast(ser.get_serialized_data_length())); - md5_.finalize(); + md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - ihandle->value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - ihandle->value[i] = this->key_buffer_[i]; - } + for (uint8_t i = 0; i < 16; ++i) { + ihandle->value[i] = md5_.digest[i]; + } + } else { + for (uint8_t i = 0; i < 16; ++i) { + ihandle->value[i] = this->key_buffer_[i]; + } } return true; @@ -565,8 +564,7 @@ size_t TypeSupport::getEstimatedSerializedSize( const auto member = members->members_ + i; void * field = const_cast(static_cast(ros_message)) + member->offset_; - if (compute_key && !member->is_key_ && members->has_any_key_member_) - { + if (compute_key && !member->is_key_ && members->has_any_key_member_) { continue; } @@ -616,7 +614,9 @@ size_t TypeSupport::getEstimatedSerializedSize( { auto sub_members = static_cast(member->members_->data); if (!member->is_array_) { - current_alignment += getEstimatedSerializedSize(sub_members, field, current_alignment, compute_key); + current_alignment += getEstimatedSerializedSize( + sub_members, field, current_alignment, + compute_key); } else { size_t array_size = 0; @@ -921,7 +921,7 @@ size_t TypeSupport::calculateMaxSerializedSize( const MembersType * members, size_t current_alignment, bool compute_key, - bool& is_key_unbounded) + bool & is_key_unbounded) { assert(members); @@ -935,8 +935,7 @@ size_t TypeSupport::calculateMaxSerializedSize( size_t array_size = 1; - if (compute_key && !member->is_key_ && members->has_any_key_member_) - { + if (compute_key && !member->is_key_ && members->has_any_key_member_) { continue; } @@ -992,8 +991,7 @@ size_t TypeSupport::calculateMaxSerializedSize( this->max_size_bound_ = false; this->is_plain_ = false; - if (compute_key) - { + if (compute_key) { is_key_unbounded = true; } @@ -1012,7 +1010,9 @@ size_t TypeSupport::calculateMaxSerializedSize( { auto sub_members = static_cast(member->members_->data); for (size_t index = 0; index < array_size; ++index) { - size_t curr = calculateMaxSerializedSize(sub_members, current_alignment, compute_key, is_key_unbounded); + size_t curr = calculateMaxSerializedSize( + sub_members, current_alignment, compute_key, + is_key_unbounded); current_alignment += curr; last_member_size += curr; } @@ -1114,7 +1114,8 @@ bool TypeSupport::deserializeROSmessage( template bool TypeSupport::get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const { assert(ros_message); @@ -1123,8 +1124,7 @@ bool TypeSupport::get_key_hash_from_ros_message( bool ret = false; (void)impl; - if (members_->member_count_ != 0) - { + if (members_->member_count_ != 0) { ret = TypeSupport::get_key_hash_from_ros_message(members_, ros_message, ihandle, force_md5); } diff --git a/rmw_fastrtps_dynamic_cpp/src/publisher.cpp b/rmw_fastrtps_dynamic_cpp/src/publisher.cpp index 377e26bf5..d737fc8e3 100644 --- a/rmw_fastrtps_dynamic_cpp/src/publisher.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/publisher.cpp @@ -274,7 +274,7 @@ rmw_fastrtps_dynamic_cpp::create_publisher( // Apply resource limits QoS if the type is keyed if (fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp index 54db1bf84..5c4423da3 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp @@ -356,7 +356,7 @@ rmw_create_client( // Apply resource limits QoS if the type is keyed if (response_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), @@ -423,7 +423,7 @@ rmw_create_client( // Apply resource limits QoS if the type is keyed if (request_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp index 495bf989b..47f6bd70f 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp @@ -355,7 +355,7 @@ rmw_create_service( // Apply resource limits QoS if the type is keyed if (request_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), @@ -426,7 +426,7 @@ rmw_create_service( // Apply resource limits QoS if the type is keyed if (response_fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( writer_qos.history(), diff --git a/rmw_fastrtps_dynamic_cpp/src/subscription.cpp b/rmw_fastrtps_dynamic_cpp/src/subscription.cpp index 28da07c3d..23587d73b 100644 --- a/rmw_fastrtps_dynamic_cpp/src/subscription.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/subscription.cpp @@ -278,7 +278,7 @@ create_subscription( // Apply resource limits QoS if the type is keyed if (fastdds_type->m_isGetKeyDefined && - !participant_info->leave_middleware_default_qos) + !participant_info->leave_middleware_default_qos) { rmw_fastrtps_shared_cpp::apply_qos_resource_limits_for_keys( reader_qos.history(), diff --git a/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp b/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp index 99a5f7b07..bce368920 100644 --- a/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/type_support_proxy.cpp @@ -49,7 +49,8 @@ bool TypeSupportProxy::deserializeROSmessage( } bool TypeSupportProxy::get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const { auto type_impl = static_cast(impl); return type_impl->get_key_hash_from_ros_message(ros_message, ihandle, force_md5, impl); diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index a202d9ba1..63d168b31 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -63,7 +63,8 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const = 0; virtual bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const = 0; + void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + const void * impl) const = 0; RMW_FASTRTPS_SHARED_CPP_PUBLIC bool getKey( diff --git a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp index cfc423434..95c555d51 100644 --- a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp +++ b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp @@ -65,27 +65,26 @@ void * TypeSupport::createData() } bool TypeSupport::getKey( - void * data, - eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, - bool force_md5) + void * data, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5) { assert(data); bool ret = false; - if (!m_isGetKeyDefined) - { - return ret; + if (!m_isGetKeyDefined) { + return ret; } auto ser_data = static_cast(data); - switch (ser_data->type) - { + switch (ser_data->type) { case FASTRTPS_SERIALIZED_DATA_TYPE_ROS_MESSAGE: { std::lock_guard lock(this->mtx_); - ret = this->get_key_hash_from_ros_message(ser_data->data, ihandle, force_md5, ser_data->impl); + ret = + this->get_key_hash_from_ros_message(ser_data->data, ihandle, force_md5, ser_data->impl); break; } diff --git a/rmw_fastrtps_shared_cpp/src/utils.cpp b/rmw_fastrtps_shared_cpp/src/utils.cpp index ba5d4eec3..86500685c 100644 --- a/rmw_fastrtps_shared_cpp/src/utils.cpp +++ b/rmw_fastrtps_shared_cpp/src/utils.cpp @@ -191,12 +191,9 @@ apply_qos_resource_limits_for_keys( { res_limits_qos.max_instances = 0; res_limits_qos.max_samples = 0; - if (history_qos.kind == eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS) - { + if (history_qos.kind == eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS) { res_limits_qos.max_samples_per_instance = history_qos.depth; - } - else - { + } else { res_limits_qos.max_samples_per_instance = 0; } } From ed7f9d69741c887604f1df0bb84bd7806f316868 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Mon, 1 Apr 2024 13:31:20 +0000 Subject: [PATCH 09/13] Rev changes 2 Signed-off-by: Mario Dominguez --- rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp | 4 +++- rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp index 57888b107..5b7d07591 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport.hpp @@ -43,7 +43,9 @@ class TypeSupport : public rmw_fastrtps_shared_cpp::TypeSupport eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5, const void * impl) const override; TypeSupport(); diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp index 622ca9318..b9e1153b6 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport.hpp @@ -175,7 +175,9 @@ class TypeSupport : public BaseTypeSupport eprosima::fastcdr::Cdr & deser, void * ros_message, const void * impl) const override; bool get_key_hash_from_ros_message( - void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, + void * ros_message, + eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, + bool force_md5, const void * impl) const override; protected: From e92f7ed32ed57be6d6eda9c1ceb61b859d62b6c8 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 1 Apr 2024 17:04:22 +0200 Subject: [PATCH 10/13] More linters Signed-off-by: Miguel Company --- rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp | 3 +-- .../include/rmw_fastrtps_shared_cpp/TypeSupport.hpp | 1 + rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp index fc2f7d000..8dac3460c 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp @@ -905,7 +905,7 @@ template size_t TypeSupport::calculateMaxSerializedSize( const MembersType * members, size_t current_alignment) { - bool is_key_unbounded{false}; //unused + bool is_key_unbounded{false}; // unused return calculateMaxSerializedSize(members, current_alignment, false, is_key_unbounded); } @@ -1117,7 +1117,6 @@ bool TypeSupport::get_key_hash_from_ros_message( void * ros_message, eprosima::fastrtps::rtps::InstanceHandle_t * ihandle, bool force_md5, const void * impl) const { - assert(ros_message); assert(members_); diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp index 63d168b31..5af5e9e29 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp @@ -17,6 +17,7 @@ #include #include +#include #include "fastdds/dds/topic/TopicDataType.hpp" diff --git a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp index 95c555d51..b34ae77f3 100644 --- a/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp +++ b/rmw_fastrtps_shared_cpp/src/TypeSupport_impl.cpp @@ -90,14 +90,13 @@ bool TypeSupport::getKey( case FASTRTPS_SERIALIZED_DATA_TYPE_CDR_BUFFER: { - // TODO - // We would need a get_key_hash_from_payload method + // TODO(MiguelCompany): In order to support keys in rmw_publish_serialized_message, + // we would need a get_key_hash_from_payload method break; } case FASTRTPS_SERIALIZED_DATA_TYPE_DYNAMIC_MESSAGE: { - auto m_type = std::make_shared(); // Retrieves the key (ihandle) from the dynamic data stored in data->data From 32b2145229033bf0bc41a4d5e2e86103fa139921 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 29 Oct 2024 15:02:15 +0100 Subject: [PATCH 11/13] Typo Signed-off-by: Mario Dominguez --- .../include/rmw_fastrtps_shared_cpp/utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp index f4c9b1c81..76abaa507 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp @@ -131,7 +131,7 @@ create_datareader( * Max samples per instance is set to history depth if KEEP_LAST * else UNLIMITED. * -* \param[in] hitory_qos History entitiy QoS. +* \param[in] history_qos History entitiy QoS. * \param[in, out] res_limits_qos Resource limits entitiy QoS. * */ From 978e919b96213913157670e3e04c396915b70472 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 5 Nov 2024 08:21:29 +0100 Subject: [PATCH 12/13] Add assert(ihandle) Signed-off-by: Mario Dominguez --- rmw_fastrtps_cpp/src/type_support_common.cpp | 1 + rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/rmw_fastrtps_cpp/src/type_support_common.cpp b/rmw_fastrtps_cpp/src/type_support_common.cpp index 126718cf9..3c4cd3c0f 100644 --- a/rmw_fastrtps_cpp/src/type_support_common.cpp +++ b/rmw_fastrtps_cpp/src/type_support_common.cpp @@ -151,6 +151,7 @@ bool TypeSupport::get_key_hash_from_ros_message( const void * impl) const { assert(ros_message); + assert(ihandle); (void)impl; // retrieve estimated serialized size in case key is unbounded diff --git a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp index 8dac3460c..9aee286b5 100644 --- a/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/src/TypeSupport_impl.hpp @@ -326,6 +326,7 @@ bool TypeSupport::get_key_hash_from_ros_message( { assert(members); assert(ros_message); + assert(ihandle); // get estimated serialized size in case key is unbounded if (this->key_is_unbounded_) { @@ -1118,6 +1119,7 @@ bool TypeSupport::get_key_hash_from_ros_message( const void * impl) const { assert(ros_message); + assert(ihandle); assert(members_); bool ret = false; From 017f34c83e076e4d547a5a9988fc129034329b16 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 5 Nov 2024 08:21:48 +0100 Subject: [PATCH 13/13] Align argument Signed-off-by: Mario Dominguez --- .../include/rmw_fastrtps_shared_cpp/utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp index 76abaa507..7973ca738 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/utils.hpp @@ -131,7 +131,7 @@ create_datareader( * Max samples per instance is set to history depth if KEEP_LAST * else UNLIMITED. * -* \param[in] history_qos History entitiy QoS. +* \param[in] history_qos History entitiy QoS. * \param[in, out] res_limits_qos Resource limits entitiy QoS. * */