Skip to content

Commit

Permalink
Add support for data representation (#756)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed May 27, 2024
1 parent 21e6a44 commit 8edeb78
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType
return is_plain_;
}

RMW_FASTRTPS_SHARED_CPP_PUBLIC
inline bool is_plain(eprosima::fastdds::dds::DataRepresentationId_t rep) const override
{
return is_plain_ && rep == eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
}

RMW_FASTRTPS_SHARED_CPP_PUBLIC
virtual ~TypeSupport() {}

Expand Down
20 changes: 18 additions & 2 deletions rmw_fastrtps_shared_cpp/src/qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,15 @@ get_datareader_qos(
const rosidl_type_hash_t & type_hash,
eprosima::fastdds::dds::DataReaderQos & datareader_qos)
{
return fill_data_entity_qos_from_profile(qos_policies, type_hash, datareader_qos);
if (fill_data_entity_qos_from_profile(qos_policies, type_hash, datareader_qos)) {
// The type support in the RMW implementation is always XCDR1.
constexpr auto rep = eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
datareader_qos.type_consistency().representation.clear();
datareader_qos.type_consistency().representation.m_value.push_back(rep);
return true;
}

return false;
}

bool
Expand All @@ -190,7 +198,15 @@ get_datawriter_qos(
const rosidl_type_hash_t & type_hash,
eprosima::fastdds::dds::DataWriterQos & datawriter_qos)
{
return fill_data_entity_qos_from_profile(qos_policies, type_hash, datawriter_qos);
if (fill_data_entity_qos_from_profile(qos_policies, type_hash, datawriter_qos)) {
// The type support in the RMW implementation is always XCDR1.
constexpr auto rep = eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
datawriter_qos.representation().clear();
datawriter_qos.representation().m_value.push_back(rep);
return true;
}

return false;
}

bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ TEST_F(GetDataReaderQoSTest, nominal_conversion) {
eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS,
subscriber_qos_.history().kind);
EXPECT_GE(10, subscriber_qos_.history().depth);
ASSERT_EQ(1, subscriber_qos_.type_consistency().representation.m_value.size());
EXPECT_EQ(
eprosima::fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
subscriber_qos_.type_consistency().representation.m_value[0]);
}

TEST_F(GetDataReaderQoSTest, large_depth_conversion) {
Expand Down Expand Up @@ -201,6 +205,10 @@ TEST_F(GetDataWriterQoSTest, nominal_conversion) {
eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS,
publisher_qos_.history().kind);
EXPECT_GE(10, publisher_qos_.history().depth);
ASSERT_EQ(1, publisher_qos_.representation().m_value.size());
EXPECT_EQ(
eprosima::fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
publisher_qos_.representation().m_value[0]);
}

TEST_F(GetDataWriterQoSTest, large_depth_conversion) {
Expand Down

0 comments on commit 8edeb78

Please sign in to comment.