ROS 时间同步问题

1、问题:

"This error occurs when the timestamps of the sensor messages that are received differ more than 1 second. This is probably an indication of timing issues in your system, e.g. the clocks of two hosts connected to the same ros core are not synchronized."

The most common cause of this is that you're running on 2 or more computers and their system clocks are out of sync by x seconds. It's recommended to setup ntp servers to keep all computers in sync.

1. 安装

sudo apt-get install ntpdate
2. 检查和某台主机的时间差 sudo ntpdate -q 192.168.1.102 %最后是目标主机IP地址
3. 如果时间差较大,需要安装chrony来同步系统时间 sudo apt-get install chrony 编辑某台机器上的 /etc/chrony/chrony.conf 文件, 添加另一台机器作为服务器。 举例: 你打算让机器人RC1获取笔记本PC1的时间,你可以这样写: server PC1 minpoll 0 maxpoll 5 maxdelay .05

这样的话,机器人系统时间就会慢慢地同步到你笔记本的时间。 如果机器人和你笔记本的时间差非常的花,你可以使用一下几句让机器人系统时间和笔记本系统时间立即同步: /etc/init.d/chrony stop ntpdate other_computer_ip /etc/init.d/chrony start
(root 用户)但是,大的时间跳动会带来一些问题,因此除非迫不得已,不建议这么做。 如果你使用的是wifi网络,并且时间没有同步,你可以把 maxdelay 的值调的大一些。
4. 隔离网络问题 如果是隔离网络,也就是你的机器人/服务器和任何外部设备都没有网络连接,系统时间只能通过一个参考始终获取。 请参考这里: https://chrony.tuxfamily.org/manual.html#Isolated-networks
原文地址:https://www.cnblogs.com/lovebay/p/11205871.html