ROS2 多机时间同步(Chrony配置简明指南)

适用场景:

主机运行 ROS2 Humble(发布 /scan 等),板子运行 ROS2 Foxy(发布 /tf 等),两边通过 ROS_DOMAIN_ID 跨平台通讯。需要保证系统时间对齐,避免 TF 插值失败、建图抖动等问题。


一、主机端配置(NTP服务端)

1. 安装 chrony

bash 复制代码
sudo apt install chrony

2. 修改配置文件

bash 复制代码
sudo nano /etc/chrony/chrony.conf

将原有 pool 替换为:

conf 复制代码
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
local stratum 10
allow 192.168.0.0/16
bindaddress 0.0.0.0

确保这几项存在。

3. 重启并启用开机自启

bash 复制代码
sudo systemctl restart chrony
sudo systemctl enable chrony

4. 验证状态

bash 复制代码
chronyc tracking

确认输出中包含:

text 复制代码
Leap status     : Normal

二、板载设备配置(NTP客户端)

1. 安装 chrony

bash 复制代码
sudo apt install chrony

2. 修改配置文件

bash 复制代码
sudo nano /etc/chrony/chrony.conf

添加如下行(仅保留一条 server):

conf 复制代码
server 192.168.x.x iburst   # 改为你的主机 IP
makestep 1 3

3. 重启服务并启用开机自启

bash 复制代码
sudo systemctl restart chrony
sudo systemctl enable chrony

4. 验证同步结果

bash 复制代码
chronyc tracking

确认 Leap status 为 Normal,且时间偏差在 0.1 秒以内。


三、建图抖动消除建议

在 Cartographer 的 .lua 文件中添加:

lua 复制代码
lookup_transform_timeout_sec = 0.5

确保 .yamluse_sim_time: false,并开启 EKF 的 publish_tf: true


四、测试通过表现

  • ros2 launch 无任何 extrapolation 报错
  • rviz2 地图无抖动
  • /tf 和 /scan 时间戳一致
  • cartographer_node 日志正常,submap 插入稳定

相关推荐
绍磊leo3 天前
ROS2 交互式调试工具:告别繁琐的命令行操作
ros
kobesdu3 天前
连接大模型与物理机器人-RoboNeuron让机器人真正“听懂人话”
机器人·开源·ros·人形机器人
kobesdu3 天前
【ROS2实战笔记-13】Foxglove Studio:ROS可视化工具的另一条路
笔记·机器人·自动驾驶·ros
kobesdu3 天前
【ROS2实战笔记-12】rosshow:终端里的盲文可视化与无头机器人的现场调试
笔记·机器人·ros·移动机器人
txz20355 天前
2,使用功能包组织C++节点
开发语言·c++·ros
dragen_light8 天前
2.ROS2-Packages
ros
dragen_light8 天前
1.ROS2-Install
c++·python·ros
dragen_light8 天前
3.ROS2-Nodes
ros
dragen_light8 天前
4.ROS2-Language Libraries
ros
kobesdu11 天前
开源3D激光SLAM算法的异同点、优劣势与适配场景总结
算法·3d·机器人·ros