Using lgtm.com and fixing found alerts (#1452)

* lgtm in readme, and mac nui fixes

* call super inits in radars

* unused imports, dup lines

* more radars, more unused imports

* pass CP into RadarInterfaceBase

* more fixups

* unused imports

* delete unused lines

* ugh, new unused import

Co-authored-by: George Hotz <geohot@gmail.com>
albatross
George Hotz 2020-05-02 12:07:34 -07:00 committed by GitHub
parent 846a58507f
commit 1295cfe06c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 27 additions and 164 deletions

View File

@ -327,3 +327,6 @@ NO WARRANTY EXPRESSED OR IMPLIED.**
--- ---
<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/1061157-bc7e9bf3b246ece7322e6ffe653f6af8-medium_jpg.jpg?buster=1458363130" width="75"></img> <img src="https://cdn-images-1.medium.com/max/1600/1*C87EjxGeMPrkTuVRVWVg4w.png" width="225"></img> <img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/1061157-bc7e9bf3b246ece7322e6ffe653f6af8-medium_jpg.jpg?buster=1458363130" width="75"></img> <img src="https://cdn-images-1.medium.com/max/1600/1*C87EjxGeMPrkTuVRVWVg4w.png" width="225"></img>
[![Total alerts](https://img.shields.io/lgtm/alerts/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:python)

View File

@ -135,8 +135,6 @@ def get_network_strength(network_type):
# from SignalStrength.java # from SignalStrength.java
def get_lte_level(rsrp, rssnr): def get_lte_level(rsrp, rssnr):
INT_MAX = 2147483647 INT_MAX = 2147483647
lvl_rsrp = NetworkStrength.unknown
lvl_rssnr = NetworkStrength.unknown
if rsrp == INT_MAX: if rsrp == INT_MAX:
lvl_rsrp = NetworkStrength.unknown lvl_rsrp = NetworkStrength.unknown
elif rsrp >= -95: elif rsrp >= -95:
@ -174,7 +172,6 @@ def get_network_strength(network_type):
return lvl return lvl
def get_gsm_level(asu): def get_gsm_level(asu):
lvl = NetworkStrength.unknown
if asu <= 2 or asu == 99: if asu <= 2 or asu == 99:
lvl = NetworkStrength.unknown lvl = NetworkStrength.unknown
elif asu >= 12: elif asu >= 12:

View File

@ -1,14 +1,11 @@
import os import os
import sys
import time import time
import tempfile import tempfile
import threading import threading
import urllib.parse import urllib.parse
import pycurl import pycurl
import hashlib
from io import BytesIO from io import BytesIO
from tenacity import retry, wait_random_exponential, stop_after_attempt from tenacity import retry, wait_random_exponential, stop_after_attempt
from common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir
class URLFile(object): class URLFile(object):
_tlocal = threading.local() _tlocal = threading.local()

View File

@ -1,6 +1,5 @@
import sys import sys
import pygame import pygame
from pygame.locals import *
class Window(): class Window():
def __init__(self, w, h, caption="window", double=False): def __init__(self, w, h, caption="window", double=False):

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os, glob import os
import ast import ast
import stat import stat
import subprocess import subprocess

View File

@ -27,10 +27,10 @@ def main():
proc.join() proc.join()
cloudlog.event("athenad exited", exitcode=proc.exitcode) cloudlog.event("athenad exited", exitcode=proc.exitcode)
time.sleep(5) time.sleep(5)
except: except Exception:
cloudlog.exception("manage_athenad.exception") cloudlog.exception("manage_athenad.exception")
finally: finally:
params.delete(ATHENA_MGR_PID_PARAM) params.delete(ATHENA_MGR_PID_PARAM)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -48,8 +48,7 @@ def _address_to_track(address):
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
self.pts = {} super().__init__(CP)
self.delay = 0 # Delay of radar #TUNE
self.rcp = _create_radar_can_parser() self.rcp = _create_radar_can_parser()
self.updated_messages = set() self.updated_messages = set()
self.trigger_msg = LAST_MSG self.trigger_msg = LAST_MSG

View File

@ -19,13 +19,10 @@ def _create_radar_can_parser(car_fingerprint):
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
# radar super().__init__(CP)
self.pts = {}
self.validCnt = {key: 0 for key in RADAR_MSGS} self.validCnt = {key: 0 for key in RADAR_MSGS}
self.track_id = 0 self.track_id = 0
self.delay = 0 # Delay of radar
self.rcp = _create_radar_can_parser(CP.carFingerprint) self.rcp = _create_radar_can_parser(CP.carFingerprint)
self.trigger_msg = 0x53f self.trigger_msg = 0x53f
self.updated_messages = set() self.updated_messages = set()

View File

@ -43,10 +43,7 @@ def create_radar_can_parser(car_fingerprint):
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
# radar super().__init__(CP)
self.pts = {}
self.delay = 0 # Delay of radar
self.rcp = create_radar_can_parser(CP.carFingerprint) self.rcp = create_radar_can_parser(CP.carFingerprint)

View File

@ -20,8 +20,7 @@ def _create_nidec_can_parser():
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
# radar super().__init__(CP)
self.pts = {}
self.track_id = 0 self.track_id = 0
self.radar_fault = False self.radar_fault = False
self.radar_wrong_config = False self.radar_wrong_config = False

View File

@ -24,9 +24,7 @@ def get_radar_can_parser(CP):
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
# radar super().__init__(CP)
self.pts = {}
self.delay = 0 # Delay of radar
self.rcp = get_radar_can_parser(CP) self.rcp = get_radar_can_parser(CP)
self.updated_messages = set() self.updated_messages = set()
self.trigger_msg = 0x420 self.trigger_msg = 0x420

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from cereal import car from cereal import car
from selfdrive.config import Conversions as CV
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
from selfdrive.car.nissan.values import CAR from selfdrive.car.nissan.values import CAR
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint

View File

@ -1,6 +1,5 @@
import copy import copy
import crcmod import crcmod
from selfdrive.car.nissan.values import CAR
nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff)

View File

@ -30,11 +30,8 @@ def _create_radar_can_parser(car_fingerprint):
class RadarInterface(RadarInterfaceBase): class RadarInterface(RadarInterfaceBase):
def __init__(self, CP): def __init__(self, CP):
# radar super().__init__(CP)
self.pts = {}
self.track_id = 0 self.track_id = 0
self.delay = 0 # Delay of radar
self.radar_ts = CP.radarTimeStep self.radar_ts = CP.radarTimeStep
if CP.carFingerprint in TSS2_CAR: if CP.carFingerprint in TSS2_CAR:

View File

@ -98,7 +98,7 @@ FINGERPRINTS = {
}, },
#2017 German Prius #2017 German Prius
{ {
36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296:8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8,740: 5, 742: 8, 743: 8, 767:4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1792: 8, 1767:4, 800: 8, 1863:8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1990: 8, 1992: 8, 1996:8, 1998: 8, 2002: 8, 2010: 8, 2015: 8, 2016: 8, 2018: 8, 2024: 8, 2026: 8, 2030: 8 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296:8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8,740: 5, 742: 8, 743: 8, 767:4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1792: 8, 1767:4, 1863:8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1990: 8, 1992: 8, 1996:8, 1998: 8, 2002: 8, 2010: 8, 2015: 8, 2016: 8, 2018: 8, 2024: 8, 2026: 8, 2030: 8
}], }],
#Corolla w/ added Pedal Support (512L and 513L) #Corolla w/ added Pedal Support (512L and 513L)
CAR.COROLLA: [{ CAR.COROLLA: [{
@ -151,7 +151,7 @@ FINGERPRINTS = {
}, },
{ {
# 2019 XSE # 2019 XSE
36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767:4, 800: 8, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767:4, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8
}], }],
CAR.CAMRYH: [ CAR.CAMRYH: [
#SE, LE and LE with Blindspot Monitor #SE, LE and LE with Blindspot Monitor

View File

@ -40,7 +40,7 @@ else:
__excepthook__ = sys.excepthook __excepthook__ = sys.excepthook
def handle_exception(*exc_info): def handle_exception(*exc_info):
if exc_info[0] not in (KeyboardInterrupt, SystemExit): if exc_info[0] not in (KeyboardInterrupt, SystemExit):
capture_exception(exc_info=exc_info) capture_exception()
__excepthook__(*exc_info) __excepthook__(*exc_info)
sys.excepthook = handle_exception sys.excepthook = handle_exception

View File

@ -2,8 +2,7 @@
import os import os
import argparse import argparse
import signal import signal
from collections import deque, defaultdict from collections import defaultdict
from statistics import mean
import cereal.messaging as messaging import cereal.messaging as messaging

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import sys
import argparse import argparse
import struct import struct
from collections import deque from collections import deque
@ -8,7 +7,6 @@ from statistics import mean
from cereal import log from cereal import log
import cereal.messaging as messaging import cereal.messaging as messaging
from cereal.services import service_list
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -3,7 +3,6 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from selfdrive.controls.lib.longitudinal_mpc import libmpc_py from selfdrive.controls.lib.longitudinal_mpc import libmpc_py
from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG
import math
# plot liongitudinal MPC trajectory by defining boundary conditions: # plot liongitudinal MPC trajectory by defining boundary conditions:
# ego and lead vehicles state. Use this script to tune MPC costs # ego and lead vehicles state. Use this script to tune MPC costs
@ -16,7 +15,7 @@ def RW(v_ego, v_l):
def NORM_RW_ERROR(v_ego, v_l, p): def NORM_RW_ERROR(v_ego, v_l, p):
return (RW(v_ego, v_l) + 4.0 - p) return (RW(v_ego, v_l) + 4.0 - p)
return (RW(v_ego, v_l) + 4.0 - p) / (np.sqrt(v_ego + 0.5) + 0.1) #return (RW(v_ego, v_l) + 4.0 - p) / (np.sqrt(v_ego + 0.5) + 0.1)
v_ego = 20.0 v_ego = 20.0
@ -36,7 +35,7 @@ a_lead_tau = 0.
# a_lead_tau = 2.90729817665 # a_lead_tau = 2.90729817665
min_a_lead_tau = (a_lead**2 * math.pi) / (2 * (v_lead + 0.01)**2) #min_a_lead_tau = (a_lead**2 * math.pi) / (2 * (v_lead + 0.01)**2)
min_a_lead_tau = 0.0 min_a_lead_tau = 0.0
print(a_lead_tau, min_a_lead_tau) print(a_lead_tau, min_a_lead_tau)

View File

@ -1,67 +0,0 @@
#!/usr/bin/env python3
"""
This tool can be used to quickly changes the values in a JSON file used for tuning
Keys like in vim:
- h: decrease by 0.05
- l: increase by 0.05
- k: move pointer up
- j: move pointer down
"""
import tty
import sys
import json
import termios
from collections import OrderedDict
FILENAME = '/data/tuning.json'
def read_tuning():
while True:
try:
return json.loads(open(FILENAME).read())
except:
pass
def main():
dat = json.loads(open(FILENAME, 'r').read())
dat = OrderedDict(sorted(dat.items(), key=lambda i: i[0]))
cur = 0
while True:
sys.stdout.write("\x1Bc")
for i, (k, v) in enumerate(dat.items()):
prefix = "> " if cur == i else " "
print((prefix + k).ljust(20) + "%.2f" % v)
key = sys.stdin.read(1)[0]
write = False
if key == "k":
cur = max(0, cur - 1)
elif key == "j":
cur = min(len(dat.keys()) - 1, cur + 1)
elif key == "l":
dat[dat.keys()[cur]] += 0.05
write = True
elif key == "h":
dat[dat.keys()[cur]] -= 0.05
write = True
elif key == "q":
break
if write:
open(FILENAME, 'w').write(json.dumps(dat))
if __name__ == "__main__":
orig_settings = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
try:
main()
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings)
except:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, orig_settings)
raise

View File

@ -182,7 +182,6 @@ class Localizer():
initial_pose_ecef_quat = quat_from_euler(initial_pose_ecef) initial_pose_ecef_quat = quat_from_euler(initial_pose_ecef)
gps_speed = log.speed gps_speed = log.speed
quat_uncertainty = 0.2**2 quat_uncertainty = 0.2**2
initial_pose_ecef_quat = quat_from_euler(initial_pose_ecef)
initial_state = LiveKalman.initial_x initial_state = LiveKalman.initial_x
initial_covs_diag = LiveKalman.initial_P_diag initial_covs_diag = LiveKalman.initial_P_diag

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import zmq
import cereal.messaging as messaging import cereal.messaging as messaging
from cereal.services import service_list
import pcap import pcap
def main(): def main():

View File

@ -10,7 +10,7 @@ try: # bacause this crashes somtimes when running pipeline
subprocess.check_output(["make", "-C", _visiond_dir, "-f", subprocess.check_output(["make", "-C", _visiond_dir, "-f",
os.path.join(_visiond_dir, "visiontest.mk"), os.path.join(_visiond_dir, "visiontest.mk"),
_libvisiontest]) _libvisiontest])
except: except Exception:
pass pass
class VisionTest(): class VisionTest():

View File

@ -21,7 +21,6 @@ import subprocess
from aenum import Enum from aenum import Enum
from lru import LRU from lru import LRU
from functools import wraps from functools import wraps
from concurrent.futures import ThreadPoolExecutor, as_completed
from tools.lib.cache import cache_path_for_file_path from tools.lib.cache import cache_path_for_file_path
from tools.lib.exceptions import DataUnreadableError from tools.lib.exceptions import DataUnreadableError

View File

@ -4,10 +4,8 @@ import sys
import json import json
import bz2 import bz2
import tempfile import tempfile
import requests
import subprocess import subprocess
import urllib.parse import urllib.parse
from aenum import Enum
import capnp import capnp
import numpy as np import numpy as np

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2016, Comma.ai, Inc. # Copyright (c) 2016, Comma.ai, Inc.
import sys
import re import re
import binascii import binascii
@ -64,24 +63,3 @@ def simple_gen(of, config_record, w, h, framedata):
# + ebml_element(0xA7, ben(0)) # Position, uint # + ebml_element(0xA7, ben(0)) # Position, uint
+ ''.join(blocks))) + ''.join(blocks)))
if __name__ == "__main__":
import random
if len(sys.argv) != 2:
print("usage: %s mkvpath" % sys.argv[0])
with open(sys.argv[1], "rb") as f:
cr, index = mkvindex(f)
# cr = "280000003002000030010000010018004646563100cb070000000000000000000000000000000000".decode("hex")
def geti(i):
pos, length = index[i]
with open(sys.argv[1], "rb") as f:
f.seek(pos)
return f.read(length)
dats = [geti(random.randrange(200)) for _ in xrange(30)]
with open("tmpout.mkv", "wb") as of:
simple_gen(of, cr, dats)

View File

@ -23,7 +23,7 @@ if __name__ == "__main__":
poller = messaging.Poller() poller = messaging.Poller()
m = 'driverMonitoring' m = 'driverMonitoring'
sock = messaging.sub_sock(m, poller, addr=args.addr) messaging.sub_sock(m, poller, addr=args.addr)
pygame.init() pygame.init()
pygame.display.set_caption('livedm') pygame.display.set_caption('livedm')

View File

@ -6,4 +6,5 @@ moc_*
.qmake.stash .qmake.stash
nui.app/* nui.app/*
routes.json routes.json
_nui.app

View File

@ -15,7 +15,11 @@
static inline uint64_t nanos_since_boot() { static inline uint64_t nanos_since_boot() {
struct timespec t; struct timespec t;
clock_gettime(CLOCK_BOOTTIME, &t); #ifdef __APPLE__
clock_gettime(CLOCK_REALTIME, &t);
#else
clock_gettime(CLOCK_BOOTTIME, &t);
#endif
return t.tv_sec * 1000000000ULL + t.tv_nsec; return t.tv_sec * 1000000000ULL + t.tv_nsec;
} }

View File

@ -6,18 +6,11 @@ os.environ['BASEDIR'] = BASEDIR
SCALE = float(os.getenv("SCALE", 1.0)) SCALE = float(os.getenv("SCALE", 1.0))
import argparse import argparse
import zmq
import pygame import pygame
import numpy as np import numpy as np
import cv2 import cv2
import sys import sys
import traceback
from collections import namedtuple
from cereal import car
from common.params import Params
from tools.lib.lazy_property import lazy_property from tools.lib.lazy_property import lazy_property
from cereal.messaging import sub_sock, recv_one_or_none, recv_one
from cereal.services import service_list
import cereal.messaging as messaging import cereal.messaging as messaging
_BB_OFFSET = 0, 0 _BB_OFFSET = 0, 0
@ -33,8 +26,6 @@ def pygame_modules_have_loaded():
def ui_thread(addr, frame_address): def ui_thread(addr, frame_address):
context = zmq.Context.instance()
pygame.init() pygame.init()
pygame.font.init() pygame.font.init()
assert pygame_modules_have_loaded() assert pygame_modules_have_loaded()

View File

@ -1,4 +1,3 @@
import platform
from collections import namedtuple from collections import namedtuple
import matplotlib import matplotlib

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import carla import time
import os
import time, termios, tty, sys
import math import math
import atexit import atexit
import numpy as np import numpy as np
@ -9,7 +7,6 @@ import threading
import random import random
import cereal.messaging as messaging import cereal.messaging as messaging
import argparse import argparse
import queue
from common.params import Params from common.params import Params
from common.realtime import Ratekeeper from common.realtime import Ratekeeper
from lib.can import can_function, sendcan_function from lib.can import can_function, sendcan_function

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import time
import cereal.messaging as messaging import cereal.messaging as messaging
from opendbc.can.parser import CANParser from opendbc.can.parser import CANParser
from opendbc.can.packer import CANPacker from opendbc.can.packer import CANPacker
@ -92,13 +91,3 @@ def sendcan_function(sendcan):
return (gas, brake, steer_torque) return (gas, brake, steer_torque)
if __name__ == "__main__":
pm = messaging.PubMaster(['can'])
sendcan = messaging.sub_sock('sendcan')
idx = 0
while 1:
sendcan_function(sendcan)
can_function(pm, 10.0, idx)
time.sleep(0.01)
idx += 1