You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置端口11888的FastDDS服务器仅接收指定ROS话题

实现指定FastDDS服务器仅接收特定ROS话题

可以实现让端口11888的FastDDS服务器仅接收/namespace/topic1和/namespace/topic2这两个ROS话题,核心是给该服务器配置话题过滤规则。需要注意:你提供的XML是客户端的发现服务器列表配置,而限制服务器接收话题需要修改服务器端的专属配置,以下是具体方案:

关键配置说明

  • 为端口11888的发现服务器单独创建参与者配置,指定其身份为SERVER,并匹配原配置中的前缀和端口。
  • 通过topic_filter设置允许列表,仅放行目标话题对应的DDS话题名(ROS 2默认会把ROS话题/namespace/topicX转换为DDS话题rt/namespace/topicX,若有自定义映射需调整)。

修改后的完整XML配置

<?xml version="1.0" encoding="UTF-8" ?>
<dds>
    <profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
        <!-- 原有客户端配置保持不变 -->
        <participant profile_name="my_profile" is_default_profile="true">
            <rtps>
                <builtin>
                    <discovery_config>
                        <discoveryProtocol>SIMPLE</discoveryProtocol>
                        <discoveryServersList>
                            <RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
                                <metatrafficUnicastLocatorList>
                                    <locator>
                                        <udpv4>
                                            <address>127.0.0.1</address>
                                            <port>11811</port>
                                        </udpv4>
                                    </locator>
                                </metatrafficUnicastLocatorList>
                            </RemoteServer>
                            <RemoteServer prefix="44.53.01.5f.45.50.52.4f.53.49.4d.41">
                                <metatrafficUnicastLocatorList>
                                    <locator>
                                        <udpv4>
                                            <address>127.0.0.1</address>
                                            <port>11888</port>
                                        </udpv4>
                                    </locator>
                                </metatrafficUnicastLocatorList>
                            </RemoteServer>
                        </discoveryServersList>
                    </discovery_config>
                </builtin>
            </rtps>
        </participant>

        <!-- 端口11888的发现服务器专属配置 -->
        <participant profile_name="server_11888_profile" is_default_profile="false">
            <rtps>
                <builtin>
                    <discovery_config>
                        <discoveryProtocol>SERVER</discoveryProtocol>
                        <server_settings>
                            <!-- 匹配客户端配置中的服务器前缀 -->
                            <prefix>44.53.01.5f.45.50.52.4f.53.49.4d.41</prefix>
                            <metatrafficUnicastLocatorList>
                                <locator>
                                    <udpv4>
                                        <address>127.0.0.1</address>
                                        <port>11888</port>
                                    </udpv4>
                                </locator>
                            </metatrafficUnicastLocatorList>
                        </server_settings>
                        <!-- 设置仅允许指定话题 -->
                        <topic_filter>
                            <kind>ALLOW_LIST</kind>
                            <topics>
                                <topic>rt/namespace/topic1</topic>
                                <topic>rt/namespace/topic2</topic>
                            </topics>
                        </topic_filter>
                    </discovery_config>
                </builtin>
            </rtps>
        </participant>
    </profiles>
</dds>

启动服务器时的注意事项

启动端口11888的FastDDS服务器时,需要指定加载上述server_11888_profile配置,比如通过命令行参数:

fastdds discovery -p server_11888_profile

内容的提问来源于stack exchange,提问作者wouterio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 23:48:17