Skip to content

Commit 8edeb78

Browse files
Add support for data representation (#756)
Signed-off-by: Miguel Company <[email protected]>
1 parent 21e6a44 commit 8edeb78

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/TypeSupport.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ class TypeSupport : public eprosima::fastdds::dds::TopicDataType
104104
return is_plain_;
105105
}
106106

107+
RMW_FASTRTPS_SHARED_CPP_PUBLIC
108+
inline bool is_plain(eprosima::fastdds::dds::DataRepresentationId_t rep) const override
109+
{
110+
return is_plain_ && rep == eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
111+
}
112+
107113
RMW_FASTRTPS_SHARED_CPP_PUBLIC
108114
virtual ~TypeSupport() {}
109115

rmw_fastrtps_shared_cpp/src/qos.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ get_datareader_qos(
181181
const rosidl_type_hash_t & type_hash,
182182
eprosima::fastdds::dds::DataReaderQos & datareader_qos)
183183
{
184-
return fill_data_entity_qos_from_profile(qos_policies, type_hash, datareader_qos);
184+
if (fill_data_entity_qos_from_profile(qos_policies, type_hash, datareader_qos)) {
185+
// The type support in the RMW implementation is always XCDR1.
186+
constexpr auto rep = eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
187+
datareader_qos.type_consistency().representation.clear();
188+
datareader_qos.type_consistency().representation.m_value.push_back(rep);
189+
return true;
190+
}
191+
192+
return false;
185193
}
186194

187195
bool
@@ -190,7 +198,15 @@ get_datawriter_qos(
190198
const rosidl_type_hash_t & type_hash,
191199
eprosima::fastdds::dds::DataWriterQos & datawriter_qos)
192200
{
193-
return fill_data_entity_qos_from_profile(qos_policies, type_hash, datawriter_qos);
201+
if (fill_data_entity_qos_from_profile(qos_policies, type_hash, datawriter_qos)) {
202+
// The type support in the RMW implementation is always XCDR1.
203+
constexpr auto rep = eprosima::fastdds::dds::XCDR_DATA_REPRESENTATION;
204+
datawriter_qos.representation().clear();
205+
datawriter_qos.representation().m_value.push_back(rep);
206+
return true;
207+
}
208+
209+
return false;
194210
}
195211

196212
bool

rmw_fastrtps_shared_cpp/test/test_rmw_qos_to_dds_attributes.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ TEST_F(GetDataReaderQoSTest, nominal_conversion) {
103103
eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS,
104104
subscriber_qos_.history().kind);
105105
EXPECT_GE(10, subscriber_qos_.history().depth);
106+
ASSERT_EQ(1, subscriber_qos_.type_consistency().representation.m_value.size());
107+
EXPECT_EQ(
108+
eprosima::fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
109+
subscriber_qos_.type_consistency().representation.m_value[0]);
106110
}
107111

108112
TEST_F(GetDataReaderQoSTest, large_depth_conversion) {
@@ -201,6 +205,10 @@ TEST_F(GetDataWriterQoSTest, nominal_conversion) {
201205
eprosima::fastdds::dds::KEEP_LAST_HISTORY_QOS,
202206
publisher_qos_.history().kind);
203207
EXPECT_GE(10, publisher_qos_.history().depth);
208+
ASSERT_EQ(1, publisher_qos_.representation().m_value.size());
209+
EXPECT_EQ(
210+
eprosima::fastdds::dds::DataRepresentationId::XCDR_DATA_REPRESENTATION,
211+
publisher_qos_.representation().m_value[0]);
204212
}
205213

206214
TEST_F(GetDataWriterQoSTest, large_depth_conversion) {

0 commit comments

Comments
 (0)