cleanup controlsd env variable reading

pull/2153/head
Willem Melching 5 years ago
parent dbb11d64c9
commit d4328365e9
  1. 14
      selfdrive/controls/controlsd.py

@ -27,7 +27,9 @@ LDW_MIN_SPEED = 31 * CV.MPH_TO_MS
LANE_DEPARTURE_THRESHOLD = 0.1 LANE_DEPARTURE_THRESHOLD = 0.1
STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL
STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees
SIMULATION = "SIMULATION" in os.environ SIMULATION = "SIMULATION" in os.environ
NOSENSOR = "NOSENSOR" in os.environ
ThermalStatus = log.ThermalData.ThermalStatus ThermalStatus = log.ThermalData.ThermalStatus
State = log.ControlsState.OpenpilotState State = log.ControlsState.OpenpilotState
@ -192,7 +194,7 @@ class Controls:
else: else:
self.events.add(EventName.preLaneChangeRight) self.events.add(EventName.preLaneChangeRight)
elif self.sm['pathPlan'].laneChangeState in [LaneChangeState.laneChangeStarting, elif self.sm['pathPlan'].laneChangeState in [LaneChangeState.laneChangeStarting,
LaneChangeState.laneChangeFinishing]: LaneChangeState.laneChangeFinishing]:
self.events.add(EventName.laneChange) self.events.add(EventName.laneChange)
if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL):
@ -206,13 +208,12 @@ class Controls:
self.events.add(EventName.commIssue) self.events.add(EventName.commIssue)
if not self.sm['pathPlan'].mpcSolutionValid: if not self.sm['pathPlan'].mpcSolutionValid:
self.events.add(EventName.plannerError) 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 if self.sm.frame > 5 / DT_CTRL: # Give locationd some time to receive all the inputs
self.events.add(EventName.sensorDataInvalid) 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 # 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 or NOSENSOR): # TODO: send GPS in carla
if not SIMULATION:
self.events.add(EventName.noGps) self.events.add(EventName.noGps)
if not self.sm['pathPlan'].paramsValid: if not self.sm['pathPlan'].paramsValid:
self.events.add(EventName.vehicleModelInvalid) self.events.add(EventName.vehicleModelInvalid)
@ -231,8 +232,7 @@ class Controls:
self.events.add(EventName.relayMalfunction) self.events.add(EventName.relayMalfunction)
if self.sm['plan'].fcw: if self.sm['plan'].fcw:
self.events.add(EventName.fcw) self.events.add(EventName.fcw)
if self.sm['model'].frameDropPerc > 1: if self.sm['model'].frameDropPerc > 1 and (not SIMULATION):
if not SIMULATION:
self.events.add(EventName.modeldLagging) self.events.add(EventName.modeldLagging)
# Only allow engagement with brake pressed when stopped behind another stopped car # Only allow engagement with brake pressed when stopped behind another stopped car

Loading…
Cancel
Save