Skip to content

Commit

Permalink
created data merge worker
Browse files Browse the repository at this point in the history
  • Loading branch information
ashum68 committed Jun 12, 2024
1 parent f9efc53 commit 3127cbd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Empty file added modules/data_merge/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions modules/data_merge/data_merge_worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
Merges local drone odometry with LiDAR detections
"""

from worker import queue_wrapper
from worker import worker_controller

from modules import detection_and_odometry
from modules import drone_odometry_local
from modules import lidar_detection


def data_merge_worker(
detection_input_queue: queue_wrapper.QueueWrapper,
odometry_input_queue: queue_wrapper.QueueWrapper,
output_queue: queue_wrapper.QueueWrapper,
controller: worker_controller.WorkerController,
) -> None:
"""
Worker process.
Expects lidar detections to be more frequent than odometry readings.
detection_input_queue, odometry_input_queue, output_queue are data queues.
controller is how the main process communicates to this worker process.
"""
detections = []
while not controller.is_exit_requested():
controller.check_pause()

detection: lidar_detection.LidarDetection = detection_input_queue.queue.get_nowait()
detections.append(detection)

odometry: drone_odometry_local.DroneOdometryLocal = odometry_input_queue.queue.get_nowait()

if odometry is not None:
result, merged = detection_and_odometry.DetectionAndOdometry.create(
detections, odometry
)

if not result:
continue

detections = []
output_queue.queue.put(merged)

0 comments on commit 3127cbd

Please sign in to comment.