gpt4 book ai didi

c++ - 如何在 CycloneDDS C++ 中设置 QOS?

转载 作者:行者123 更新时间:2023-12-04 07:50:25 27 4
gpt4 key购买 nike

我正在使用 CycloneDDS C++ version ,
尝试将以下 QOS 设置为写入器 DDS_HISTORY_KEEP_ALL、DDS_DURABILITY_TRANSIENT_LOCAL、DDS_RELIABILITY_RELIABLE
我试图在 dds 发布者中将 Qos 设置为数据编写器

dds::domain::DomainParticipant local_participant(domain::default_id());
dds::pub::Publisher local_publisher(local_participant);
dds::topic::Topic<DDSData::myData> topicMyData(local_participant, "DDS");

dds::pub::qos::DataWriterQos QosW( dds_history_kind(DDS_HISTORY_KEEP_ALL),
dds_durability_kind(DDS_DURABILITY_TRANSIENT_LOCAL),
dds_reliability_kind(DDS_RELIABILITY_RELIABLE));

m_ReplyDataWriter = std::make_shared < dds::pub::DataWriter<DDSData::myData>>(local_publisher, topicMyData, QosW, NULL, ::dds::core::status::StatusMask::none());
具有 Qos 的 DataWriter 构造函数
DataWriter(const dds::pub::Publisher& pub,
const ::dds::topic::Topic<T>& topic,
const dds::pub::qos::DataWriterQos& qos,
dds::pub::DataWriterListener<T>* listener = NULL,
const dds::core::status::StatusMask& mask = ::dds::core::status::StatusMask::none());
它不起作用我在这里想念什么?
Error   C2664'dds::pub::DataWriter<DDSData::myData,dds::pub::detail::DataWriter>::DataWriter(const dds::pub::DataWriter<DDSData::myData,dds::pub::detail::DataWriter> &)': cannot convert argument 3 from '_Ty' to 'const dds::pub::qos::DataWriterQos &'       

最佳答案

Check this out
错误是因为 QoS 设置不正确,您可以尝试以下代码,
使用您自己的 QoS 创建 DataWriter

dds::domain::DomainParticipant local_participant(domain::default_id());
dds::pub::Publisher local_publisher(local_participant);
dds::topic::Topic<DDSData::myData> topicMyData(local_participant, "DDS");

dds::pub::qos::DataWriterQos dwqos = topicMyData.qos();

dwqos << dds_history_kind(DDS_HISTORY_KEEP_ALL)
<< dds_durability_kind(DDS_DURABILITY_TRANSIENT_LOCAL)
<< dds_reliability_kind(DDS_RELIABILITY_RELIABLE);

dds::pub::DataWriter<Foo::Type> writer2(local_publisher, topicMyData, dwqos);

//m_ReplyDataWriter = std::make_shared < dds::pub::DataWriter<DDSData::myData>>(local_publisher, topicMyData, dwqos, NULL, ::dds::core::status::StatusMask::none());

关于c++ - 如何在 CycloneDDS C++ 中设置 QOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67016991/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com