Add 'car/' from commit 'eee0e8dc445691e600680f4abc77f2814b20b054'
git-subtree-dir: car git-subtree-mainline:1d29a5526cgit-subtree-split:eee0e8dc44
This commit is contained in:
33
car/control/PythonRemoteController.py
Normal file
33
car/control/PythonRemoteController.py
Normal 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'))
|
||||
Reference in New Issue
Block a user