Implement throttle stream in MotoServer
This commit is contained in:
@@ -15,12 +15,17 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
|
||||
self.servo = Servo(servo_pin)
|
||||
self._timer = None
|
||||
|
||||
def SetThrottle(self, request, context):
|
||||
def SetThrottle(self, request_iterator, context):
|
||||
# If we don't get a response every 3 seconds, stop the car.
|
||||
# This isn't a stream right now, however may change it to be so since we'll constantly
|
||||
# be sending values...
|
||||
throttleFailed = False
|
||||
for throttleRequest in request_iterator:
|
||||
self.set_timeout(timeout_length)
|
||||
return motorService_pb2.ThrottleResponse(throttleSet = (True if self.motor.set_throttle(request.throttle) else False))
|
||||
throttleFailed = self.motor.set_throttle(throttleRequest.throttle)
|
||||
if throttleFailed:
|
||||
break
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user