10. Odin1时间同步

1. 说明

  • Odin1 目前使用开机时间作为系统时间,不方便进行二次开发
  • Odin1 提供ntp-like(模拟ntp方式)时间软同步功能,使得Odin1和主机进行时间同步

2. 使用方法

在驱动/odin1_ros_driver/config/control_command.yaml文件中配置“use_host_ros_time: 2”:

  # 0: use odin internal system time as data time stamp, typical and recommended;
  # 1: use host ros time (upon receive) as data time stamp, only use if you specifically require this setup, not recommended for most users
  # 2: align odin1 time to host time, timestamp is the sensor data reception time on host time axis
  use_host_ros_time: 2    

3. 原理实现

PC(host_sdk) 与 Odin1(liuyedao) 之间进行一次 ntp-like 的时间交互,记录 4 个时间戳:

  • t0:主机发布时间
  • t1:从机接收时间
  • t2:从机发布时间
  • t3:主机接收时间 time_synchronization

原理:

\[T_{\mathrm{delay}} = (t_3 - t_0) - (t_2 - t_1)\] \[T_{\mathrm{offset}} = \frac{(t_3 + t_0) - (t_2 + t_1)}{2}\]

(物理意义:T_o - T_offset)

实现:

  • delay和offset计算
    • 上位机心跳保温,携带发布时刻信息t0
    • 下位机接受心跳保温后,缓存t0和接收时刻t1
    • 下位机发布消息前,记录消息发布时刻 t2,将t0 t1 t2 打包在心跳应答包中
    • 上位机接受到心跳应答包,记录接受时刻t3
    • 根据公式计算
  • 数据时间戳补偿
    • 增加30帧滑动时间窗口,进行补偿和延迟时间的平滑
    • 若用户设置使用host时间,则将该补偿增加到,驱动发布的所有数据上

语言:
This site uses Just the Docs, a documentation theme for Jekyll.