Files
picar/control/PythonRemoteController.py
2020-03-05 21:43:22 +10:30

34 lines
807 B
Python

print("Connecting to pi")
import grpc
from concurrent import futures
import motorService_pb2_grpc
from motorService_pb2 import SteeringRequest, ThrottleRequest
import time
throttle = 0.1
timer = None
class ThrottleIterator:
'''
Class to get the current throttle for the car.
Will return a random throttle between
'''
def __iter__(self):
return self
def __next__(self):
if throttle > 1 or throttle < -1:
raise StopIteration
time.sleep(1)
return ThrottleRequest(throttle=throttle)
channel = grpc.insecure_channel('10.0.0.53:50051')
stub = motorService_pb2_grpc.CarControlStub(channel)
response = stub.SetThrottle(ThrottleIterator())
while True:
throttle = int(input('Please enter a value for the throttle between -100 and 100'))