Fix motor control

This commit is contained in:
Piv
2020-03-19 23:21:52 +10:30
parent c6b9ae4d6e
commit b16b0900cd

View File

@@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from threading import Timer, Thread from threading import Timer, Thread
from gpiozero import Servo, Device
from concurrent import futures from concurrent import futures
import time import time
@@ -10,7 +9,6 @@ import grpc
import control.motorService_pb2 as motorService_pb2 import control.motorService_pb2 as motorService_pb2
import control.motorService_pb2_grpc as motorService_pb2_grpc import control.motorService_pb2_grpc as motorService_pb2_grpc
from control.gpiozero.vehicle import Vehicle from control.gpiozero.vehicle import Vehicle
from control.gpiozero.mockvehicle import MockVehicle
from slam.slam_servicer import SlamServicer from slam.slam_servicer import SlamServicer
import slam.SlamController_pb2_grpc as SlamController_pb2_grpc import slam.SlamController_pb2_grpc as SlamController_pb2_grpc
import tracking.lidar_tracker_pb2_grpc as lidar_tracker_pb2_grpc import tracking.lidar_tracker_pb2_grpc as lidar_tracker_pb2_grpc
@@ -25,11 +23,10 @@ class MotorServicer(motorService_pb2_grpc.CarControlServicer):
def SetThrottle(self, request, context): def SetThrottle(self, request, context):
# gRPC streams currently don't work between python and android. # gRPC streams currently don't work between python and android.
# If we don't get a response every 3 seconds, stop the car. # If we don't get a response every 3 seconds, stop the car.
throttleFailed = False
print('Setting throttle to: ' + str(request.throttle)) print('Setting throttle to: ' + str(request.throttle))
self.set_timeout(3) self.set_timeout(3)
throttleFailed = self.vehicle.set_throttle(request.throttle) self.vehicle.throttle = request.throttle
return motorService_pb2.ThrottleResponse(throttleSet=throttleFailed) return motorService_pb2.ThrottleResponse(throttleSet=True)
def SetSteering(self, request, context): def SetSteering(self, request, context):
print('Setting steering to: ' + str(request.steering)) print('Setting steering to: ' + str(request.steering))