diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index fe582779e3..58d78d2dbf 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -27,7 +27,9 @@ LDW_MIN_SPEED = 31 * CV.MPH_TO_MS LANE_DEPARTURE_THRESHOLD = 0.1 STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees + SIMULATION = "SIMULATION" in os.environ +NOSENSOR = "NOSENSOR" in os.environ ThermalStatus = log.ThermalData.ThermalStatus State = log.ControlsState.OpenpilotState @@ -192,9 +194,9 @@ class Controls: else: self.events.add(EventName.preLaneChangeRight) elif self.sm['pathPlan'].laneChangeState in [LaneChangeState.laneChangeStarting, - LaneChangeState.laneChangeFinishing]: + LaneChangeState.laneChangeFinishing]: self.events.add(EventName.laneChange) - + if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): self.events.add(EventName.canError) if self.mismatch_counter >= 200: @@ -206,13 +208,12 @@ class Controls: self.events.add(EventName.commIssue) if not self.sm['pathPlan'].mpcSolutionValid: self.events.add(EventName.plannerError) - if not self.sm['liveLocationKalman'].sensorsOK and os.getenv("NOSENSOR") is None: + if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR: if self.sm.frame > 5 / DT_CTRL: # Give locationd some time to receive all the inputs self.events.add(EventName.sensorDataInvalid) - if not self.sm['liveLocationKalman'].gpsOK and (self.distance_traveled > 1000) and os.getenv("NOSENSOR") is None: + if not self.sm['liveLocationKalman'].gpsOK and (self.distance_traveled > 1000): # Not show in first 1 km to allow for driving out of garage. This event shows after 5 minutes - # GPS is not yet working in a simulation - if not SIMULATION: + if not (SIMULATION or NOSENSOR): # TODO: send GPS in carla self.events.add(EventName.noGps) if not self.sm['pathPlan'].paramsValid: self.events.add(EventName.vehicleModelInvalid) @@ -231,8 +232,7 @@ class Controls: self.events.add(EventName.relayMalfunction) if self.sm['plan'].fcw: self.events.add(EventName.fcw) - if self.sm['model'].frameDropPerc > 1: - if not SIMULATION: + if self.sm['model'].frameDropPerc > 1 and (not SIMULATION): self.events.add(EventName.modeldLagging) # Only allow engagement with brake pressed when stopped behind another stopped car