Refactor python module structure

This commit is contained in:
Piv
2020-03-05 21:43:22 +10:30
parent 043c8783a4
commit 82a214c209
24 changed files with 20 additions and 120 deletions

View File

@@ -0,0 +1,33 @@
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'))