TIdy up, regenerate slam proto to include port

This commit is contained in:
Piv
2020-02-12 20:29:25 +10:30
parent a7d5e8010f
commit 1d69b7cbbb
3 changed files with 29 additions and 18 deletions

View File

@@ -27,20 +27,19 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
print('Setting throttle to: ' + str(request.throttle))
self.set_timeout(3)
throttleFailed = self.motor.set_throttle(request.throttle)
return motorService_pb2.ThrottleResponse(throttleSet = throttleFailed)
return motorService_pb2.ThrottleResponse(throttleSet=throttleFailed)
def SetSteering(self, request, context):
# TODO: Fix this to use the motor object as well to check for bounds.
print('Setting steering to: ' + str(request.steering))
self.servo.value = request.steering
return motorService_pb2.SteeringResponse(steeringSet = True)
return motorService_pb2.SteeringResponse(steeringSet=True)
def set_timeout(self, min_timeout):
"""Stops the old timer and restarts it to the specified time.
min_timeout -- The minimum time that can be used for the timer.
vary_timout -- Default 200, the additional random varying time (0 - vary_timeout) to add to timer.
"""
"""
if self._timer is not None:
self._timer.cancel()
self._timer = Timer(min_timeout, self.timeout_elapsed)
@@ -54,7 +53,8 @@ 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)
SlamController_pb2_grpc.add_SlamControlServicer_to_server(self.create_slam_servicer(), server)
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')
@@ -74,6 +74,7 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
return grpc.ssl_server_credentials([[pvtKeyBytes, pvtCertBytes]])
motor = Motor()
servo = Servo(18)
servicer = MotorServicer(motor, servo)