From 78847664104b28a8d6e8be9bc0daee386adc797b Mon Sep 17 00:00:00 2001 From: Piv <18462828+Piv200@users.noreply.github.com> Date: Sun, 29 Sep 2019 21:14:16 +0930 Subject: [PATCH] Use car package and ghetto singleton motor/servo. --- MotorControl/MotorServer.py | 12 ++++++++---- MotorControl/motorService_pb2_grpc.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MotorControl/MotorServer.py b/MotorControl/MotorServer.py index a1e89a0..e042e5a 100755 --- a/MotorControl/MotorServer.py +++ b/MotorControl/MotorServer.py @@ -6,17 +6,21 @@ from concurrent import futures import grpc -import motorService_pb2 -import motorService_pb2_grpc +import car.MotorControl.motorService_pb2 as motorService_pb2 +import car.MotorControl.motorService_pb2_grpc as motorService_pb2_grpc from MotorControl.gpiozero.motor_session import Motor servo_pin = 18 timeout_length = 3 +motor = Motor() +servo = Servo() + class MotorServicer(motorService_pb2_grpc.CarControlServicer): def __init__(self): - self.motor = Motor() - self.servo = Servo(servo_pin) + global motor, servo + self.motor = motor + self.servo = servo self._timer = None def SetThrottle(self, request_iterator, context): diff --git a/MotorControl/motorService_pb2_grpc.py b/MotorControl/motorService_pb2_grpc.py index 995aec8..93e3a6d 100644 --- a/MotorControl/motorService_pb2_grpc.py +++ b/MotorControl/motorService_pb2_grpc.py @@ -1,7 +1,7 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -import motorService_pb2 as motorService__pb2 +import car.MotorControl.motorService_pb2 as motorService__pb2 class CarControlStub(object):