From 88b956528e614dc7429d525d5d7e09b5431d7b38 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 22 Oct 2020 16:28:54 -0700 Subject: [PATCH] camera malfunction alert (#2391) * camera malfunction alert * bump cereal * fix process replay * ugh, needs refactor --- cereal | 2 +- selfdrive/controls/controlsd.py | 8 +++++--- selfdrive/controls/lib/events.py | 4 ++++ selfdrive/test/longitudinal_maneuvers/plant.py | 8 ++++---- selfdrive/test/process_replay/process_replay.py | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cereal b/cereal index 7128f46571..b39fb46a72 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 7128f46571c9a2cafb350f13e8dcaf28d0f4134d +Subproject commit b39fb46a72aa26b3220ea7d78476fede39ca361e diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 8dd19a54d9..4950dc21c6 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -52,7 +52,7 @@ class Controls: self.sm = sm if self.sm is None: - self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration', + self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration', 'frontFrame', 'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman']) self.can_sock = can_sock @@ -236,7 +236,9 @@ class Controls: if self.sm['plan'].fcw: self.events.add(EventName.fcw) if self.sm['model'].frameDropPerc > 1 and (not SIMULATION): - self.events.add(EventName.modeldLagging) + self.events.add(EventName.modeldLagging) + if not self.sm.alive['frontFrame']: + self.events.add(EventName.cameraMalfunction) # Only allow engagement with brake pressed when stopped behind another stopped car if CS.brakePressed and self.sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED \ @@ -456,7 +458,7 @@ class Controls: self.pm.send('sendcan', can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) force_decel = (self.sm['dMonitoringState'].awarenessStatus < 0.) or \ - (self.state == State.softDisabling) + (self.state == State.softDisabling) steer_angle_rad = (CS.steeringAngle - self.sm['pathPlan'].angleOffset) * CV.DEG_TO_RAD diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index be23d3b0f9..dd425ddbd1 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -472,6 +472,10 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo ET.PERMANENT: NormalPermanentAlert("Fan Malfunction", "Contact Support"), }, + EventName.cameraMalfunction: { + ET.PERMANENT: NormalPermanentAlert("Camera Malfunction", "Contact Support"), + }, + # ********** events that affect controls state transitions ********** EventName.pcmEnable: { diff --git a/selfdrive/test/longitudinal_maneuvers/plant.py b/selfdrive/test/longitudinal_maneuvers/plant.py index dffda44068..eba0933c8e 100755 --- a/selfdrive/test/longitudinal_maneuvers/plant.py +++ b/selfdrive/test/longitudinal_maneuvers/plant.py @@ -112,7 +112,7 @@ class Plant(): Plant.logcan = messaging.pub_sock('can') Plant.sendcan = messaging.sub_sock('sendcan') Plant.model = messaging.pub_sock('model') - Plant.frame_pub = messaging.pub_sock('frame') + Plant.front_frame = messaging.pub_sock('frontFrame') Plant.live_params = messaging.pub_sock('liveParameters') Plant.live_location_kalman = messaging.pub_sock('liveLocationKalman') Plant.health = messaging.pub_sock('health') @@ -162,7 +162,7 @@ class Plant(): def close(self): Plant.logcan.close() Plant.model.close() - Plant.frame_pub.close() + Plant.front_frame.close() Plant.live_params.close() Plant.live_location_kalman.close() @@ -393,7 +393,7 @@ class Plant(): if publish_model and self.frame % 5 == 0: md = messaging.new_message('model') cal = messaging.new_message('liveCalibration') - fp = messaging.new_message('frame') + fp = messaging.new_message('frontFrame') md.model.frameId = 0 for x in [md.model.path, md.model.leftLane, md.model.rightLane]: x.points = [0.0]*50 @@ -425,7 +425,7 @@ class Plant(): # fake values? Plant.model.send(md.to_bytes()) Plant.cal.send(cal.to_bytes()) - Plant.frame_pub.send(fp.to_bytes()) + Plant.front_frame.send(fp.to_bytes()) Plant.logcan.send(can_list_to_can_capnp(can_msgs)) diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index a58ed4ee80..3596096a2b 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -221,7 +221,7 @@ CONFIGS = [ pub_sub={ "can": ["controlsState", "carState", "carControl", "sendcan", "carEvents", "carParams"], "thermal": [], "health": [], "liveCalibration": [], "dMonitoringState": [], "plan": [], "pathPlan": [], "gpsLocation": [], "liveLocationKalman": [], - "model": [], "frame": [], + "model": [], "frontFrame": [], }, ignore=["logMonoTime", "valid", "controlsState.startMonoTime", "controlsState.cumLagMs"], init_callback=fingerprint,