Make the lidar streamer ready to work with main controller
This commit is contained in:
@@ -19,12 +19,13 @@ class LidarCache():
|
||||
self.run = True
|
||||
self.tracking_group_number = -1
|
||||
self.currentGroups = None
|
||||
self._group_listeners = []
|
||||
|
||||
def start_cache(self, sender):
|
||||
self.thread = Thread(target=self.do_scanning, args=[sender])
|
||||
def start_cache(self):
|
||||
self.thread = Thread(target=self.do_scanning)
|
||||
self.thread.start()
|
||||
|
||||
def do_scanning(self, listener):
|
||||
def do_scanning(self):
|
||||
"""Performs scans whilst cache is running, and will pass calculated groups data to the sender.
|
||||
|
||||
Parameters
|
||||
@@ -33,8 +34,6 @@ class LidarCache():
|
||||
Any object that includes the onGroupsChanged method.
|
||||
|
||||
"""
|
||||
# Create the 0MQ socket first. This should not be passed between threads.
|
||||
self._mFactory = listener
|
||||
|
||||
# Batch over scans, so we don't need to do our own batching to determine groups
|
||||
# TODO: Implement custom batching, as iter_scans can be unreliable
|
||||
@@ -65,7 +64,21 @@ class LidarCache():
|
||||
pointScan.points.append(tracker_pb.Point(
|
||||
angle=point[1], distance=point[2], group_number=group.number))
|
||||
|
||||
self._mFactory.onGroupsChanged(pointScan)
|
||||
for listener in self._group_listeners:
|
||||
listener.onGroupsChanged(pointScan)
|
||||
|
||||
def add_groups_changed_listener(self, listener):
|
||||
"""
|
||||
Add a listener for a change in scans. THis will provide a tuple with the new group
|
||||
scans, which can then be sent off to a network listener for display, or to update the
|
||||
vehicle with a new velocity.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
listener
|
||||
An object that implements the onGroupsChanged(message) method.
|
||||
"""
|
||||
self._group_listeners.append(listener)
|
||||
|
||||
def stop_scanning(self):
|
||||
self.run = False
|
||||
|
||||
Reference in New Issue
Block a user