FInal fixes to move to message factory

This commit is contained in:
Piv
2020-03-05 19:40:34 +10:30
parent 9878aaf6a4
commit c52237cae4
2 changed files with 5 additions and 4 deletions

View File

@@ -20,7 +20,6 @@ class SlamStreamer:
self._map_meters = map_meters self._map_meters = map_meters
self._lidar_connection = lidar_connection self._lidar_connection = lidar_connection
self._port = port self._port = port
self._zmq_context = self._create_context()
def start(self): def start(self):
''' '''

View File

@@ -4,6 +4,8 @@ from threading import Thread
from persontracking import algorithms from persontracking import algorithms
import persontracking.lidar_tracker_pb2 as tracker_pb import persontracking.lidar_tracker_pb2 as tracker_pb
import zmq import zmq
import Messaging.message_factory as mf
import Messaging.messages as messages
class LidarCache(): class LidarCache():
@@ -36,8 +38,7 @@ class LidarCache():
Performs a scan for the given number of iterations. Performs a scan for the given number of iterations.
''' '''
# Create the 0MQ socket first. This should not be passed between threads. # Create the 0MQ socket first. This should not be passed between threads.
self._socket = self._create_socket() self._mFactory = mf.getZmqPubSubStreamer(self.port)
self._socket.bind("tcp://*:" + str(self.port))
for i, scan in enumerate(self.lidar.iter_scans(min_len=self.measurements)): for i, scan in enumerate(self.lidar.iter_scans(min_len=self.measurements)):
print('%d: Got %d measurments' % (i, len(scan))) print('%d: Got %d measurments' % (i, len(scan)))
@@ -53,7 +54,8 @@ class LidarCache():
def fireGroupsChanged(self): def fireGroupsChanged(self):
# Send the updated groups to 0MQ socket. # Send the updated groups to 0MQ socket.
self._socket.send_multipart(["lidar_map", tracker_pb.PointScan(points=[]).SerializeToString()]) self._mFactory.send_message_topic("lidar_map", messages.ProtoMessage(
message=tracker_pb.PointScan(points=[]).SerializeToString()))
def stop_scanning(self): def stop_scanning(self):
self.run = False self.run = False