enable flake8 E502: backslash is redundant between brackets
parent
ebed2d1dcc
commit
6466ec982a
|
@ -17,7 +17,7 @@ repos:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
exclude: '^(pyextra)|(external)|(cereal)|(rednose)|(panda)|(laika)|(laika_repo)|(rednose_repo)/'
|
exclude: '^(pyextra)|(external)|(cereal)|(rednose)|(panda)|(laika)|(laika_repo)|(rednose_repo)/'
|
||||||
args:
|
args:
|
||||||
- --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E201,E202,E203,E226,E241,E265,E266,E302,E305,E402,E501,E502,E722,E741,W504
|
- --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E201,E202,E203,E226,E241,E265,E266,E302,E305,E402,E501,E722,E741,W504
|
||||||
- --statistics
|
- --statistics
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
|
|
@ -51,7 +51,7 @@ def ecef2geodetic(ecef, radians=False):
|
||||||
S = np.cbrt(1 + C + np.sqrt(C * C + 2 * C))
|
S = np.cbrt(1 + C + np.sqrt(C * C + 2 * C))
|
||||||
P = F / (3 * pow((S + 1 / S + 1), 2) * G * G)
|
P = F / (3 * pow((S + 1 / S + 1), 2) * G * G)
|
||||||
Q = np.sqrt(1 + 2 * esq * esq * P)
|
Q = np.sqrt(1 + 2 * esq * esq * P)
|
||||||
r_0 = -(P * esq * r) / (1 + Q) + np.sqrt(0.5 * a * a*(1 + 1.0 / Q) - \
|
r_0 = -(P * esq * r) / (1 + Q) + np.sqrt(0.5 * a * a*(1 + 1.0 / Q) -
|
||||||
P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r)
|
P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r)
|
||||||
U = np.sqrt(pow((r - esq * r_0), 2) + z * z)
|
U = np.sqrt(pow((r - esq * r_0), 2) + z * z)
|
||||||
V = np.sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z)
|
V = np.sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z)
|
||||||
|
|
2
panda
2
panda
|
@ -1 +1 @@
|
||||||
Subproject commit 8039638482ebedb9cd10cb1eac083631919ac95e
|
Subproject commit eba113cb677b53b868f166dd2437347698b1341e
|
|
@ -70,7 +70,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.buttonEvents = []
|
ret.buttonEvents = []
|
||||||
|
|
||||||
# events
|
# events
|
||||||
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], \
|
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low],
|
||||||
gas_resume_speed=2.)
|
gas_resume_speed=2.)
|
||||||
|
|
||||||
if ret.vEgo < self.CP.minSteerSpeed:
|
if ret.vEgo < self.CP.minSteerSpeed:
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CarController():
|
||||||
self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt'])
|
self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt'])
|
||||||
self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis'])
|
self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis'])
|
||||||
|
|
||||||
def update(self, enabled, CS, frame, actuators, \
|
def update(self, enabled, CS, frame, actuators,
|
||||||
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
|
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
|
||||||
|
|
||||||
P = self.params
|
P = self.params
|
||||||
|
|
|
@ -182,9 +182,9 @@ class CarInterface(CarInterfaceBase):
|
||||||
# In GM, PCM faults out if ACC command overlaps user gas.
|
# In GM, PCM faults out if ACC command overlaps user gas.
|
||||||
enabled = c.enabled and not self.CS.out.gasPressed
|
enabled = c.enabled and not self.CS.out.gasPressed
|
||||||
|
|
||||||
can_sends = self.CC.update(enabled, self.CS, self.frame, \
|
can_sends = self.CC.update(enabled, self.CS, self.frame,
|
||||||
c.actuators,
|
c.actuators,
|
||||||
hud_v_cruise, c.hudControl.lanesVisible, \
|
hud_v_cruise, c.hudControl.lanesVisible,
|
||||||
c.hudControl.leadVisible, c.hudControl.visualAlert)
|
c.hudControl.leadVisible, c.hudControl.visualAlert)
|
||||||
|
|
||||||
self.frame += 1
|
self.frame += 1
|
||||||
|
|
|
@ -96,8 +96,8 @@ class CarController():
|
||||||
|
|
||||||
self.params = CarControllerParams(CP)
|
self.params = CarControllerParams(CP)
|
||||||
|
|
||||||
def update(self, enabled, CS, frame, actuators, \
|
def update(self, enabled, CS, frame, actuators,
|
||||||
pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, \
|
pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel,
|
||||||
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
|
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
|
||||||
|
|
||||||
P = self.params
|
P = self.params
|
||||||
|
|
|
@ -269,7 +269,7 @@ class CarState(CarStateBase):
|
||||||
ret.cruiseState.speedOffset = calc_cruise_offset(0, ret.vEgo)
|
ret.cruiseState.speedOffset = calc_cruise_offset(0, ret.vEgo)
|
||||||
if self.CP.carFingerprint in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.ACCORDH, CAR.CRV_HYBRID, CAR.INSIGHT):
|
if self.CP.carFingerprint in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.ACCORDH, CAR.CRV_HYBRID, CAR.INSIGHT):
|
||||||
ret.brakePressed = cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] != 0 or \
|
ret.brakePressed = cp.vl["POWERTRAIN_DATA"]['BRAKE_PRESSED'] != 0 or \
|
||||||
(self.brake_switch and self.brake_switch_prev and \
|
(self.brake_switch and self.brake_switch_prev and
|
||||||
cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != self.brake_switch_ts)
|
cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != self.brake_switch_ts)
|
||||||
self.brake_switch_prev = self.brake_switch
|
self.brake_switch_prev = self.brake_switch
|
||||||
self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH']
|
self.brake_switch_ts = cp.ts["POWERTRAIN_DATA"]['BRAKE_SWITCH']
|
||||||
|
|
|
@ -44,12 +44,12 @@ class Controls:
|
||||||
# Setup sockets
|
# Setup sockets
|
||||||
self.pm = pm
|
self.pm = pm
|
||||||
if self.pm is None:
|
if self.pm is None:
|
||||||
self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', \
|
self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState',
|
||||||
'carControl', 'carEvents', 'carParams'])
|
'carControl', 'carEvents', 'carParams'])
|
||||||
|
|
||||||
self.sm = sm
|
self.sm = sm
|
||||||
if self.sm is None:
|
if self.sm is None:
|
||||||
self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration', \
|
self.sm = messaging.SubMaster(['thermal', 'health', 'model', 'liveCalibration',
|
||||||
'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman'])
|
'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman'])
|
||||||
|
|
||||||
self.can_sock = can_sock
|
self.can_sock = can_sock
|
||||||
|
@ -76,8 +76,8 @@ class Controls:
|
||||||
internet_needed or not openpilot_enabled_toggle
|
internet_needed or not openpilot_enabled_toggle
|
||||||
|
|
||||||
# detect sound card presence and ensure successful init
|
# detect sound card presence and ensure successful init
|
||||||
sounds_available = not os.path.isfile('/EON') or (os.path.isfile('/proc/asound/card0/state') \
|
sounds_available = (not os.path.isfile('/EON') or (os.path.isfile('/proc/asound/card0/state') and
|
||||||
and open('/proc/asound/card0/state').read().strip() == 'ONLINE')
|
open('/proc/asound/card0/state').read().strip() == 'ONLINE'))
|
||||||
|
|
||||||
car_recognized = self.CP.carName != 'mock'
|
car_recognized = self.CP.carName != 'mock'
|
||||||
# If stock camera is disconnected, we loaded car controls and it's not dashcam mode
|
# If stock camera is disconnected, we loaded car controls and it's not dashcam mode
|
||||||
|
@ -184,7 +184,7 @@ class Controls:
|
||||||
self.events.add(EventName.preLaneChangeLeft)
|
self.events.add(EventName.preLaneChangeLeft)
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ def long_control_state_trans(active, long_control_state, v_ego, v_target, v_pid,
|
||||||
output_gb, brake_pressed, cruise_standstill):
|
output_gb, brake_pressed, cruise_standstill):
|
||||||
"""Update longitudinal control state machine"""
|
"""Update longitudinal control state machine"""
|
||||||
stopping_condition = (v_ego < 2.0 and cruise_standstill) or \
|
stopping_condition = (v_ego < 2.0 and cruise_standstill) or \
|
||||||
(v_ego < STOPPING_EGO_SPEED and \
|
(v_ego < STOPPING_EGO_SPEED and
|
||||||
((v_pid < STOPPING_TARGET_SPEED and v_target < STOPPING_TARGET_SPEED) or
|
((v_pid < STOPPING_TARGET_SPEED and v_target < STOPPING_TARGET_SPEED) or
|
||||||
brake_pressed))
|
brake_pressed))
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ class PathPlanner():
|
||||||
self.lane_change_direction = LaneChangeDirection.none
|
self.lane_change_direction = LaneChangeDirection.none
|
||||||
else:
|
else:
|
||||||
torque_applied = sm['carState'].steeringPressed and \
|
torque_applied = sm['carState'].steeringPressed and \
|
||||||
((sm['carState'].steeringTorque > 0 and self.lane_change_direction == LaneChangeDirection.left) or \
|
((sm['carState'].steeringTorque > 0 and self.lane_change_direction == LaneChangeDirection.left) or
|
||||||
(sm['carState'].steeringTorque < 0 and self.lane_change_direction == LaneChangeDirection.right))
|
(sm['carState'].steeringTorque < 0 and self.lane_change_direction == LaneChangeDirection.right))
|
||||||
|
|
||||||
lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob
|
lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob
|
||||||
|
|
|
@ -73,7 +73,7 @@ class PIController():
|
||||||
|
|
||||||
# Update when changing i will move the control away from the limits
|
# Update when changing i will move the control away from the limits
|
||||||
# or when i will move towards the sign of the error
|
# or when i will move towards the sign of the error
|
||||||
if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or \
|
if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or
|
||||||
(error <= 0 and (control >= self.neg_limit or i > 0.0))) and \
|
(error <= 0 and (control >= self.neg_limit or i > 0.0))) and \
|
||||||
not freeze_integrator:
|
not freeze_integrator:
|
||||||
self.i = i
|
self.i = i
|
||||||
|
|
|
@ -83,11 +83,11 @@ class TestMonitoring(unittest.TestCase):
|
||||||
def test_fully_distracted_driver(self):
|
def test_fully_distracted_driver(self):
|
||||||
events_output, d_status = run_DState_seq(always_distracted, always_false, always_true, always_false)
|
events_output, d_status = run_DState_seq(always_distracted, always_false, always_true, always_false)
|
||||||
self.assertTrue(len(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)]) == 0)
|
self.assertTrue(len(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)]) == 0)
|
||||||
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL +\
|
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL +
|
||||||
((_DISTRACTED_PRE_TIME_TILL_TERMINAL-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.preDriverDistracted)
|
((_DISTRACTED_PRE_TIME_TILL_TERMINAL-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.preDriverDistracted)
|
||||||
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL +\
|
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL +
|
||||||
((_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.promptDriverDistracted)
|
((_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.promptDriverDistracted)
|
||||||
self.assertEqual(events_output[int((_DISTRACTED_TIME +\
|
self.assertEqual(events_output[int((_DISTRACTED_TIME +
|
||||||
((_TEST_TIMESPAN-10-_DISTRACTED_TIME)/2))/DT_DMON)].names[0], EventName.driverDistracted)
|
((_TEST_TIMESPAN-10-_DISTRACTED_TIME)/2))/DT_DMON)].names[0], EventName.driverDistracted)
|
||||||
self.assertIs(type(d_status.awareness), float)
|
self.assertIs(type(d_status.awareness), float)
|
||||||
|
|
||||||
|
@ -95,11 +95,11 @@ class TestMonitoring(unittest.TestCase):
|
||||||
def test_fully_invisible_driver(self):
|
def test_fully_invisible_driver(self):
|
||||||
events_output = run_DState_seq(always_no_face, always_false, always_true, always_false)[0]
|
events_output = run_DState_seq(always_no_face, always_false, always_true, always_false)[0]
|
||||||
self.assertTrue(len(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)]) == 0)
|
self.assertTrue(len(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)]) == 0)
|
||||||
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL +\
|
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL +
|
||||||
((_AWARENESS_PRE_TIME_TILL_TERMINAL-_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.preDriverUnresponsive)
|
((_AWARENESS_PRE_TIME_TILL_TERMINAL-_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.preDriverUnresponsive)
|
||||||
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PROMPT_TIME_TILL_TERMINAL +\
|
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PROMPT_TIME_TILL_TERMINAL +
|
||||||
((_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
((_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)].names[0], EventName.promptDriverUnresponsive)
|
||||||
self.assertEqual(events_output[int((_AWARENESS_TIME +\
|
self.assertEqual(events_output[int((_AWARENESS_TIME +
|
||||||
((_TEST_TIMESPAN-10-_AWARENESS_TIME)/2))/DT_DMON)].names[0], EventName.driverUnresponsive)
|
((_TEST_TIMESPAN-10-_AWARENESS_TIME)/2))/DT_DMON)].names[0], EventName.driverUnresponsive)
|
||||||
|
|
||||||
# 3. op engaged, down to orange, driver pays attention, back to normal; then down to orange, driver touches wheel
|
# 3. op engaged, down to orange, driver pays attention, back to normal; then down to orange, driver touches wheel
|
||||||
|
|
|
@ -49,23 +49,23 @@ if __name__ == "__main__":
|
||||||
img = np.zeros((320, 160, 3))
|
img = np.zeros((320, 160, 3))
|
||||||
if faceProb > 0.4:
|
if faceProb > 0.4:
|
||||||
cv2.putText(img, 'you', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (255, 255, 0))
|
cv2.putText(img, 'you', (int(facePosition[0]*160+40), int(facePosition[1]*320+110)), cv2.FONT_ITALIC, 0.5, (255, 255, 0))
|
||||||
cv2.rectangle(img, (int(facePosition[0]*160+40), int(facePosition[1]*320+120)),\
|
cv2.rectangle(img, (int(facePosition[0]*160+40), int(facePosition[1]*320+120)),
|
||||||
(int(facePosition[0]*160+120), int(facePosition[1]*320+200)), (255, 255, 0), 1)
|
(int(facePosition[0]*160+120), int(facePosition[1]*320+200)), (255, 255, 0), 1)
|
||||||
|
|
||||||
not_blink = evt.driverMonitoring.leftBlinkProb + evt.driverMonitoring.rightBlinkProb < 1
|
not_blink = evt.driverMonitoring.leftBlinkProb + evt.driverMonitoring.rightBlinkProb < 1
|
||||||
|
|
||||||
if evt.driverMonitoring.leftEyeProb > 0.6:
|
if evt.driverMonitoring.leftEyeProb > 0.6:
|
||||||
cv2.line(img, (int(facePosition[0]*160+95), int(facePosition[1]*320+140)),\
|
cv2.line(img, (int(facePosition[0]*160+95), int(facePosition[1]*320+140)),
|
||||||
(int(facePosition[0]*160+105), int(facePosition[1]*320+140)), (255, 255, 0), 2)
|
(int(facePosition[0]*160+105), int(facePosition[1]*320+140)), (255, 255, 0), 2)
|
||||||
if not_blink:
|
if not_blink:
|
||||||
cv2.line(img, (int(facePosition[0]*160+99), int(facePosition[1]*320+143)),\
|
cv2.line(img, (int(facePosition[0]*160+99), int(facePosition[1]*320+143)),
|
||||||
(int(facePosition[0]*160+101), int(facePosition[1]*320+143)), (255, 255, 0), 2)
|
(int(facePosition[0]*160+101), int(facePosition[1]*320+143)), (255, 255, 0), 2)
|
||||||
|
|
||||||
if evt.driverMonitoring.rightEyeProb > 0.6:
|
if evt.driverMonitoring.rightEyeProb > 0.6:
|
||||||
cv2.line(img, (int(facePosition[0]*160+55), int(facePosition[1]*320+140)),\
|
cv2.line(img, (int(facePosition[0]*160+55), int(facePosition[1]*320+140)),
|
||||||
(int(facePosition[0]*160+65), int(facePosition[1]*320+140)), (255, 255, 0), 2)
|
(int(facePosition[0]*160+65), int(facePosition[1]*320+140)), (255, 255, 0), 2)
|
||||||
if not_blink:
|
if not_blink:
|
||||||
cv2.line(img, (int(facePosition[0]*160+59), int(facePosition[1]*320+143)),\
|
cv2.line(img, (int(facePosition[0]*160+59), int(facePosition[1]*320+143)),
|
||||||
(int(facePosition[0]*160+61), int(facePosition[1]*320+143)), (255, 255, 0), 2)
|
(int(facePosition[0]*160+61), int(facePosition[1]*320+143)), (255, 255, 0), 2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue