Skip to content

Commit

Permalink
Update rc_driver.py
Browse files Browse the repository at this point in the history
Fixed exit without error issue
  • Loading branch information
hamuchiwa authored May 2, 2019
1 parent f74fdcc commit 52d1931
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions computer/rc_driver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__author__ = 'zhengwang'

import cv2
import sys
import threading
import socketserver
Expand Down Expand Up @@ -100,12 +101,12 @@ def handle(self):
prediction = self.nn.predict(image_array)

# stop conditions
if sensor_data and int(sensor_data) < d_sensor_thresh: #
if sensor_data and int(sensor_data) < self.d_sensor_thresh:
print("Stop, obstacle in front")
self.rc_car.stop()
sensor_data = None

elif 0 < self.d_stop_sign < d_stop_light_thresh and stop_sign_active:
elif 0 < self.d_stop_sign < self.d_stop_light_thresh and stop_sign_active:
print("Stop sign ahead")
self.rc_car.stop()

Expand All @@ -124,7 +125,7 @@ def handle(self):
stop_flag = False
stop_sign_active = False

elif 0 < self.d_light < d_stop_light_thresh:
elif 0 < self.d_light < self.d_stop_light_thresh:
# print("Traffic light ahead")
if self.obj_detection.red_light:
print("Red light")
Expand All @@ -136,15 +137,15 @@ def handle(self):
print("Yellow light flashing")
pass

self.d_light = d_stop_light_thresh
self.d_light = self.d_stop_light_thresh
self.obj_detection.red_light = False
self.obj_detection.green_light = False
self.obj_detection.yellow_light = False

else:
self.rc_car.steer(prediction)
self.stop_start = cv2.getTickCount()
self.d_stop_sign = d_stop_light_thresh
self.d_stop_sign = self.d_stop_light_thresh

if stop_sign_active is False:
self.drive_time_after_stop = (self.stop_start - self.stop_finish) / cv2.getTickFrequency()
Expand Down

0 comments on commit 52d1931

Please sign in to comment.