From c85fdb9f7019258ee5541d4c80908f450d6f147b Mon Sep 17 00:00:00 2001 From: A_Bassiouny Date: Sat, 28 Dec 2024 22:12:33 +0100 Subject: [PATCH] [ObjectTracker] do not reset distances when using consistent gradient method. --- src/episode_segmenter/event_detectors.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/episode_segmenter/event_detectors.py b/src/episode_segmenter/event_detectors.py index 52660d3..bdcbdaa 100644 --- a/src/episode_segmenter/event_detectors.py +++ b/src/episode_segmenter/event_detectors.py @@ -423,7 +423,7 @@ def __init__(self, logger: EventLogger, starter_event: NewObjectEvent, distance_ self.use_average_distance: bool = False self.use_consistent_gradient: bool = True - self.window_size: int = ceil(timedelta(milliseconds=500).total_seconds() / + self.window_size: int = ceil(timedelta(milliseconds=700).total_seconds() / self.measure_timestep.total_seconds()) self.latest_distances: List[float] = [] @@ -496,7 +496,8 @@ def is_moving(self) -> Optional[bool]: if self.window_size_reached and self.measure_timestep_passed: self._crop_distances_and_times_to_window_size() is_moving = self._is_motion_condition_met - self._reset_distances_and_times() + if not self.use_consistent_gradient: + self._reset_distances_and_times() return is_moving @property @@ -562,7 +563,7 @@ def _check_motion_using_consistent_gradient(self, distances: List[List[float]]) """ distance_arr = np.array(distances) x, y, z = distance_arr[:, 0], distance_arr[:, 1], distance_arr[:, 2] - is_moving = any(np.all(axes > 0) or np.all(axes < 0) for axes in [x, y, z]) + is_moving = any(np.all(axes > 1e-4) or np.all(axes < -1e-4) for axes in [x, y, z]) self.start_pose = self.latest_poses[-self.window_size] self.event_time = self.latest_times[-self.window_size] return is_moving