广告广告位招商联系 ads@irunion.comA5 · 728×90(移动端 320×100) · 参考价 ¥300/月了解详情 →

【Editorial】A hard current loop on an MCU and a non-real-time ROS 2 node: where is the deadline, and who misses it?

Started by FPGA_ARM_Linux · 2026-11-14 04:27 UTC · 33 views · 1 replies
F Member
【Editorial Discussion】

A common architecture puts a fast current or joint loop on a microcontroller and a planner, state machine, or logging stack on a ROS 2 computer. When the motion looks late or jittery, the two sides blame each other. The first need is a stated deadline on each interface (cycle of the MCU loop, freshness of a command, freshness of a feedback message) and a measurement of who missed it.

1) The MCU loop should keep running on its own clock with a defined behaviour if a new command does not arrive: hold the last safe command, go to a brake, or follow a local profile — and it should log the miss. A loop that silently holds an old torque command can look like a ROS 2 bug.

2) ROS 2 nodes that write commands must measure their own jitter (callback duration, executor, lock, logging). A Python node, a log in the same thread, or a discovery spike can miss a period without the MCU being at fault. Move non-critical work off the command path.

3) Time stamps and clocks should be comparable. If the MCU and the computer do not share a reasonable clock discipline, “late” is undefined. State the time base on the interface.

4) Test the contract by delaying or dropping a command on purpose and confirming the safe behaviour. If that test does not exist, the deadline is only a comment.

Open question: where do you put the hard deadline — only on the MCU, or also on the ROS 2 command stream? What was the last actual missed deadline in your stack, and in which process? Practical partitions are welcome.
R Member
我的做法是两边都设 deadline,但性质不同:硬 deadline 只放在 MCU 侧。电流环按自身时钟跑,命令超时就按约定的安全行为处理,比如保持上一条安全力矩、斜坡降到零或抱闸,并且把超时次数和持续时间记下来——静默沿用旧命令最容易被误判成 ROS2 的 bug。ROS2 侧则做命令新鲜度检查:每条命令带序号和时间戳,发布端统计回调耗时和执行器抖动,超过周期就丢弃旧命令而不是补发;同时把日志、参数读写这些非关键工作移出命令路径。时钟方面,MCU 和上位机至少要有一个可比的时间基准,否则“晚了多少”根本没法量化,排查时先对齐时钟再谈抖动。
广告广告位招商联系 ads@irunion.comA6 · 728×90(移动端 320×100) · 参考价 ¥200/月了解详情 →
Log in or register to reply.