Use the throttle as the heartbeat message.

This commit is contained in:
Piv
2019-09-22 19:45:49 +09:30
parent d14bae53f6
commit 37622b58f8
4 changed files with 11 additions and 126 deletions

View File

@@ -16,6 +16,10 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
self._timer = None
def SetThrottle(self, request, 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...
self.set_timeout(timeout_length)
return motorService_pb2.ThrottleResponse(throttleSet = (True if self.motor.set_throttle(request.throttle) else False))
def SetSteering(self, request, context):
@@ -23,12 +27,6 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
self.servo.value = request.steering
return motorService_pb2.SteeringResponse(steeringSet = True)
def Heartbeat(self, request, 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...
self.set_timeout(timeout_length)
def set_timeout(self, min_timeout):
"""Stops the old timer and restarts it to the specified time.