From e308b14623b48753e0e2eabd9a002da3152660a5 Mon Sep 17 00:00:00 2001 From: diyjac Date: Tue, 5 Sep 2017 21:50:14 -0400 Subject: [PATCH] feat: Add parameter to disable tl_detector.py for field testing on Carla --- requirements-carla-downgrade.txt | 9 +++++++++ requirements-carla-upgrade.txt | 9 +++++++++ ros/launch/site-without-lights.launch | 17 ++++++++++++++++ ros/launch/styx-without-lights.launch | 20 +++++++++++++++++++ .../tl_sim_detector_without_lights.launch | 6 ++++++ .../tl_site_detector_without_lights.launch | 6 ++++++ ros/src/tl_detector/tl_detector.py | 20 +++++++++++++++---- 7 files changed, 83 insertions(+), 4 deletions(-) create mode 100755 requirements-carla-downgrade.txt create mode 100755 requirements-carla-upgrade.txt create mode 100644 ros/launch/site-without-lights.launch create mode 100755 ros/launch/styx-without-lights.launch create mode 100644 ros/src/tl_detector/launch/tl_sim_detector_without_lights.launch create mode 100644 ros/src/tl_detector/launch/tl_site_detector_without_lights.launch diff --git a/requirements-carla-downgrade.txt b/requirements-carla-downgrade.txt new file mode 100755 index 00000000..240f4cf0 --- /dev/null +++ b/requirements-carla-downgrade.txt @@ -0,0 +1,9 @@ +Flask>=0.11.1 +attrdict>=2.0.0 +eventlet>=0.19.0 +python-socketio>=1.6.1 +numpy>=1.13.1 +Pillow>=2.2.1 +scipy +tensorflow==0.12 +h5py diff --git a/requirements-carla-upgrade.txt b/requirements-carla-upgrade.txt new file mode 100755 index 00000000..3100ea89 --- /dev/null +++ b/requirements-carla-upgrade.txt @@ -0,0 +1,9 @@ +Flask>=0.11.1 +attrdict>=2.0.0 +eventlet>=0.19.0 +python-socketio>=1.6.1 +numpy>=1.13.1 +Pillow>=2.2.1 +scipy +tensorflow>=1.0.0 +h5py diff --git a/ros/launch/site-without-lights.launch b/ros/launch/site-without-lights.launch new file mode 100644 index 00000000..f48fe97e --- /dev/null +++ b/ros/launch/site-without-lights.launch @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/ros/launch/styx-without-lights.launch b/ros/launch/styx-without-lights.launch new file mode 100755 index 00000000..29a4d253 --- /dev/null +++ b/ros/launch/styx-without-lights.launch @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ros/src/tl_detector/launch/tl_sim_detector_without_lights.launch b/ros/src/tl_detector/launch/tl_sim_detector_without_lights.launch new file mode 100644 index 00000000..027ff1bd --- /dev/null +++ b/ros/src/tl_detector/launch/tl_sim_detector_without_lights.launch @@ -0,0 +1,6 @@ + + + + + + diff --git a/ros/src/tl_detector/launch/tl_site_detector_without_lights.launch b/ros/src/tl_detector/launch/tl_site_detector_without_lights.launch new file mode 100644 index 00000000..027ff1bd --- /dev/null +++ b/ros/src/tl_detector/launch/tl_site_detector_without_lights.launch @@ -0,0 +1,6 @@ + + + + + + diff --git a/ros/src/tl_detector/tl_detector.py b/ros/src/tl_detector/tl_detector.py index 041def14..f93776d1 100755 --- a/ros/src/tl_detector/tl_detector.py +++ b/ros/src/tl_detector/tl_detector.py @@ -49,7 +49,11 @@ def __init__(self): self.upcoming_light_pub = rospy.Publisher('/traffic_waypoint', Int32, queue_size=1) self.bridge = CvBridge() - self.light_classifier = TLClassifier(rospy.get_param('~model_path')) + self.path = rospy.get_param('~model_path') + if self.path != "NONE": + self.light_classifier = TLClassifier(self.path) + else: + self.light_classifier = None self.init = True self.state = TrafficLight.UNKNOWN @@ -77,6 +81,8 @@ def loop(self): self.sub_raw_image = None self.last_wp = -1 self.upcoming_light_pub.publish(Int32(self.last_wp)) + elif self.light_classifier is None: + self.upcoming_light_pub.publish(Int32(-1)) rate.sleep() def pose_cb(self, msg): @@ -89,8 +95,11 @@ def pose_cb(self, msg): self.orientation.z, self.orientation.w]) self.theta = euler[2] - if self.light_classifier.predict is None: - print "NOT MOVING! Initializing TRAFFIC LIGHT DETECTOR...." + if self.light_classifier is not None: + if self.light_classifier.predict is None: + print "NOT MOVING! Initializing TRAFFIC LIGHT DETECTOR...." + else: + print "WARNING! NO TRAFFIC LIGHT DETECTOR...." def waypoints_cb(self, msg): # make our own copy of the waypoints - they are static and do not change @@ -231,7 +240,10 @@ def get_light_state(self, light): image = np.copy(cv_image) #Get classification - classification = self.light_classifier.get_classification(image) + if self.light_classifier is not None: + classification = self.light_classifier.get_classification(image) + else: + classification = TrafficLight.UNKNOWN print "traffic light: ", label[classification] return classification