R/processing_movement_functions.R
find_movement_latencies.RdThis function is useful to align for example tracker and mocap data when they are not precisely synchronised. The two movement trajectories must be in the same coordinate system, but they can have a spatial translation, different scaling, and different sampling rate.
First movement data frame, must have a column time
Second movement data frame, must have a column time
(String) vector of column names for xyz position of the first data frame
(String) vector of column names for xyz position of the second data frame
Scaling of the first movement trajectory (e.g. 1 for m or 10e-3 for mm)
Scaling of the second movement trajectory (e.g. 1 for m or 10e-3 for mm)
Sampling rate used for the comparison
Two-element vector of the interval for the optimisation
A list with elements and lag (estimated lag in s) and dist
(residual spatial distance after mean translation subtracted from both data frames)
The function uses brute force by a simple grid-search at the specified sample rate and over the specified interval.