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 sourcesresiduals: Sum of squared residuals from the linear fitn_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: f64Clock 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: f64Time 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: f64Sum 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: u64Number 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
impl Clone for ClockModel
Source§fn clone(&self) -> ClockModel
fn clone(&self) -> ClockModel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more