Fast DDS之Qos与Profiles


Qos (Quality of Service)用于指定服务的行为,允许用户指定每个实体怎样表现或运行。通过XML文件(Profiles)来配置或者在代码中直接指定。

XML profiles

xml配置文件可以有多个。

加载

Fast DDS在初始化阶段自动加载XML:

  • 在当前可执行文件的路径下加载 DEFAULT_FASTRTPS_PROFILES.xml
  • 加载环境变量FASTRTPS_DEFAULT_PROFILES_FILE指定的xml
  • 加载配置参数指定的xml文件
  • 直接加载xml格式的字符串

创建

<?xml version="1.0" encoding="UTF-8" ?>
<dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <profiles>
        <domainparticipant_factory profile_name="domainparticipant_factory_profile">
            <!-- ... -->
        </domainparticipant_factory>

        <participant profile_name="participant_profile">
            <!-- ... -->
        </participant>

        <data_writer profile_name="datawriter_profile">
            <!-- ... -->
        </data_writer>

        <data_reader profile_name="datareader_profile">
            <!-- ... -->
        </data_reader>

        <topic profile_name="topic_profile">
            <!-- ... -->
        </topic>

        <transport_descriptors>
            <!-- ... -->
        </transport_descriptors>
    </profiles>

    <library_settings>
        <!-- ... -->
    </library_settings>

    <log>
        <!-- ... -->
    </log>

    <types>
        <!-- ... -->
    </types>
</dds>
  1. <dds>, <profiles>, <library_settings>, <types>, and <log> 这些标签可以独立定义。
  2. <participant>, <data_reader>, <data_writer>, <topic>, and <transport_descriptors> 这些标签必须作为<profiles>的子元素

修改

if (ReturnCode_t::RETCODE_OK ==
        DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml"))
{
    DomainParticipantQos participant_qos;
    DomainParticipantFactory::get_instance()->get_participant_qos_from_profile(
        "participant_xml_profile",
        participant_qos);

    // Name obtained in another section of the code
    participant_qos.name() = custom_name;

    // Modify number of preallocations (this overrides the one set in the XML profile)
    participant_qos.allocation().send_buffers.preallocated_number = 10;

    // Create participant using the modified XML Qos
    DomainParticipant* participant =
            DomainParticipantFactory::get_instance()->create_participant(
        0, participant_qos);
}

可配置内容

  • DomainParticipantFactory profiles
  • DomainParticipant profiles
  • DataWriter profiles
  • DataReader profiles
  • Topic profiles
  • transport_descriptor
  • Intra-process delivery profiles
  • Log profiles
  • Dynamic Types profiles

Qos

每个Qos都有一个唯一的ID(定义在枚举QosPolicyId_t中),这个ID值用于一些Status中,以识别状态所引用的特定Qos策略。
Fast DDS中支持的Policies在这里

<deadline>

DeadlineQosPolicy,当新的数据样本的频率低于设定的阈值时,此QoS策略会发出警报。它对于预期定期更新数据的情况非常有用。
在Pub端,它是期望能够提供发送新的数据样本的最长期限;在Sub端,它是接收新样本的最长时间。

Data Member NameTypeDefault Value
periodDuration_tc_TimeInfinite
<deadline>
    <period>
        <sec>1</sec>
    </period>
</deadline>

<durability>

DurabilityQosPolicy

DurabilityServiceQosPolicy

EntityFactoryQosPolicy

GroupDataQosPolicy

HistoryQosPolicy

LatencyBudgetQosPolicy

LivelinessQosPolicy

OwnershipQosPolicy

OwnershipStrengthQosPolicy

PartitionQosPolicy

PresentationQosPolicy

ReaderDataLifecycleQosPolicy

ReliabilityQosPolicy

ResourceLimitsQosPolicy

TimeBasedFilterQosPolicy

TopicDataQosPolicy

TransportPriorityQosPolicy

UserDataQosPolicy

WriterDataLifecycleQosPolicy

eProsima扩展的Qos

  • 16
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值