Use pub socket with a key for the sub in the envelope.
This commit is contained in:
@@ -33,12 +33,10 @@ class SlamStreamer:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
print('Starting to stream')
|
print('Starting to stream')
|
||||||
self._socket = self._start_socket(self._create_socket(self._zmq_context), self._port)
|
self._socket = self._start_socket(
|
||||||
|
self._create_socket(self._zmq_context), self._port)
|
||||||
|
|
||||||
# Block until user opens zmq.
|
print('Started and bound zmq socket.')
|
||||||
self._socket.recv()
|
|
||||||
|
|
||||||
print('Received message from ZMQ')
|
|
||||||
|
|
||||||
# Adapted from BreezySLAM rpslam example.
|
# Adapted from BreezySLAM rpslam example.
|
||||||
# Connect to Lidar unit
|
# Connect to Lidar unit
|
||||||
@@ -75,10 +73,10 @@ class SlamStreamer:
|
|||||||
map should be the result of slam.getmap.
|
map should be the result of slam.getmap.
|
||||||
location should be a tuple, the result of slam.getpos()
|
location should be a tuple, the result of slam.getpos()
|
||||||
'''
|
'''
|
||||||
protoScan = SlamScan(map = bytes(mapbytes), \
|
protoScan = SlamScan(map=bytes(mapbytes),
|
||||||
location=SlamLocation(x=location[0], y=location[1], theta=location[3]))
|
location=SlamLocation(x=location[0], y=location[1], theta=location[3]))
|
||||||
print('Sending map')
|
print('Sending map')
|
||||||
self._socket.send(protoScan.SerializeToString())
|
self._socket.send_multipart(b'slam_map', protoScan.SerializeToString())
|
||||||
|
|
||||||
def stop_scanning(self):
|
def stop_scanning(self):
|
||||||
self.can_scan = False
|
self.can_scan = False
|
||||||
@@ -87,7 +85,7 @@ class SlamStreamer:
|
|||||||
return zmq.Context.instance()
|
return zmq.Context.instance()
|
||||||
|
|
||||||
def _create_socket(self, context):
|
def _create_socket(self, context):
|
||||||
return context.socket(zmq.PAIR)
|
return context.socket(zmq.PUB)
|
||||||
|
|
||||||
def _start_socket(self, socket, port):
|
def _start_socket(self, socket, port):
|
||||||
socket.bind('tcp://*:' + str(self._port))
|
socket.bind('tcp://*:' + str(self._port))
|
||||||
|
|||||||
Reference in New Issue
Block a user