The Robot Operating System 2 (ROS 2) is a widely used middleware for robotic systems, characterized by a publish-subscribe (pub-sub) communication mechanism in which computation is structured as callbacks dispatched by ROS 2 executors. Despite its popularity, the pub-sub pattern in ROS 2 is inherently nondeterministic: the order in which these callbacks run is nondeterministic even within a single executor, and distributed deployments add further nondeterminism from the interleaving of messages across nodes and from network latency. Such nondeterminism often leads to concurrency issues and makes it virtually impossible to analyze for safeness and provide guarantees. We present a framework that is able to convert an unmodified ROS 2 application and run it under Lingua Franca (LF), a coordination language for deterministic execution using logical time, so that the same input always produces the same deterministic execution order. We first describe which ROS 2 features can be executed deterministically under logical time. Such features enable the possibility to establish an automatic conversion framework to extract information from a ROS 2 application and directly convert it into an LF program. The rich features of LF, such as logical-time delays, federated execution across processes, and fault handling, can then be applied to make the ROS 2 application be executed in a deterministic and timing-predictable manner without changing the ROS 2 code. We evaluate the framework on a synthetic example and on the Autoware reference system. We show that the order in which callbacks are executed differs in default ROS 2, while also having end-to-end latencies that vary across executions. In contrast, our LF-controlled ROS 2 system produces a deterministic execution order and consistent end-to-end latencies.
翻译:机器人操作系统2(ROS 2)是一种广泛应用于机器人系统的中间件,其核心机制为发布-订阅通信模式,计算过程由ROS 2执行器调度的回调函数构建。尽管ROS 2广受欢迎,但其发布-订阅模式本质上具有非确定性:即使在单执行器内部,回调的执行顺序也是非确定的;而分布式部署中消息在节点间的交织以及网络延迟进一步加剧了非确定性。这种非确定性常引发并发问题,并导致几乎无法进行安全性分析与保证。我们提出一种框架,能够将未经修改的ROS 2应用转换至Lingua Franca(LF)——一种基于逻辑时间实现确定性执行的协调语言——下运行,从而确保相同输入始终产生相同的确定性执行顺序。首先,我们阐明哪些ROS 2特性可在逻辑时间框架下实现确定性执行。这些特性使得建立自动化转换框架成为可能,该框架可从ROS 2应用中提取信息并直接转换为LF程序。随后,LF的丰富特性(如逻辑时间延迟、跨进程联邦执行及故障处理)可被应用于ROS 2应用,在不修改其代码的前提下实现确定性与时序可预测的执行。我们通过合成示例与Autoware参考系统对该框架进行评估。实验表明:默认ROS 2中回调的执行顺序在不同运行中存在差异,且端到端延迟具有可变性;而经LF控制的ROS 2系统则能产生确定的执行顺序与一致的端到端延迟。