1. 时间类型

征程 6 内部的时间类型如下

图片

Linux 系统时间是基于 arm system counter 抽象的,Linux 的基于 arm system counter 抽象了很多种时间,图中画了两种。CLOCK_MONOTONIC_RAW 是不会被时间同步调整的。

image.png

2. Frame 时间戳

从 VIO 侧获取的图像数据,带有时间戳信息,相关信息如下:

typedef struct image_info_s {
    uint16_t sensor_id; /
< sensor id */
**    uint32_t pipeline_id; /**
< pipeline id */
    uint32_t frame_id; /
< frame id */
**    uint64_t time_stamp; /**
< HW time stamp */
    struct timeval tv; /
< system time of hal get buf */
**    int32_t buf_index; /**
< buffer index */
    int32_t img_format; /
< image format */
**    int32_t fd[HB_VIO_BUFFER_MAX_PLANES]; /**
< ion buf fd */
    uint32_t size[HB_VIO_BUFFER_MAX_PLANES]; /
< buffer size per plane */
**    uint32_t planeCount; /**
< image plane count */
    uint32_t dynamic_flag; /
< dynamic flag */
**    uint32_t water_mark_line; /**
< water mark line value */
    VIO_DATA_TYPE_E data_type; /
< buffer data type */
**    buffer_state_e state; /**
< buffer state */
    uint64_t desc; /
< temp description for isp raw feedback */
**    struct timeval trig_tv;/**
< system time of lpwm trigger */
} image_info_t;

time_stamp:代表收到第一行到达时刻,获取的是 system count;

struct timeval tv: 代表收到第一行到达时刻,时间戳来源有 3 个地方, 分别代表 RTC 时戳,wall time,PHC 时戳,可通过/sys/devices/platform/soc/soc:globaltime/globaltime 配置;

struct timeval trig_tv: 同 tv,代表 LPWM trigger 时刻;

image.png

  • RTC、PHC 是可以被时间同步调整的,直接调整的是硬件 counter。
    ○ PHC 时间获取:驱动调用 hobot_eth_get_phc_time 接口
    ○ RTC 时间获取:CIM 可以通过读寄存器直接拿到 RTC 时间,不建议调用接口获取 RTC 时间 ■ RTC 精确到秒的时间:应用层可以获取

        ■ RTC 精确到纳秒的时间:                           
            □ 如果时间同步在同步 RTC,不允许其他应用获取 RTC 时间,因为获取 RTC 时间可能                    导致 RTC 时间异常改变,这个是硬件限制。                           
            □ 如果不做 RTC 的时间同步,应用层可以获取 RTC 时间
  • 车载系统一般使用 PHC 时间域,所以 frame timestamps 选择 PHC 时钟源的情况偏多,当前具体使用哪个时钟源,看具体方案;

地平线智驾开发者
7 声望5 粉丝

地平线智能驾驶开发者社区旨在连接智能驾驶领域的开发者和对相关技术感兴趣的其他行业开发者、从业者。