Skip to main content

ClockSynchronizer

Struct ClockSynchronizer 

Source
pub struct ClockSynchronizer { /* private fields */ }
Expand description

软件锁相环 (Software PLL) 与时间同步器

解决两个问题:

  1. 硬件时钟 (Hardware Timestamp) 通常与系统时钟 (System Time) 不同步。
  2. 硬件时钟存在漂移 (Drift),且 USB 传输导致到达时间 (Arrival Time) 有抖动 (Jitter)。

算法:基于最小二乘法的线性回归 (Linear Regression on Sliding Window)

Implementations§

Source§

impl ClockSynchronizer

Source

pub fn new(window_size: usize) -> Self

Source

pub fn correct(&mut self, hw_ns: u64, arrival_time: Instant) -> Duration

输入一帧的原始硬件时间戳,返回矫正后的系统时间

  • hw_ns: 驱动提供的硬件时间戳 (纳秒)
  • arrival_time: 帧到达用户态的系统时刻

Trait Implementations§

Source§

impl Debug for ClockSynchronizer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.