27 lines
796 B
Python
27 lines
796 B
Python
import persontracking.lidar_tracker_pb2 as lidar_tracker_pb2
|
|
from persontracking.lidar_tracker_pb2_grpc import PersonTrackingServicer
|
|
from persontracking.lidar_cache import LidarCache
|
|
from multiprocessing import Process
|
|
|
|
|
|
class LidarServicer(PersonTrackingServicer):
|
|
lidar_thread = None
|
|
|
|
def __init__(self):
|
|
self.cache = LidarCache(measurements=100)
|
|
|
|
def set_tracking_group(self, request, context):
|
|
pass
|
|
|
|
def stop_tracking(self, request, context):
|
|
self.cache.stop_scanning()
|
|
self.lidar_thread.join()
|
|
self.lidar_thread = None
|
|
|
|
def start_tracking(self, request, context):
|
|
'''
|
|
Starts the lidar cache.
|
|
'''
|
|
if self.lidar_thread is None:
|
|
self.lidar_thread = Process(target=self.cache.do_scanning)
|