This function determines the time point when the player was first away from the reference position, and then determines the last time that its velocity away from the reference position was smaller than a threshold. Positions are initially median-filtered, and so is the computed velocity. All calculations are performed without resampling.
movement data frame
reference position, a list containing `pos_x` and `pos_z`
minimum distance from reference position to determine escape
span of the median filter
minimum speed to determine start of escape
minimum time to start searching for escape
maximum time to search for escape
currently disabled (only needed for debugging)
Developer note: if escape is imposed on an ongoing movement away from bush, it might not be detected by this algorithm based on a fixed velocity criterion. However, it can actually be ambiguous to decide whether the escape was planned before or after the min_time. The algorithm could potentially be improved by using an acceleration criterion (e.g. zero crossing) but the tracker data are a bit noisy and this would require some more elaborate signal processing/filtering.