Skip to main content

ClockModel

Struct ClockModel 

Source
pub struct ClockModel {
    pub gain: f64,
    pub offset: f64,
    pub residuals: f64,
    pub n_measurements: u64,
}
Expand description

Linear clock synchronization model for multi-camera systems.

This structure implements a linear transformation to synchronize timestamps between different clock sources (e.g., camera hardware clocks vs. host system clock). The transformation follows the equation: host_time = gain * device_time + offset.

The clock model is essential for multi-camera synchronization in the Strand Camera system, allowing timestamps from different sources to be aligned to a common time reference.

§Mathematical Model

The linear relationship is: t_host = gain × t_device + offset

  • gain: Clock rate ratio (typically close to 1.0)
  • offset: Time offset between clock sources
  • residuals: Sum of squared residuals from the linear fit
  • n_measurements: Number of data points used to compute the model

§Examples

use strand_cam_bui_types::ClockModel;

// Create a clock model with typical values
let clock_model = ClockModel {
    gain: 1.000001,           // Slightly faster device clock
    offset: -1234567.89,      // Device clock started earlier
    residuals: 0.001,         // Good fit quality
    n_measurements: 100,      // Based on 100 sync points
};

// Convert device timestamp to host timestamp
let device_time = 1000.0;
let host_time = clock_model.gain * device_time + clock_model.offset;

Fields§

§gain: f64

Clock rate ratio between device and host clocks.

This represents how fast the device clock runs relative to the host clock. A value of 1.0 means identical rates, > 1.0 means the device clock runs faster, and < 1.0 means it runs slower.

§offset: f64

Time offset between device and host clocks.

This is the constant offset needed to align the two time sources. The offset accounts for differences in when the clocks were started and any systematic time differences.

§residuals: f64

Sum of squared residuals from the linear regression fit.

This value indicates the quality of the linear fit - smaller values indicate better synchronization. It’s computed during the least-squares fitting process used to determine the gain and offset parameters.

§n_measurements: u64

Number of timestamp measurements used to compute this model.

More measurements typically lead to better model accuracy. The synchronization system collects timestamp pairs over time to build a robust clock model.

Trait Implementations§

Source§

impl Clone for ClockModel

Source§

fn clone(&self) -> ClockModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClockModel

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ClockModel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ClockModel

Source§

fn eq(&self, other: &ClockModel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ClockModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ClockModel

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,