Skip to content

Commit

Permalink
[ObjectTracker] do not reset distances when using consistent gradient…
Browse files Browse the repository at this point in the history
… method.
  • Loading branch information
AbdelrhmanBassiouny committed Dec 28, 2024
1 parent fc10c8c commit c85fdb9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/episode_segmenter/event_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c85fdb9

Please sign in to comment.