赞
踩
比较杂乱,调试会遇到问题,并且ROS2的问题和ROS1有非常大的差异性。
一些概念:
词汇表:
eProsima 快速 RTPS
eprosima Fast RTPS 是 RTPS(实时发布订阅)协议的 C++ 实现,它通过对象管理组 (OMG) 联盟定义和维护的不可靠传输(如 UDP)提供发布者-订阅者通信。 RTPS 还是 OMG 为数据分发服务 (DDS) 标准定义的有线互操作性协议。 eProsima Fast RTPS 具有独立和最新的优势,因为大多数供应商解决方案要么将 RTPS 作为实现 DDS 的工具,要么使用过去版本的规范。
该库的一些主要功能是:
ROS 2 提供了丰富多样的服务质量 (QoS) 策略,允许您调整节点之间的通信。使用正确的服务质量策略集,ROS 2 可以像 TCP 一样可靠,也可以像 UDP 一样尽最大努力,在这两者之间有很多很多可能的状态。与主要仅支持 TCP 的 ROS 1 不同,ROS 2 受益于底层 DDS 传输的灵活性,在有损无线网络的环境中,“尽力而为”策略更合适,或者在具有正确质量的实时计算系统中需要服务配置文件才能满足最后期限。
一组 QoS “策略”组合起来形成一个 QoS “配置文件”。鉴于为给定场景选择正确 QoS 策略的复杂性,ROS 2 为常见用例(例如传感器数据)提供了一组预定义的 QoS 配置文件。同时,开发人员可以灵活地控制 QoS 配置文件的特定策略。
可以为发布者、订阅者、服务服务器和客户端指定 QoS 配置文件。QoS 配置文件可以独立应用于上述实体的每个实例,但如果使用不同的配置文件,它们可能会不兼容,从而阻止消息的传递。
基本 QoS 配置文件当前包括以下策略的设置:
历史
保持最后:仅存储最多 N 个样本,可通过队列深度选项进行配置。
Keep all:存储所有样本,受底层中间件配置的资源限制。
深度
队列大小:仅当“历史”策略设置为“保持最后”时才使用。
可靠性
尽力而为:尝试提供样本,但如果网络不健壮,可能会丢失它们。
可靠:保证样品送达,可多次重试。
耐用性
Transient local:发布者负责为“后期加入”订阅保存样本。
Volatile:不尝试保留样本。
最后期限
持续时间:后续消息发布到主题之间的预期最长时间
寿命
Duration:消息发布和接收之间的最长时间,而消息不被视为陈旧或过期(过期消息被静默丢弃,实际上永远不会收到)。
活泼
自动:当任何一个发布者发布消息时,系统将认为节点的所有发布者在另一个“租用期限”内都处于活动状态。
按主题手动:如果系统手动断言它仍然活着(通过调用发布者 API),则系统将认为发布者在另一个“租约期限”内还活着。
租期
Duration:发布者在系统认为它失去活力之前必须表明它处于活动状态的最长时间(失去活力可能表示失败)。
对于每一个不是持续时间的策略,还有“系统默认”选项,它使用底层中间件的默认值。对于每个作为持续时间的策略,还存在一个“默认”选项,表示持续时间未指定,底层中间件通常会将其解释为无限长的持续时间。
ROS 2 中的“历史”和“深度”策略结合起来提供类似于 ROS 1 中队列大小的功能。
ROS 2 中的“可靠性”策略类似于使用 UDPROS(仅在 中roscpp
)表示“尽力而为”,或使用 TCPROS(ROS 1 默认)表示“可靠”。但是请注意,即使 ROS 2 中的可靠策略也是使用 UDP 实现的,它允许在适当的情况下进行多播。
“持久性”策略“本地瞬态”,结合任何深度,提供类似于“锁定”发布者的功能。ROS 2 中的其余策略与 ROS 1 中可用的任何策略都不相似,这意味着 ROS 2 在这方面比 ROS 1 更具特色。未来可能会在 ROS 2 中提供更多的 QoS 策略。
配置文件允许开发人员专注于他们的应用程序,而不必担心每一个可能的 QoS 设置。QoS 配置文件定义了一组策略,这些策略预计可以很好地用于特定用例。
当前定义的 QoS 配置文件是:
发布者和订阅的默认 QoS 设置
为了使从 ROS 1 到 ROS 2 的转换更容易,执行类似的网络行为是可取的。默认情况下,ROS 2 中的发布者和订阅者具有“保持最后”的历史队列大小,队列大小为 10,可靠性为“可靠”,持久性为“易失”,活力为“系统默认”。最后期限、寿命和租约期限也都设置为“默认”。
服务
与发布者和订阅者一样,服务也是可靠的。服务使用 volatile 持久性尤其重要,否则重新启动的服务服务器可能会收到过时的请求。虽然客户端不会收到多个响应,但服务器不会收到过时请求的副作用。
传感器数据
对于传感器数据,在大多数情况下,及时接收读数比确保所有读数都到达更重要。也就是说,开发人员希望在捕获最新样本后立即获得最新样本,代价是可能会丢失一些样本。因此,传感器数据配置文件使用尽力而为的可靠性和较小的队列大小。
参数
ROS 2 中的参数基于服务,因此具有类似的配置文件。不同之处在于参数使用了更大的队列深度,以便在例如参数客户端无法到达参数服务服务器时,请求不会丢失。
系统默认
这对所有策略使用 RMW 实现的默认值。不同的 RMW 实现可能有不同的默认值。
sudo sysctl net.ipv4.ipfrag_time=3
sudo sysctl net.ipv4.ipfrag_high_thresh=134217728 # (128 MB)
fastdds discovery --server-id 0
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_discovery_server
/chatter
主题。ROS_DISCOVERY_SERVER
为发现服务器的位置。(不要忘记在每个新终端中获取 ROS 2)--remap __node:=listener_discovery_server
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_discovery_server
ROS_DISCOVERY_SERVER
像以前一样设置环境变量,以便节点启动发现客户端。ros2 run demo_nodes_cpp listener --ros-args --remap __node:=simple_listener
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=simple_talker
/chatter
主题)并检查它是否没有连接到已经运行的谈话者。simple_listener
节点接收来自 的“hello world”消息,simple_talker
但没有接收来自 的其他消息talker_discovery_server
。rqt_graph
工具可用于验证此示例的节点和结构。请记住,为了rqt_graph
与发现服务器协议一起使用(即查看listener_discovery_server
和talker_discovery_server
节点),ROS_DISCOVERY_SERVER
必须在启动它之前设置环境变量。- zhangrelay@LAPTOP-5REQ7K1L:~$ fastdds -h
- usage: fastdds <command> [<command-args>]
-
- Commands:
-
- discovery Server-Client discovery auxiliary generator
-
- shm Shared-memory commands
-
- fastdds <command> [-h] shows command usage
-
-
- positional arguments:
- command Command to run
-
- options:
- -h, --help show this help message and exit
- zhangrelay@LAPTOP-5REQ7K1L:~$ fastdds discovery -h
-
- eProsima Server-Client discovery auxiliary generator tool version 1.0.0
-
- Usage: fastdds discovery [optional parameters]
- General options:
- -h --help Produce help message.
-
- -i --server-id Unique server identifier. Specifies zero based server
- position in ROS_DISCOVERY_SERVER environment variable.
-
- -l --ip-address IPv4 address chosen to listen the clients. Defaults
- to any (0.0.0.0). Instead of an address, a name can
- be specified.
- -p --port UDP port chosen to listen the clients. Defaults to 11811
-
- -b --backup Creates a server with a backup file associated.
-
- -x --xml-file Gets config from XML file. If there is any argument in
- common with the config of the XML, the XML argument will
- be overriden. A XML file with several profiles will take
- the profile with "is_default_profile="true"" unless
- another profile using uri with "@" character is defined.
-
- Examples:
- 1. Launch a default server with id 0 (first on ROS_DISCOVERY_SERVER)
- listening on all available interfaces on UDP port 11811. Only one
- server can use default values per machine.
-
- $ fastdds discovery -i 0
-
- 2. Launch a default server with id 1 (second on ROS_DISCOVERY_SERVER)
- listening on localhost with UDP port 14520. Only localhost clients
- can reach the server using as ROS_DISCOVERY_SERVER=;127.0.0.1:14520
-
- $ fastdds discovery -i 1 -l 127.0.0.1 -p 14520
-
- 3. Launch a default server with id 2 (third on ROS_DISCOVERY_SERVER)
- listening on Wi-Fi (192.168.36.34) and Ethernet (172.20.96.1) local
- interfaces with UDP ports 8783 and 51083 respectively
- (addresses and ports are made up for the example).
-
- $ fastdds discovery -i 2 -l 192.168.36.34 -p 8783 -l 172.20.96.1 -p
- 51083
-
- 4. Launch a default server with id 3 (fourth on ROS_DISCOVERY_SERVER)
- listening on 172.30.144.1 with UDP port 12345 and provided with a
- backup file. If the server crashes it will automatically restore its
- previous state when reenacted.
-
- $ fastdds discovery -i 3 -l 172.30.144.1 -p 12345 -b
-
- 5. Launch a default server with id 0 (first on ROS_DISCOVERY_SERVER)
- listening on localhost with UDP port 14520. Only localhost clients
- can reach the server defining as ROS_DISCOVERY_SERVER=localhost:14520.
-
- $ fastdds discovery -i 0 -l localhost -p 14520
-
- 6. Launch a server with id 0 (first on ROS_DISCOVERY_SERVER) reading
- default configuration from XML file.
-
- $ fastdds discovery -i 0 -x config.xml
-
- 6. Launch a server with id 0 (first on ROS_DISCOVERY_SERVER) reading
- specific profile_name configuration from XML file.
-
- $ fastdds discovery -i 0 -x profile_name@config.xml
-
- zhangrelay@LAPTOP-5REQ7K1L:~$ fastdds discovery -i 1 -l 127.0.0.1 -p 14520

ipfrag_time
参数的值。net.ipv4.ipfrag_time / /proc/sys/net/ipv4/ipfrag_time
(默认 30 秒):将 IP 片段保存在内存中的时间(以秒为单位)。ipfrag_high_thresh
参数值。net.ipv4.ipfrag_high_thresh / /proc/sys/net/ipv4/ipfrag_high_thresh
(默认值:262144 字节):用于重组 IP 片段的最大内存。ipfrag_time
但是,假设每个 UDP 数据包都缺少一个片段,则该值可能必须非常高才能保存在 的时间窗口内接收到的所有数据。Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。