Add SlamController stuff
This commit is contained in:
@@ -10,8 +10,9 @@ import grpc
|
||||
import MotorControl.motorService_pb2 as motorService_pb2
|
||||
import MotorControl.motorService_pb2_grpc as motorService_pb2_grpc
|
||||
from MotorControl.gpiozero.motor_session import Motor
|
||||
from SlamController.slam_streamer import SlamStreamer
|
||||
import SlamController.SlamController_pb2_grpc as SlamController_pb2_grpc
|
||||
|
||||
servo_pin = 18
|
||||
|
||||
class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
||||
def __init__(self, motor, servo):
|
||||
@@ -53,13 +54,17 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
||||
def start_server(self):
|
||||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=8))
|
||||
motorService_pb2_grpc.add_CarControlServicer_to_server(self, server)
|
||||
# Disable security for local testing.
|
||||
SlamController_pb2_grpc.add_SlamControlServicer_to_server(self.create_slam_servicer(), server)
|
||||
# Disable tls for local testing.
|
||||
# server.add_secure_port('[::]:50051', self.create_credentials())
|
||||
server.add_insecure_port('[::]:50051')
|
||||
server.start()
|
||||
while True:
|
||||
time.sleep(60*60)
|
||||
|
||||
def create_slam_servicer(self):
|
||||
return SlamStreamer()
|
||||
|
||||
def create_credentials(self):
|
||||
pvtKeyPath = '/home/pi/tls/device.key'
|
||||
pvtCertPath = '/home/pi/tls/device.crt'
|
||||
@@ -70,7 +75,7 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
||||
return grpc.ssl_server_credentials([[pvtKeyBytes, pvtCertBytes]])
|
||||
|
||||
motor = Motor()
|
||||
servo = Servo(servo_pin)
|
||||
servo = Servo(18)
|
||||
servicer = MotorServicer(motor, servo)
|
||||
|
||||
service_thread = Thread(target=servicer.start_server)
|
||||
|
||||
Reference in New Issue
Block a user