Use PAIR socket for slam, tidy up python stuff.
This commit is contained in:
@@ -3,19 +3,21 @@ import slam_streamer as slam
|
||||
from threading import Thread
|
||||
|
||||
class SlamServicer(SlamController_pb2_grpc.SlamControlServicer):
|
||||
slam_thread = None
|
||||
|
||||
def __init__(self, lidar_connection):
|
||||
print('Servicer initialised')
|
||||
self.slam = slam.SlamStreamer(lidar_connection=lidar_connection)
|
||||
|
||||
def start_map_streaming(self, request, context):
|
||||
if not hasattr(self, 'slamThread'):
|
||||
if self.slam_thread is None:
|
||||
# Don't bother creating and starting slam more than once.
|
||||
self.slam.port = request.port
|
||||
self.slam.map_pixels = request.map_size_pixels
|
||||
self.slam.map_meters = request.map_size_meters
|
||||
slamThread = Thread(target=self.slam.start)
|
||||
slamThread.start()
|
||||
self.slam_thread = Thread(target=self.slam.start)
|
||||
self.slam_thread.start()
|
||||
|
||||
def stop_streaming(self, request, context):
|
||||
if hasattr(self, 'slamThread'):
|
||||
if self.slam_thread is not None:
|
||||
self.slam.stop_scanning()
|
||||
Reference in New Issue
Block a user