Enable more flake8 checks (#1602)
* enable some more flake8 checks * some more quick ones * bump opendbc * e401 * e711 e712 * e115 e116 * e222 * e301 * remove that * e129 * e701 e702 * e125 e131 * e227 * e306 * e262 * W503 * e713 * e704 * e731 * bump opendbc * fix some e722pull/1609/head
parent
4fcf47812b
commit
d9bf9f0a40
|
@ -17,7 +17,8 @@ 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:
|
||||||
- --select=F
|
- --ignore=E111,E114,E121,E122,E123,E124,E126,E127,E128,E201,E202,E203,E221,E225,E226,E231,E241,E251,E261,E265,E266,E302,E303,E305,E402,E501,E502,E722,E741,W504
|
||||||
|
- --statistics
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
|
|
|
@ -25,7 +25,7 @@ def get_imei(slot):
|
||||||
ret = parse_service_call_string(service_call(["iphonesubinfo", "3" ,"i32", str(slot)]))
|
ret = parse_service_call_string(service_call(["iphonesubinfo", "3" ,"i32", str(slot)]))
|
||||||
if not ret:
|
if not ret:
|
||||||
# allow non android to be identified differently
|
# allow non android to be identified differently
|
||||||
ret = "%015d" % random.randint(0, 1<<32)
|
ret = "%015d" % random.randint(0, 1 << 32)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_serial():
|
def get_serial():
|
||||||
|
@ -132,6 +132,7 @@ def get_network_type():
|
||||||
|
|
||||||
def get_network_strength(network_type):
|
def get_network_strength(network_type):
|
||||||
network_strength = NetworkStrength.unknown
|
network_strength = NetworkStrength.unknown
|
||||||
|
|
||||||
# from SignalStrength.java
|
# from SignalStrength.java
|
||||||
def get_lte_level(rsrp, rssnr):
|
def get_lte_level(rsrp, rssnr):
|
||||||
INT_MAX = 2147483647
|
INT_MAX = 2147483647
|
||||||
|
|
|
@ -39,4 +39,3 @@ def api_get(endpoint, method='GET', timeout=None, access_token=None, **params):
|
||||||
headers['User-Agent'] = "openpilot-" + version
|
headers['User-Agent'] = "openpilot-" + version
|
||||||
|
|
||||||
return requests.request(method, backend+endpoint, timeout=timeout, headers = headers, params=params)
|
return requests.request(method, backend+endpoint, timeout=timeout, headers = headers, params=params)
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,3 @@ if ANDROID:
|
||||||
else:
|
else:
|
||||||
PERSIST = os.path.join(BASEDIR, "persist")
|
PERSIST = os.path.join(BASEDIR, "persist")
|
||||||
PARAMS = os.path.join(BASEDIR, "persist", "params")
|
PARAMS = os.path.join(BASEDIR, "persist", "params")
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,8 @@ class AutoMoveTempdir():
|
||||||
def close(self):
|
def close(self):
|
||||||
os.rename(self._path, self._target_path)
|
os.rename(self._path, self._target_path)
|
||||||
|
|
||||||
def __enter__(self): return self
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, type, value, traceback):
|
||||||
if type is None:
|
if type is None:
|
||||||
|
@ -63,7 +64,8 @@ class NamedTemporaryDir():
|
||||||
def close(self):
|
def close(self):
|
||||||
shutil.rmtree(self._path)
|
shutil.rmtree(self._path)
|
||||||
|
|
||||||
def __enter__(self): return self
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback):
|
def __exit__(self, type, value, traceback):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
|
@ -68,8 +68,11 @@ class SwagErrorFilter(logging.Filter):
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
return record.levelno < logging.ERROR
|
return record.levelno < logging.ERROR
|
||||||
|
|
||||||
_tmpfunc = lambda: 0
|
def _tmpfunc():
|
||||||
_srcfile = os.path.normcase(_tmpfunc.__code__.co_filename)
|
return 0
|
||||||
|
|
||||||
|
def _srcfile():
|
||||||
|
return os.path.normcase(_tmpfunc.__code__.co_filename)
|
||||||
|
|
||||||
class SwagLogger(logging.Logger):
|
class SwagLogger(logging.Logger):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -6,6 +6,7 @@ def clip(x, lo, hi):
|
||||||
|
|
||||||
def interp(x, xp, fp):
|
def interp(x, xp, fp):
|
||||||
N = len(xp)
|
N = len(xp)
|
||||||
|
|
||||||
def get_interp(xv):
|
def get_interp(xv):
|
||||||
hi = 0
|
hi = 0
|
||||||
while hi < N and xv > xp[hi]:
|
while hi < N and xv > xp[hi]:
|
||||||
|
@ -14,8 +15,8 @@ def interp(x, xp, fp):
|
||||||
return fp[-1] if hi == N and xv > xp[low] else (
|
return fp[-1] if hi == N and xv > xp[low] else (
|
||||||
fp[0] if hi == 0 else
|
fp[0] if hi == 0 else
|
||||||
(xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low])
|
(xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low])
|
||||||
return [get_interp(v) for v in x] if hasattr(
|
|
||||||
x, '__iter__') else get_interp(x)
|
return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x)
|
||||||
|
|
||||||
def mean(x):
|
def mean(x):
|
||||||
return sum(x) / len(x)
|
return sum(x) / len(x)
|
||||||
|
|
|
@ -195,7 +195,8 @@ class DBReader(DBAccessor):
|
||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
|
|
||||||
def __exit__(self, type, value, traceback): pass
|
def __exit__(self, type, value, traceback):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DBWriter(DBAccessor):
|
class DBWriter(DBAccessor):
|
||||||
|
|
|
@ -43,4 +43,3 @@ class Profiler():
|
||||||
else:
|
else:
|
||||||
print("%30s: %9.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100))
|
print("%30s: %9.2f percent: %3.0f" % (n, ms*1000.0, ms/self.tot*100))
|
||||||
print("Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot))
|
print("Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot))
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class RunningStat():
|
||||||
self.S_last = 0.
|
self.S_last = 0.
|
||||||
else:
|
else:
|
||||||
self.M = self.M_last + (new_data - self.M_last) / self.n
|
self.M = self.M_last + (new_data - self.M_last) / self.n
|
||||||
self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M);
|
self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M)
|
||||||
self.M_last = self.M
|
self.M_last = self.M
|
||||||
self.S_last = self.S
|
self.S_last = self.S
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ def replace_right(s, old, new, occurrence):
|
||||||
# replace_right('1232425', '2', ' ', 2) -> '123 4 5'
|
# replace_right('1232425', '2', ' ', 2) -> '123 4 5'
|
||||||
|
|
||||||
split = s.rsplit(old, occurrence)
|
split = s.rsplit(old, occurrence)
|
||||||
return new.join(split)
|
return new.join(split)
|
||||||
|
|
|
@ -6,4 +6,3 @@ def phone_only(x):
|
||||||
return x
|
return x
|
||||||
else:
|
else:
|
||||||
return nottest(x)
|
return nottest(x)
|
||||||
|
|
||||||
|
|
|
@ -25,4 +25,3 @@ class Timeout:
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
signal.alarm(0)
|
signal.alarm(0)
|
||||||
|
|
||||||
|
|
|
@ -145,4 +145,3 @@ def pretransform_from_calib(calib):
|
||||||
camera_frame_from_road_frame = np.dot(eon_intrinsics, view_frame_from_road_frame)
|
camera_frame_from_road_frame = np.dot(eon_intrinsics, view_frame_from_road_frame)
|
||||||
camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame)
|
camera_frame_from_calib_frame = get_camera_frame_from_calib_frame(camera_frame_from_road_frame)
|
||||||
return np.linalg.inv(camera_frame_from_calib_frame)
|
return np.linalg.inv(camera_frame_from_calib_frame)
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,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)
|
||||||
|
|
|
@ -50,12 +50,16 @@ class URLFile(object):
|
||||||
|
|
||||||
if self._debug:
|
if self._debug:
|
||||||
print("downloading", self._url)
|
print("downloading", self._url)
|
||||||
|
|
||||||
def header(x):
|
def header(x):
|
||||||
if b'MISS' in x:
|
if b'MISS' in x:
|
||||||
print(x.strip())
|
print(x.strip())
|
||||||
|
|
||||||
c.setopt(pycurl.HEADERFUNCTION, header)
|
c.setopt(pycurl.HEADERFUNCTION, header)
|
||||||
|
|
||||||
def test(debug_type, debug_msg):
|
def test(debug_type, debug_msg):
|
||||||
print(" debug(%d): %s" % (debug_type, debug_msg.strip()))
|
print(" debug(%d): %s" % (debug_type, debug_msg.strip()))
|
||||||
|
|
||||||
c.setopt(pycurl.VERBOSE, 1)
|
c.setopt(pycurl.VERBOSE, 1)
|
||||||
c.setopt(pycurl.DEBUGFUNCTION, test)
|
c.setopt(pycurl.DEBUGFUNCTION, test)
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
|
@ -68,7 +72,7 @@ class URLFile(object):
|
||||||
print("get %s %r %.f slow" % (self._url, trange, t2-t1))
|
print("get %s %r %.f slow" % (self._url, trange, t2-t1))
|
||||||
|
|
||||||
response_code = c.getinfo(pycurl.RESPONSE_CODE)
|
response_code = c.getinfo(pycurl.RESPONSE_CODE)
|
||||||
if response_code == 416: # Requested Range Not Satisfiable
|
if response_code == 416: # Requested Range Not Satisfiable
|
||||||
return ""
|
return ""
|
||||||
if response_code != 206 and response_code != 200:
|
if response_code != 206 and response_code != 200:
|
||||||
raise Exception("Error {} ({}): {}".format(response_code, self._url, repr(dats.getvalue())[:500]))
|
raise Exception("Error {} ({}): {}".format(response_code, self._url, repr(dats.getvalue())[:500]))
|
||||||
|
|
2
opendbc
2
opendbc
|
@ -1 +1 @@
|
||||||
Subproject commit 0430bfa5c2b08f9cc6ab32470fe8ac9465e7a876
|
Subproject commit b15edbc1b5a68fd725ea45ba9442a6c9be875971
|
|
@ -20,6 +20,7 @@ class Analyzer(ast.NodeVisitor):
|
||||||
for alias in node.names:
|
for alias in node.names:
|
||||||
imps.add(alias.name)
|
imps.add(alias.name)
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
|
||||||
def visit_ImportFrom(self, node):
|
def visit_ImportFrom(self, node):
|
||||||
imps.add(node.module)
|
imps.add(node.module)
|
||||||
self.generic_visit(node)
|
self.generic_visit(node)
|
||||||
|
@ -38,4 +39,3 @@ for f in sorted(pyf):
|
||||||
|
|
||||||
print("%d lines of parsed openpilot python" % tlns)
|
print("%d lines of parsed openpilot python" % tlns)
|
||||||
#print(sorted(list(imps)))
|
#print(sorted(list(imps)))
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ SafetyModel = car.CarParams.SafetyModel
|
||||||
# USB is optional
|
# USB is optional
|
||||||
try:
|
try:
|
||||||
import usb1
|
import usb1
|
||||||
from usb1 import USBErrorIO, USBErrorOverflow #pylint: disable=no-name-in-module
|
from usb1 import USBErrorIO, USBErrorOverflow # pylint: disable=no-name-in-module
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ def __parse_can_buffer(dat):
|
||||||
for j in range(0, len(dat), 0x10):
|
for j in range(0, len(dat), 0x10):
|
||||||
ddat = dat[j:j+0x10]
|
ddat = dat[j:j+0x10]
|
||||||
f1, f2 = struct.unpack("II", ddat[0:8])
|
f1, f2 = struct.unpack("II", ddat[0:8])
|
||||||
ret.append((f1 >> 21, f2>>16, ddat[8:8+(f2&0xF)], (f2>>4)&0xFF))
|
ret.append((f1 >> 21, f2 >> 16, ddat[8:8 + (f2 & 0xF)], (f2 >> 4) & 0xFF))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def can_send_many(arr):
|
def can_send_many(arr):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from PIL import ImageFont, ImageDraw, Image
|
||||||
font = ImageFont.truetype("arial", size=72)
|
font = ImageFont.truetype("arial", size=72)
|
||||||
def get_frame(idx):
|
def get_frame(idx):
|
||||||
img = np.zeros((874, 1164, 3), np.uint8)
|
img = np.zeros((874, 1164, 3), np.uint8)
|
||||||
img[100:400, 100:100+(idx%10)*100] = 255
|
img[100:400, 100:100+(idx % 10)* 100] = 255
|
||||||
|
|
||||||
# big number
|
# big number
|
||||||
im2 = Image.new("RGB", (200,200))
|
im2 = Image.new("RGB", (200,200))
|
||||||
|
@ -28,7 +28,7 @@ if __name__ == "__main__":
|
||||||
dat.valid = True
|
dat.valid = True
|
||||||
dat.frame = {
|
dat.frame = {
|
||||||
"frameId": idx,
|
"frameId": idx,
|
||||||
"image": frm[idx%len(frm)],
|
"image": frm[idx % len(frm)],
|
||||||
}
|
}
|
||||||
pm.send('frame', dat)
|
pm.send('frame', dat)
|
||||||
|
|
||||||
|
|
|
@ -128,4 +128,3 @@ def is_ecu_disconnected(fingerprint, fingerprint_list, ecu_fingerprint, car, ecu
|
||||||
|
|
||||||
def make_can_msg(addr, dat, bus):
|
def make_can_msg(addr, dat, bus):
|
||||||
return [addr, 0, dat, bus]
|
return [addr, 0, dat, bus]
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class CarController():
|
||||||
static_msgs = range(1653, 1658)
|
static_msgs = range(1653, 1658)
|
||||||
for addr in static_msgs:
|
for addr in static_msgs:
|
||||||
cnt = (frame % 10) + 1
|
cnt = (frame % 10) + 1
|
||||||
can_sends.append(make_can_msg(addr, (cnt<<4).to_bytes(1, 'little') + b'\x00\x00\x00\x00\x00\x00\x00', 1))
|
can_sends.append(make_can_msg(addr, (cnt << 4).to_bytes(1, 'little') + b'\x00\x00\x00\x00\x00\x00\x00', 1))
|
||||||
|
|
||||||
self.enabled_last = enabled
|
self.enabled_last = enabled
|
||||||
self.main_on_last = CS.out.cruiseState.available
|
self.main_on_last = CS.out.cruiseState.available
|
||||||
|
|
|
@ -6,7 +6,7 @@ def create_steer_command(packer, angle_cmd, enabled, lkas_state, angle_steers, c
|
||||||
"""Creates a CAN message for the Ford Steer Command."""
|
"""Creates a CAN message for the Ford Steer Command."""
|
||||||
|
|
||||||
#if enabled and lkas available:
|
#if enabled and lkas available:
|
||||||
if enabled and lkas_state in [2,3]: #and (frame % 500) >= 3:
|
if enabled and lkas_state in [2,3]: # and (frame % 500) >= 3:
|
||||||
action = lkas_action
|
action = lkas_action
|
||||||
else:
|
else:
|
||||||
action = 0xf
|
action = 0xf
|
||||||
|
|
|
@ -161,8 +161,7 @@ class CarController():
|
||||||
lka_active = CS.lkas_status == 1
|
lka_active = CS.lkas_status == 1
|
||||||
lka_critical = lka_active and abs(actuators.steer) > 0.9
|
lka_critical = lka_active and abs(actuators.steer) > 0.9
|
||||||
lka_icon_status = (lka_active, lka_critical)
|
lka_icon_status = (lka_active, lka_critical)
|
||||||
if frame % P.CAMERA_KEEPALIVE_STEP == 0 \
|
if frame % P.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last:
|
||||||
or lka_icon_status != self.lka_icon_status_last:
|
|
||||||
steer_alert = hud_alert == VisualAlert.steerRequired
|
steer_alert = hud_alert == VisualAlert.steerRequired
|
||||||
can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert))
|
can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert))
|
||||||
self.lka_icon_status_last = lka_icon_status
|
self.lka_icon_status_last = lka_icon_status
|
||||||
|
|
|
@ -44,9 +44,9 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
# 1 - open, 0 - closed
|
# 1 - open, 0 - closed
|
||||||
ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]['FrontLeftDoor'] == 1 or
|
ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]['FrontLeftDoor'] == 1 or
|
||||||
pt_cp.vl["BCMDoorBeltStatus"]['FrontRightDoor'] == 1 or
|
pt_cp.vl["BCMDoorBeltStatus"]['FrontRightDoor'] == 1 or
|
||||||
pt_cp.vl["BCMDoorBeltStatus"]['RearLeftDoor'] == 1 or
|
pt_cp.vl["BCMDoorBeltStatus"]['RearLeftDoor'] == 1 or
|
||||||
pt_cp.vl["BCMDoorBeltStatus"]['RearRightDoor'] == 1)
|
pt_cp.vl["BCMDoorBeltStatus"]['RearRightDoor'] == 1)
|
||||||
|
|
||||||
# 1 - latched
|
# 1 - latched
|
||||||
ret.seatbeltUnlatched = pt_cp.vl["BCMDoorBeltStatus"]['LeftSeatBelt'] == 0
|
ret.seatbeltUnlatched = pt_cp.vl["BCMDoorBeltStatus"]['LeftSeatBelt'] == 0
|
||||||
|
|
|
@ -121,4 +121,3 @@ def create_lka_icon_command(bus, active, critical, steer):
|
||||||
else:
|
else:
|
||||||
dat = b"\x00\x00\x00"
|
dat = b"\x00\x00\x00"
|
||||||
return make_can_msg(0x104c006c, dat, bus)
|
return make_can_msg(0x104c006c, dat, bus)
|
||||||
|
|
||||||
|
|
|
@ -71,15 +71,15 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.minEnableSpeed = -1. # engage speed is decided by pcm
|
ret.minEnableSpeed = -1. # engage speed is decided by pcm
|
||||||
ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG
|
ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG
|
||||||
ret.wheelbase = 2.86
|
ret.wheelbase = 2.86
|
||||||
ret.steerRatio = 14.4 #end to end is 13.46
|
ret.steerRatio = 14.4 # end to end is 13.46
|
||||||
ret.steerRatioRear = 0.
|
ret.steerRatioRear = 0.
|
||||||
ret.centerToFront = ret.wheelbase * 0.4
|
ret.centerToFront = ret.wheelbase * 0.4
|
||||||
|
|
||||||
elif candidate == CAR.BUICK_REGAL:
|
elif candidate == CAR.BUICK_REGAL:
|
||||||
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
|
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
|
||||||
ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2
|
ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2
|
||||||
ret.wheelbase = 2.83 #111.4 inches in meters
|
ret.wheelbase = 2.83 # 111.4 inches in meters
|
||||||
ret.steerRatio = 14.4 # guess for tourx
|
ret.steerRatio = 14.4 # guess for tourx
|
||||||
ret.steerRatioRear = 0.
|
ret.steerRatioRear = 0.
|
||||||
ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx
|
ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class RadarInterface(RadarInterfaceBase):
|
||||||
self.pts[targetId].yvRel = float('nan')
|
self.pts[targetId].yvRel = float('nan')
|
||||||
|
|
||||||
for oldTarget in list(self.pts.keys()):
|
for oldTarget in list(self.pts.keys()):
|
||||||
if not oldTarget in currentTargets:
|
if oldTarget not in currentTargets:
|
||||||
del self.pts[oldTarget]
|
del self.pts[oldTarget]
|
||||||
|
|
||||||
ret.points = list(self.pts.values())
|
ret.points = list(self.pts.values())
|
||||||
|
|
|
@ -20,7 +20,7 @@ def calc_cruise_offset(offset, speed):
|
||||||
|
|
||||||
|
|
||||||
def get_can_signals(CP):
|
def get_can_signals(CP):
|
||||||
# this function generates lists for signal, messages and initial values
|
# this function generates lists for signal, messages and initial values
|
||||||
signals = [
|
signals = [
|
||||||
("XMISSION_SPEED", "ENGINE_DATA", 0),
|
("XMISSION_SPEED", "ENGINE_DATA", 0),
|
||||||
("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
|
("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
|
||||||
|
@ -345,5 +345,5 @@ class CarState(CarStateBase):
|
||||||
if CP.carFingerprint in [CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]:
|
if CP.carFingerprint in [CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]:
|
||||||
checks = [(0x194, 100)]
|
checks = [(0x194, 100)]
|
||||||
|
|
||||||
bus_cam = 1 if CP.carFingerprint in HONDA_BOSCH and not CP.isPandaBlack else 2
|
bus_cam = 1 if CP.carFingerprint in HONDA_BOSCH and not CP.isPandaBlack else 2
|
||||||
return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_cam)
|
return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_cam)
|
||||||
|
|
|
@ -13,7 +13,7 @@ def process_hud_alert(enabled, fingerprint, visual_alert, left_lane,
|
||||||
|
|
||||||
# initialize to no line visible
|
# initialize to no line visible
|
||||||
sys_state = 1
|
sys_state = 1
|
||||||
if left_lane and right_lane or sys_warning: #HUD alert only display when LKAS status is active
|
if left_lane and right_lane or sys_warning: # HUD alert only display when LKAS status is active
|
||||||
if enabled or sys_warning:
|
if enabled or sys_warning:
|
||||||
sys_state = 3
|
sys_state = 3
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -113,7 +113,7 @@ class CarState(CarStateBase):
|
||||||
self.lkas11 = cp_cam.vl["LKAS11"]
|
self.lkas11 = cp_cam.vl["LKAS11"]
|
||||||
self.clu11 = cp.vl["CLU11"]
|
self.clu11 = cp.vl["CLU11"]
|
||||||
self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw']
|
self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw']
|
||||||
self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] #0 NOT ACTIVE, 1 ACTIVE
|
self.steer_state = cp.vl["MDPS12"]['CF_Mdps_ToiActive'] # 0 NOT ACTIVE, 1 ACTIVE
|
||||||
self.lead_distance = cp.vl["SCC11"]['ACC_ObjDist']
|
self.lead_distance = cp.vl["SCC11"]['ACC_ObjDist']
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -163,7 +163,7 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
("ESC_Off_Step", "TCS15", 0),
|
("ESC_Off_Step", "TCS15", 0),
|
||||||
|
|
||||||
("CF_Lvr_GearInf", "LVR11", 0), #Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev)
|
("CF_Lvr_GearInf", "LVR11", 0), # Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev)
|
||||||
|
|
||||||
("CR_Mdps_StrColTq", "MDPS12", 0),
|
("CR_Mdps_StrColTq", "MDPS12", 0),
|
||||||
("CF_Mdps_ToiActive", "MDPS12", 0),
|
("CF_Mdps_ToiActive", "MDPS12", 0),
|
||||||
|
|
|
@ -113,7 +113,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.lateralTuning.pid.kf = 0.00006
|
ret.lateralTuning.pid.kf = 0.00006
|
||||||
ret.mass = 1275. + STD_CARGO_KG
|
ret.mass = 1275. + STD_CARGO_KG
|
||||||
ret.wheelbase = 2.7
|
ret.wheelbase = 2.7
|
||||||
ret.steerRatio = 13.73 #Spec
|
ret.steerRatio = 13.73 # Spec
|
||||||
tire_stiffness_factor = 0.385
|
tire_stiffness_factor = 0.385
|
||||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||||
|
@ -121,7 +121,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.lateralTuning.pid.kf = 0.00006
|
ret.lateralTuning.pid.kf = 0.00006
|
||||||
ret.mass = 1685. + STD_CARGO_KG
|
ret.mass = 1685. + STD_CARGO_KG
|
||||||
ret.wheelbase = 2.7
|
ret.wheelbase = 2.7
|
||||||
ret.steerRatio = 13.73 #Spec
|
ret.steerRatio = 13.73 # Spec
|
||||||
tire_stiffness_factor = 0.385
|
tire_stiffness_factor = 0.385
|
||||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CarController():
|
||||||
|
|
||||||
|
|
||||||
self.apply_steer_last = apply_steer
|
self.apply_steer_last = apply_steer
|
||||||
|
|
||||||
can_sends.append(mazdacan.create_steering_control(self.packer, CS.CP.carFingerprint,
|
can_sends.append(mazdacan.create_steering_control(self.packer, CS.CP.carFingerprint,
|
||||||
frame, apply_steer, CS.cam_lkas))
|
frame, apply_steer, CS.cam_lkas))
|
||||||
return can_sends
|
return can_sends
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CarState(CarStateBase):
|
||||||
ret.leftBlinker = cp.vl["BLINK_INFO"]['LEFT_BLINK'] == 1
|
ret.leftBlinker = cp.vl["BLINK_INFO"]['LEFT_BLINK'] == 1
|
||||||
ret.rightBlinker = cp.vl["BLINK_INFO"]['RIGHT_BLINK'] == 1
|
ret.rightBlinker = cp.vl["BLINK_INFO"]['RIGHT_BLINK'] == 1
|
||||||
|
|
||||||
ret.steeringAngle = cp.vl["STEER"]['STEER_ANGLE']
|
ret.steeringAngle = cp.vl["STEER"]['STEER_ANGLE']
|
||||||
ret.steeringTorque = cp.vl["STEER_TORQUE"]['STEER_TORQUE_SENSOR']
|
ret.steeringTorque = cp.vl["STEER_TORQUE"]['STEER_TORQUE_SENSOR']
|
||||||
ret.steeringPressed = abs(ret.steeringTorque) > LKAS_LIMITS.STEER_THRESHOLD
|
ret.steeringPressed = abs(ret.steeringTorque) > LKAS_LIMITS.STEER_THRESHOLD
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class CarState(CarStateBase):
|
||||||
self.cruise_speed = ret.vEgoRaw
|
self.cruise_speed = ret.vEgoRaw
|
||||||
|
|
||||||
ret.cruiseState.available = True
|
ret.cruiseState.available = True
|
||||||
ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]['CRZ_ACTIVE'] == 1
|
ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]['CRZ_ACTIVE'] == 1
|
||||||
ret.cruiseState.speed = self.cruise_speed
|
ret.cruiseState.speed = self.cruise_speed
|
||||||
|
|
||||||
if ret.cruiseState.enabled:
|
if ret.cruiseState.enabled:
|
||||||
|
@ -182,4 +182,3 @@ class CarState(CarStateBase):
|
||||||
]
|
]
|
||||||
|
|
||||||
return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)
|
return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
tire_stiffness_factor = 0.70 # not optimized yet
|
tire_stiffness_factor = 0.70 # not optimized yet
|
||||||
|
|
||||||
if candidate in [CAR.CX5]:
|
if candidate in [CAR.CX5]:
|
||||||
ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG
|
ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG
|
||||||
ret.wheelbase = 2.7
|
ret.wheelbase = 2.7
|
||||||
ret.steerRatio = 15.5
|
ret.steerRatio = 15.5
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ def create_steering_control(packer, car_fingerprint, frame, apply_steer, lkas):
|
||||||
b2 = int(lkas["ANGLE_ENABLED"])
|
b2 = int(lkas["ANGLE_ENABLED"])
|
||||||
|
|
||||||
tmp = steering_angle + 2048
|
tmp = steering_angle + 2048
|
||||||
ahi = tmp >> 10
|
ahi = tmp >> 10
|
||||||
amd = (tmp & 0x3FF) >> 2
|
amd = (tmp & 0x3FF) >> 2
|
||||||
amd = (amd >> 4) | (( amd & 0xF) << 4)
|
amd = (amd >> 4) | (( amd & 0xF) << 4)
|
||||||
alo = (tmp & 0x3) << 2
|
alo = (tmp & 0x3) << 2
|
||||||
|
|
||||||
ctr = frame % 16
|
ctr = frame % 16
|
||||||
# bytes: [ 1 ] [ 2 ] [ 3 ] [ 4 ]
|
# bytes: [ 1 ] [ 2 ] [ 3 ] [ 4 ]
|
||||||
|
|
|
@ -3,4 +3,3 @@ from selfdrive.car.interfaces import RadarInterfaceBase
|
||||||
|
|
||||||
class RadarInterface(RadarInterfaceBase):
|
class RadarInterface(RadarInterfaceBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ class CAR:
|
||||||
|
|
||||||
class LKAS_LIMITS:
|
class LKAS_LIMITS:
|
||||||
STEER_THRESHOLD = 15
|
STEER_THRESHOLD = 15
|
||||||
DISABLE_SPEED = 45 #kph
|
DISABLE_SPEED = 45 # kph
|
||||||
ENABLE_SPEED = 52 #kph
|
ENABLE_SPEED = 52 # kph
|
||||||
|
|
||||||
class Buttons:
|
class Buttons:
|
||||||
NONE = 0
|
NONE = 0
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -42,8 +42,10 @@ class CarController():
|
||||||
self.steer_rate_limited = False
|
self.steer_rate_limited = False
|
||||||
|
|
||||||
self.fake_ecus = set()
|
self.fake_ecus = set()
|
||||||
if CP.enableCamera: self.fake_ecus.add(Ecu.fwdCamera)
|
if CP.enableCamera:
|
||||||
if CP.enableDsu: self.fake_ecus.add(Ecu.dsu)
|
self.fake_ecus.add(Ecu.fwdCamera)
|
||||||
|
if CP.enableDsu:
|
||||||
|
self.fake_ecus.add(Ecu.dsu)
|
||||||
|
|
||||||
self.packer = CANPacker(dbc_name)
|
self.packer = CANPacker(dbc_name)
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.wheelbase = 2.82448
|
ret.wheelbase = 2.82448
|
||||||
ret.steerRatio = 13.7
|
ret.steerRatio = 13.7
|
||||||
tire_stiffness_factor = 0.7933
|
tire_stiffness_factor = 0.7933
|
||||||
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG #mean between normal and hybrid
|
ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]]
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]]
|
||||||
ret.lateralTuning.pid.kf = 0.00006
|
ret.lateralTuning.pid.kf = 0.00006
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.wheelbase = 2.78
|
ret.wheelbase = 2.78
|
||||||
ret.steerRatio = 16.0
|
ret.steerRatio = 16.0
|
||||||
tire_stiffness_factor = 0.8
|
tire_stiffness_factor = 0.8
|
||||||
ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG #mean between normal and hybrid limited
|
ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning
|
||||||
ret.lateralTuning.pid.kf = 0.00012 # community tuning
|
ret.lateralTuning.pid.kf = 0.00012 # community tuning
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
stop_and_go = False
|
stop_and_go = False
|
||||||
ret.safetyParam = 73
|
ret.safetyParam = 73
|
||||||
ret.wheelbase = 2.82
|
ret.wheelbase = 2.82
|
||||||
ret.steerRatio = 14.8 #Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
|
ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download
|
||||||
tire_stiffness_factor = 0.7983
|
tire_stiffness_factor = 0.7983
|
||||||
ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17], [0.03]]
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17], [0.03]]
|
||||||
|
|
|
@ -62,7 +62,7 @@ class RadarInterface(RadarInterfaceBase):
|
||||||
if self.trigger_msg not in self.updated_messages:
|
if self.trigger_msg not in self.updated_messages:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
rr = self._update(self.updated_messages)
|
rr = self._update(self.updated_messages)
|
||||||
self.updated_messages.clear()
|
self.updated_messages.clear()
|
||||||
|
|
||||||
return rr
|
return rr
|
||||||
|
|
|
@ -803,7 +803,7 @@ FW_VERSIONS = {
|
||||||
b'\x01896630852100\x00\x00\x00\x00',
|
b'\x01896630852100\x00\x00\x00\x00',
|
||||||
b'\x01896630859000\x00\x00\x00\x00',
|
b'\x01896630859000\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.eps, 0x7a1, None): [
|
(Ecu.eps, 0x7a1, None): [
|
||||||
b'8965B45070\x00\x00\x00\x00\x00\x00',
|
b'8965B45070\x00\x00\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.esp, 0x7b0, None): [
|
(Ecu.esp, 0x7b0, None): [
|
||||||
|
@ -844,24 +844,24 @@ FW_VERSIONS = {
|
||||||
},
|
},
|
||||||
CAR.LEXUS_RX: {
|
CAR.LEXUS_RX: {
|
||||||
(Ecu.engine, 0x700, None): [
|
(Ecu.engine, 0x700, None): [
|
||||||
b'\x01896630E41200\x00\x00\x00\x00',
|
b'\x01896630E41200\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.esp, 0x7b0, None): [
|
(Ecu.esp, 0x7b0, None): [
|
||||||
b'F152648473\x00\x00\x00\x00\x00\x00',
|
b'F152648473\x00\x00\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.dsu, 0x791, None): [
|
(Ecu.dsu, 0x791, None): [
|
||||||
b'881514810500\x00\x00\x00\x00',
|
b'881514810500\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.eps, 0x7a1, None): [
|
(Ecu.eps, 0x7a1, None): [
|
||||||
b'8965B0E012\x00\x00\x00\x00\x00\x00',
|
b'8965B0E012\x00\x00\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.fwdRadar, 0x750, 0xf): [
|
(Ecu.fwdRadar, 0x750, 0xf): [
|
||||||
b'8821F4701100\x00\x00\x00\x00',
|
b'8821F4701100\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
(Ecu.fwdCamera, 0x750, 0x6d): [
|
(Ecu.fwdCamera, 0x750, 0x6d): [
|
||||||
b'8646F4802001\x00\x00\x00\x00',
|
b'8646F4802001\x00\x00\x00\x00',
|
||||||
b'8646F4802100\x00\x00\x00\x00',
|
b'8646F4802100\x00\x00\x00\x00',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
CAR.LEXUS_RXH: {
|
CAR.LEXUS_RXH: {
|
||||||
(Ecu.engine, 0x7e0, None): [
|
(Ecu.engine, 0x7e0, None): [
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CarController():
|
||||||
self.hcaEnabledFrameCount = 0
|
self.hcaEnabledFrameCount = 0
|
||||||
else:
|
else:
|
||||||
self.hcaEnabledFrameCount += 1
|
self.hcaEnabledFrameCount += 1
|
||||||
if self.hcaEnabledFrameCount >= 118 * (100 / P.HCA_STEP): # 118s
|
if self.hcaEnabledFrameCount >= 118 * (100 / P.HCA_STEP): # 118s
|
||||||
# The Kansas I-70 Crosswind Problem: if we truly do need to steer
|
# The Kansas I-70 Crosswind Problem: if we truly do need to steer
|
||||||
# in one direction for > 360 seconds, we have to disable HCA for a
|
# in one direction for > 360 seconds, we have to disable HCA for a
|
||||||
# frame while actively steering. Testing shows we can just set the
|
# frame while actively steering. Testing shows we can just set the
|
||||||
|
|
|
@ -27,4 +27,3 @@ class UIParams:
|
||||||
car_front = 2.6924 * lidar_zoom
|
car_front = 2.6924 * lidar_zoom
|
||||||
car_back = 1.8796 * lidar_zoom
|
car_back = 1.8796 * lidar_zoom
|
||||||
car_color = 110
|
car_color = 110
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ class Controls:
|
||||||
|
|
||||||
# Only allow engagement with brake pressed when stopped behind another stopped car
|
# Only allow engagement with brake pressed when stopped behind another stopped car
|
||||||
if CS.brakePressed and self.sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED \
|
if CS.brakePressed and self.sm['plan'].vTargetFuture >= STARTING_TARGET_SPEED \
|
||||||
and not self.CP.radarOffCan and CS.vEgo < 0.3:
|
and not self.CP.radarOffCan and CS.vEgo < 0.3:
|
||||||
self.events.add(EventName.noTarget)
|
self.events.add(EventName.noTarget)
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ class Controls:
|
||||||
|
|
||||||
# Send a "steering required alert" if saturation count has reached the limit
|
# Send a "steering required alert" if saturation count has reached the limit
|
||||||
if (lac_log.saturated and not CS.steeringPressed) or \
|
if (lac_log.saturated and not CS.steeringPressed) or \
|
||||||
(self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT):
|
(self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT):
|
||||||
# Check if we deviated from the path
|
# Check if we deviated from the path
|
||||||
left_deviation = actuators.steer > 0 and path_plan.dPoly[3] > 0.1
|
left_deviation = actuators.steer > 0 and path_plan.dPoly[3] > 0.1
|
||||||
right_deviation = actuators.steer < 0 and path_plan.dPoly[3] < -0.1
|
right_deviation = actuators.steer < 0 and path_plan.dPoly[3] < -0.1
|
||||||
|
|
|
@ -71,4 +71,4 @@ def main():
|
||||||
is_rhd_checked = True
|
is_rhd_checked = True
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -116,7 +116,7 @@ class LatControlINDI():
|
||||||
indi_log.delta = float(delta_u)
|
indi_log.delta = float(delta_u)
|
||||||
indi_log.output = float(self.output_steer)
|
indi_log.output = float(self.output_steer)
|
||||||
|
|
||||||
check_saturation = (CS.vEgo> 10.) and not CS.steeringRateLimited and not CS.steeringPressed
|
check_saturation = (CS.vEgo> 10.) and not CS.steeringRateLimited and not CS.steeringPressed
|
||||||
indi_log.saturated = self._check_saturation(self.output_steer, check_saturation, steers_max)
|
indi_log.saturated = self._check_saturation(self.output_steer, check_saturation, steers_max)
|
||||||
|
|
||||||
return float(self.output_steer), float(self.angle_steers_des), indi_log
|
return float(self.output_steer), float(self.angle_steers_des), indi_log
|
||||||
|
|
|
@ -79,8 +79,8 @@ class LatControlLQR():
|
||||||
i = self.i_lqr + self.ki * self.i_rate * error
|
i = self.i_lqr + self.ki * self.i_rate * error
|
||||||
control = lqr_output + i
|
control = lqr_output + i
|
||||||
|
|
||||||
if ((error >= 0 and (control <= steers_max or i < 0.0)) or \
|
if (error >= 0 and (control <= steers_max or i < 0.0)) or \
|
||||||
(error <= 0 and (control >= -steers_max or i > 0.0))):
|
(error <= 0 and (control >= -steers_max or i > 0.0)):
|
||||||
self.i_lqr = i
|
self.i_lqr = i
|
||||||
|
|
||||||
self.output_steer = lqr_output + self.i_lqr
|
self.output_steer = lqr_output + self.i_lqr
|
||||||
|
|
|
@ -194,4 +194,3 @@ class VehicleModel():
|
||||||
Yaw rate [rad/s]
|
Yaw rate [rad/s]
|
||||||
"""
|
"""
|
||||||
return self.calc_curvature(sa, u) * u
|
return self.calc_curvature(sa, u) * u
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ class TestAlerts(unittest.TestCase):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for i, txt in enumerate([alert.alert_text_1, alert.alert_text_2]):
|
for i, txt in enumerate([alert.alert_text_1, alert.alert_text_2]):
|
||||||
if i >= len(fonts[alert.alert_size]): break
|
if i >= len(fonts[alert.alert_size]):
|
||||||
|
break
|
||||||
|
|
||||||
font = fonts[alert.alert_size][i]
|
font = fonts[alert.alert_size][i]
|
||||||
w, h = draw.textsize(txt, font)
|
w, h = draw.textsize(txt, font)
|
||||||
|
|
|
@ -65,7 +65,7 @@ def run_DState_seq(driver_state_msgs, driver_car_interaction, openpilot_status,
|
||||||
for idx in range(len(driver_state_msgs)):
|
for idx in range(len(driver_state_msgs)):
|
||||||
e = Events()
|
e = Events()
|
||||||
DS.get_pose(driver_state_msgs[idx], [0,0,0], 0, openpilot_status[idx])
|
DS.get_pose(driver_state_msgs[idx], [0,0,0], 0, openpilot_status[idx])
|
||||||
# cal_rpy and car_speed don't matter here
|
# cal_rpy and car_speed don't matter here
|
||||||
|
|
||||||
# evaluate events at 10Hz for tests
|
# evaluate events at 10Hz for tests
|
||||||
DS.update(e, driver_car_interaction[idx], openpilot_status[idx], car_standstill_status[idx])
|
DS.update(e, driver_car_interaction[idx], openpilot_status[idx], car_standstill_status[idx])
|
||||||
|
|
|
@ -11,10 +11,13 @@ from common.android import ANDROID
|
||||||
if os.getenv("NOLOG") or os.getenv("NOCRASH") or not ANDROID:
|
if os.getenv("NOLOG") or os.getenv("NOCRASH") or not ANDROID:
|
||||||
def capture_exception(*args, **kwargs):
|
def capture_exception(*args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def bind_user(**kwargs):
|
def bind_user(**kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def bind_extra(**kwargs):
|
def bind_extra(**kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -38,6 +41,7 @@ else:
|
||||||
def install():
|
def install():
|
||||||
# installs a sys.excepthook
|
# installs a sys.excepthook
|
||||||
__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()
|
capture_exception()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import importlib
|
import importlib
|
||||||
from setproctitle import setproctitle #pylint: disable=no-name-in-module
|
from setproctitle import setproctitle # pylint: disable=no-name-in-module
|
||||||
|
|
||||||
import cereal.messaging as messaging
|
import cereal.messaging as messaging
|
||||||
import selfdrive.crash as crash
|
import selfdrive.crash as crash
|
||||||
|
|
|
@ -8,4 +8,3 @@ class Calibration:
|
||||||
UNCALIBRATED = 0
|
UNCALIBRATED = 0
|
||||||
CALIBRATED = 1
|
CALIBRATED = 1
|
||||||
INVALID = 2
|
INVALID = 2
|
||||||
|
|
||||||
|
|
|
@ -133,5 +133,3 @@ on of this parser
|
||||||
self.ionoAlpha = []
|
self.ionoAlpha = []
|
||||||
self.ionoBeta = []
|
self.ionoBeta = []
|
||||||
self.ionoCoeffsValid = False
|
self.ionoCoeffsValid = False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ for ublox version 8, not all functions may work.
|
||||||
|
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
import time, os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
# protocol constants
|
# protocol constants
|
||||||
PREAMBLE1 = 0xb5
|
PREAMBLE1 = 0xb5
|
||||||
|
@ -291,7 +292,7 @@ class UBloxDescriptor:
|
||||||
fields = self.fields[:]
|
fields = self.fields[:]
|
||||||
for f in fields:
|
for f in fields:
|
||||||
(fieldname, alen) = ArrayParse(f)
|
(fieldname, alen) = ArrayParse(f)
|
||||||
if not fieldname in msg._fields:
|
if fieldname not in msg._fields:
|
||||||
break
|
break
|
||||||
if alen == -1:
|
if alen == -1:
|
||||||
f1.append(msg._fields[fieldname])
|
f1.append(msg._fields[fieldname])
|
||||||
|
@ -327,7 +328,7 @@ class UBloxDescriptor:
|
||||||
ret = self.name + ': '
|
ret = self.name + ': '
|
||||||
for f in self.fields:
|
for f in self.fields:
|
||||||
(fieldname, alen) = ArrayParse(f)
|
(fieldname, alen) = ArrayParse(f)
|
||||||
if not fieldname in msg._fields:
|
if fieldname not in msg._fields:
|
||||||
continue
|
continue
|
||||||
v = msg._fields[fieldname]
|
v = msg._fields[fieldname]
|
||||||
if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
|
@ -591,7 +592,7 @@ class UBloxMessage:
|
||||||
if not self.valid():
|
if not self.valid():
|
||||||
raise UBloxError('INVALID MESSAGE')
|
raise UBloxError('INVALID MESSAGE')
|
||||||
type = self.msg_type()
|
type = self.msg_type()
|
||||||
if not type in msg_types:
|
if type not in msg_types:
|
||||||
raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf)))
|
raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf)))
|
||||||
msg_types[type].unpack(self)
|
msg_types[type].unpack(self)
|
||||||
return self._fields, self._recs
|
return self._fields, self._recs
|
||||||
|
@ -601,7 +602,7 @@ class UBloxMessage:
|
||||||
if not self.valid():
|
if not self.valid():
|
||||||
raise UBloxError('INVALID MESSAGE')
|
raise UBloxError('INVALID MESSAGE')
|
||||||
type = self.msg_type()
|
type = self.msg_type()
|
||||||
if not type in msg_types:
|
if type not in msg_types:
|
||||||
raise UBloxError('Unknown message %s' % str(type))
|
raise UBloxError('Unknown message %s' % str(type))
|
||||||
msg_types[type].pack(self)
|
msg_types[type].pack(self)
|
||||||
|
|
||||||
|
@ -610,7 +611,7 @@ class UBloxMessage:
|
||||||
if not self.valid():
|
if not self.valid():
|
||||||
raise UBloxError('INVALID MESSAGE')
|
raise UBloxError('INVALID MESSAGE')
|
||||||
type = self.msg_type()
|
type = self.msg_type()
|
||||||
if not type in msg_types:
|
if type not in msg_types:
|
||||||
raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf)))
|
raise UBloxError('Unknown message %s length=%u' % (str(type), len(self._buf)))
|
||||||
return msg_types[type].name
|
return msg_types[type].name
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ def configure_ublox(dev):
|
||||||
|
|
||||||
def int_to_bool_list(num):
|
def int_to_bool_list(num):
|
||||||
# for parsing bool bytes
|
# for parsing bool bytes
|
||||||
return [bool(num & (1<<n)) for n in range(8)]
|
return [bool(num & (1 << n)) for n in range(8)]
|
||||||
|
|
||||||
|
|
||||||
def gen_ephemeris(ephem_data):
|
def gen_ephemeris(ephem_data):
|
||||||
|
@ -134,9 +134,9 @@ def gen_solution(msg):
|
||||||
msg_data['day'],
|
msg_data['day'],
|
||||||
msg_data['hour'],
|
msg_data['hour'],
|
||||||
msg_data['min'],
|
msg_data['min'],
|
||||||
msg_data['sec'])
|
msg_data['sec']) -
|
||||||
- datetime.datetime(1970,1,1)).total_seconds())*1e+03
|
datetime.datetime(1970,1,1)).total_seconds())*1e+03 +
|
||||||
+ msg_data['nano']*1e-06)
|
msg_data['nano']*1e-06)
|
||||||
gps_fix = {'bearing': msg_data['headMot']*1e-05, # heading of motion in degrees
|
gps_fix = {'bearing': msg_data['headMot']*1e-05, # heading of motion in degrees
|
||||||
'altitude': msg_data['height']*1e-03, # altitude above ellipsoid
|
'altitude': msg_data['height']*1e-03, # altitude above ellipsoid
|
||||||
'latitude': msg_data['lat']*1e-07, # latitude in degrees
|
'latitude': msg_data['lat']*1e-07, # latitude in degrees
|
||||||
|
@ -164,8 +164,8 @@ def gen_nav_data(msg, nav_frame_buffer):
|
||||||
# parse GPS ephem
|
# parse GPS ephem
|
||||||
gnssId = msg_meta_data['gnssId']
|
gnssId = msg_meta_data['gnssId']
|
||||||
if gnssId == 0:
|
if gnssId == 0:
|
||||||
svId = msg_meta_data['svid']
|
svId = msg_meta_data['svid']
|
||||||
subframeId = GET_FIELD_U(measurements[1]['dwrd'], 3, 8)
|
subframeId = GET_FIELD_U(measurements[1]['dwrd'], 3, 8)
|
||||||
words = []
|
words = []
|
||||||
for m in measurements:
|
for m in measurements:
|
||||||
words.append(m['dwrd'])
|
words.append(m['dwrd'])
|
||||||
|
@ -244,7 +244,7 @@ def init_reader():
|
||||||
return dev
|
return dev
|
||||||
except serial.serialutil.SerialException as e:
|
except serial.serialutil.SerialException as e:
|
||||||
print(e)
|
print(e)
|
||||||
port_counter = (port_counter + 1)%len(ports)
|
port_counter = (port_counter + 1) % len(ports)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def handle_msg(dev, msg, nav_frame_buffer):
|
def handle_msg(dev, msg, nav_frame_buffer):
|
||||||
|
|
|
@ -6,4 +6,3 @@ from selfdrive.loggerd.uploader import UPLOAD_ATTR_NAME
|
||||||
for fn in sys.argv[1:]:
|
for fn in sys.argv[1:]:
|
||||||
print("unmarking %s" % fn)
|
print("unmarking %s" % fn)
|
||||||
removexattr(fn, UPLOAD_ATTR_NAME)
|
removexattr(fn, UPLOAD_ATTR_NAME)
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ class Uploader():
|
||||||
if url_resp.status_code == 412:
|
if url_resp.status_code == 412:
|
||||||
self.last_resp = url_resp
|
self.last_resp = url_resp
|
||||||
return
|
return
|
||||||
|
|
||||||
url_resp_json = json.loads(url_resp.text)
|
url_resp_json = json.loads(url_resp.text)
|
||||||
url = url_resp_json['url']
|
url = url_resp_json['url']
|
||||||
headers = url_resp_json['headers']
|
headers = url_resp_json['headers']
|
||||||
|
@ -174,9 +174,11 @@ class Uploader():
|
||||||
|
|
||||||
if fake_upload:
|
if fake_upload:
|
||||||
cloudlog.info("*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url)
|
cloudlog.info("*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url)
|
||||||
|
|
||||||
class FakeResponse():
|
class FakeResponse():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.status_code = 200
|
self.status_code = 200
|
||||||
|
|
||||||
self.last_resp = FakeResponse()
|
self.last_resp = FakeResponse()
|
||||||
else:
|
else:
|
||||||
with open(fn, "rb") as f:
|
with open(fn, "rb") as f:
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ManeuverPlot():
|
||||||
def __init__(self, title = None):
|
def __init__(self, title = None):
|
||||||
self.time_array = []
|
self.time_array = []
|
||||||
|
|
||||||
self.gas_array = []
|
self.gas_array = []
|
||||||
self.brake_array = []
|
self.brake_array = []
|
||||||
self.steer_torque_array = []
|
self.steer_torque_array = []
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ class ManeuverPlot():
|
||||||
self.fcw_array = []
|
self.fcw_array = []
|
||||||
|
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
def add_data(self, time, gas, brake, steer_torque, distance, speed,
|
def add_data(self, time, gas, brake, steer_torque, distance, speed,
|
||||||
acceleration, up_accel_cmd, ui_accel_cmd, uf_accel_cmd, d_rel, v_rel,
|
acceleration, up_accel_cmd, ui_accel_cmd, uf_accel_cmd, d_rel, v_rel,
|
||||||
v_lead, v_target_lead, pid_speed, cruise_speed, jerk_factor, a_target, fcw):
|
v_lead, v_target_lead, pid_speed, cruise_speed, jerk_factor, a_target, fcw):
|
||||||
self.time_array.append(time)
|
self.time_array.append(time)
|
||||||
self.gas_array.append(gas)
|
self.gas_array.append(gas)
|
||||||
|
@ -70,7 +70,7 @@ class ManeuverPlot():
|
||||||
if not os.path.exists(path + "/" + maneuver_name):
|
if not os.path.exists(path + "/" + maneuver_name):
|
||||||
os.makedirs(path + "/" + maneuver_name)
|
os.makedirs(path + "/" + maneuver_name)
|
||||||
plt_num = 0
|
plt_num = 0
|
||||||
|
|
||||||
# speed chart ===================
|
# speed chart ===================
|
||||||
plt_num += 1
|
plt_num += 1
|
||||||
plt.figure(plt_num)
|
plt.figure(plt_num)
|
||||||
|
@ -140,4 +140,3 @@ class ManeuverPlot():
|
||||||
pylab.savefig("/".join([path, maneuver_name, 'distance.svg']), dpi=1000)
|
pylab.savefig("/".join([path, maneuver_name, 'distance.svg']), dpi=1000)
|
||||||
|
|
||||||
plt.close("all")
|
plt.close("all")
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ CP = CarInterface.get_params(CAR.CIVIC, {0: {0x201: 6}, 1: {}, 2: {}, 3: {}})
|
||||||
def can_cksum(mm):
|
def can_cksum(mm):
|
||||||
s = 0
|
s = 0
|
||||||
for c in mm:
|
for c in mm:
|
||||||
s += (c>>4)
|
s += (c >> 4)
|
||||||
s += c & 0xF
|
s += c & 0xF
|
||||||
s = 8-s
|
s = 8-s
|
||||||
s %= 0x10
|
s %= 0x10
|
||||||
|
@ -45,7 +45,7 @@ def car_plant(pos, speed, grade, gas, brake):
|
||||||
mass = 1700
|
mass = 1700
|
||||||
aero_cd = 0.3
|
aero_cd = 0.3
|
||||||
force_peak = mass*3.
|
force_peak = mass*3.
|
||||||
force_brake_peak = -mass*10. #1g
|
force_brake_peak = -mass*10. # 1g
|
||||||
power_peak = 100000 # 100kW
|
power_peak = 100000 # 100kW
|
||||||
speed_base = power_peak/force_peak
|
speed_base = power_peak/force_peak
|
||||||
rolling_res = 0.01
|
rolling_res = 0.01
|
||||||
|
@ -277,13 +277,13 @@ class Plant():
|
||||||
vls = vls_tuple(
|
vls = vls_tuple(
|
||||||
self.speed_sensor(speed),
|
self.speed_sensor(speed),
|
||||||
self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed),
|
self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed), self.speed_sensor(speed),
|
||||||
self.angle_steer, self.angle_steer_rate, 0, 0,#Steer torque sensor
|
self.angle_steer, self.angle_steer_rate, 0, 0, # Steer torque sensor
|
||||||
0, 0, # Blinkers
|
0, 0, # Blinkers
|
||||||
self.gear_choice,
|
self.gear_choice,
|
||||||
speed != 0,
|
speed != 0,
|
||||||
self.brake_error, self.brake_error,
|
self.brake_error, self.brake_error,
|
||||||
not self.seatbelt, self.seatbelt, # Seatbelt
|
not self.seatbelt, self.seatbelt, # Seatbelt
|
||||||
self.brake_pressed, 0., #Brake pressed, Brake switch
|
self.brake_pressed, 0., # Brake pressed, Brake switch
|
||||||
cruise_buttons,
|
cruise_buttons,
|
||||||
self.esp_disabled,
|
self.esp_disabled,
|
||||||
0, # HUD lead
|
0, # HUD lead
|
||||||
|
@ -339,9 +339,9 @@ class Plant():
|
||||||
# TODO: use the DBC
|
# TODO: use the DBC
|
||||||
if self.frame % 5 == 0:
|
if self.frame % 5 == 0:
|
||||||
radar_state_msg = b'\x79\x00\x00\x00\x00\x00\x00\x00'
|
radar_state_msg = b'\x79\x00\x00\x00\x00\x00\x00\x00'
|
||||||
radar_msg = to_3_byte(d_rel*16.0) + \
|
radar_msg = to_3_byte(d_rel * 16.0) + \
|
||||||
to_3_byte(int(lateral_pos_rel*16.0)&0x3ff) + \
|
to_3_byte(int(lateral_pos_rel * 16.0) & 0x3ff) + \
|
||||||
to_3s_byte(int(v_rel*32.0)) + \
|
to_3s_byte(int(v_rel * 32.0)) + \
|
||||||
b"0f00000"
|
b"0f00000"
|
||||||
|
|
||||||
radar_msg = binascii.unhexlify(radar_msg)
|
radar_msg = binascii.unhexlify(radar_msg)
|
||||||
|
|
|
@ -6,7 +6,8 @@ import numbers
|
||||||
|
|
||||||
import dictdiffer
|
import dictdiffer
|
||||||
if "CI" in os.environ:
|
if "CI" in os.environ:
|
||||||
tqdm = lambda x: x
|
def tqdm(x):
|
||||||
|
return x
|
||||||
else:
|
else:
|
||||||
from tqdm import tqdm # type: ignore
|
from tqdm import tqdm # type: ignore
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ def remove_ignored_fields(msg, ignore):
|
||||||
for k in keys[:-1]:
|
for k in keys[:-1]:
|
||||||
try:
|
try:
|
||||||
attr = getattr(msg, k)
|
attr = getattr(msg, k)
|
||||||
except:
|
except AttributeError:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
v = getattr(attr, keys[-1])
|
v = getattr(attr, keys[-1])
|
||||||
|
@ -46,8 +47,7 @@ def remove_ignored_fields(msg, ignore):
|
||||||
return msg.as_reader()
|
return msg.as_reader()
|
||||||
|
|
||||||
def compare_logs(log1, log2, ignore_fields=[], ignore_msgs=[]):
|
def compare_logs(log1, log2, ignore_fields=[], ignore_msgs=[]):
|
||||||
filter_msgs = lambda m: m.which() not in ignore_msgs
|
log1, log2 = [list(filter(lambda m: m.which() not in ignore_msgs, log)) for log in (log1, log2)]
|
||||||
log1, log2 = [list(filter(filter_msgs, log)) for log in (log1, log2)]
|
|
||||||
assert len(log1) == len(log2), "logs are not same length: " + str(len(log1)) + " VS " + str(len(log2))
|
assert len(log1) == len(log2), "logs are not same length: " + str(len(log1)) + " VS " + str(len(log2))
|
||||||
|
|
||||||
diff = []
|
diff = []
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import capnp
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
if "CI" in os.environ:
|
if "CI" in os.environ:
|
||||||
tqdm = lambda x: x
|
def tqdm(x):
|
||||||
|
return x
|
||||||
else:
|
else:
|
||||||
from tqdm import tqdm # type: ignore
|
from tqdm import tqdm # type: ignore
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ class FakePubMaster(messaging.PubMaster):
|
||||||
for s in services:
|
for s in services:
|
||||||
try:
|
try:
|
||||||
data = messaging.new_message(s)
|
data = messaging.new_message(s)
|
||||||
except:
|
except capnp.lib.capnp.KjException:
|
||||||
data = messaging.new_message(s, 0)
|
data = messaging.new_message(s, 0)
|
||||||
self.data[s] = data.as_reader()
|
self.data[s] = data.as_reader()
|
||||||
self.sock[s] = DumbSocket()
|
self.sock[s] = DumbSocket()
|
||||||
|
|
|
@ -124,7 +124,7 @@ if __name__ == "__main__":
|
||||||
process_replay_dir = os.path.dirname(os.path.abspath(__file__))
|
process_replay_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
try:
|
try:
|
||||||
ref_commit = open(os.path.join(process_replay_dir, "ref_commit")).read().strip()
|
ref_commit = open(os.path.join(process_replay_dir, "ref_commit")).read().strip()
|
||||||
except:
|
except FileNotFoundError:
|
||||||
print("couldn't find reference commit")
|
print("couldn't find reference commit")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ if __name__ == "__main__":
|
||||||
results: Any = {}
|
results: Any = {}
|
||||||
for car_brand, segment in segments:
|
for car_brand, segment in segments:
|
||||||
if (cars_whitelisted and car_brand.upper() not in args.whitelist_cars) or \
|
if (cars_whitelisted and car_brand.upper() not in args.whitelist_cars) or \
|
||||||
(not cars_whitelisted and car_brand.upper() in args.blacklist_cars):
|
(not cars_whitelisted and car_brand.upper() in args.blacklist_cars):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print("***** testing route segment %s *****\n" % segment)
|
print("***** testing route segment %s *****\n" % segment)
|
||||||
|
@ -151,7 +151,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
for cfg in CONFIGS:
|
for cfg in CONFIGS:
|
||||||
if (procs_whitelisted and cfg.proc_name not in args.whitelist_procs) or \
|
if (procs_whitelisted and cfg.proc_name not in args.whitelist_procs) or \
|
||||||
(not procs_whitelisted and cfg.proc_name in args.blacklist_procs):
|
(not procs_whitelisted and cfg.proc_name in args.blacklist_procs):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cmp_log_fn = os.path.join(process_replay_dir, "%s_%s_%s.bz2" % (segment, cfg.proc_name, ref_commit))
|
cmp_log_fn = os.path.join(process_replay_dir, "%s_%s_%s.bz2" % (segment, cfg.proc_name, ref_commit))
|
||||||
|
|
|
@ -261,7 +261,7 @@ routes = {
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'enableDsu': False,
|
'enableDsu': False,
|
||||||
},
|
},
|
||||||
"7e34a988419b5307|2019-12-18--19-13-30": {
|
"7e34a988419b5307|2019-12-18--19-13-30": {
|
||||||
'carFingerprint': TOYOTA.RAV4H_TSS2,
|
'carFingerprint': TOYOTA.RAV4H_TSS2,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'fingerprintSource': 'fixed'
|
'fingerprintSource': 'fixed'
|
||||||
|
@ -286,12 +286,12 @@ routes = {
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'enableDsu': False,
|
'enableDsu': False,
|
||||||
},
|
},
|
||||||
"886fcd8408d570e9|2020-01-29--05-11-22": {
|
"886fcd8408d570e9|2020-01-29--05-11-22": {
|
||||||
'carFingerprint': TOYOTA.LEXUS_RX,
|
'carFingerprint': TOYOTA.LEXUS_RX,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'enableDsu': True,
|
'enableDsu': True,
|
||||||
},
|
},
|
||||||
"886fcd8408d570e9|2020-01-29--02-18-55": {
|
"886fcd8408d570e9|2020-01-29--02-18-55": {
|
||||||
'carFingerprint': TOYOTA.LEXUS_RX,
|
'carFingerprint': TOYOTA.LEXUS_RX,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'enableDsu': False,
|
'enableDsu': False,
|
||||||
|
@ -301,12 +301,12 @@ routes = {
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'enableDsu': True,
|
'enableDsu': True,
|
||||||
},
|
},
|
||||||
"01b22eb2ed121565|2020-02-02--11-25-51": {
|
"01b22eb2ed121565|2020-02-02--11-25-51": {
|
||||||
'carFingerprint': TOYOTA.LEXUS_RX_TSS2,
|
'carFingerprint': TOYOTA.LEXUS_RX_TSS2,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'fingerprintSource': 'fixed',
|
'fingerprintSource': 'fixed',
|
||||||
},
|
},
|
||||||
"b74758c690a49668|2020-05-20--15-58-57": {
|
"b74758c690a49668|2020-05-20--15-58-57": {
|
||||||
'carFingerprint': TOYOTA.LEXUS_RXH_TSS2,
|
'carFingerprint': TOYOTA.LEXUS_RXH_TSS2,
|
||||||
'enableCamera': True,
|
'enableCamera': True,
|
||||||
'fingerprintSource': 'fixed',
|
'fingerprintSource': 'fixed',
|
||||||
|
|
|
@ -14,7 +14,7 @@ def setup_leon_fan():
|
||||||
bus.write_i2c_block_data(0x67, 0xa, [0])
|
bus.write_i2c_block_data(0x67, 0xa, [0])
|
||||||
else:
|
else:
|
||||||
bus.write_i2c_block_data(0x67, 0xa, [0x20])
|
bus.write_i2c_block_data(0x67, 0xa, [0x20])
|
||||||
bus.write_i2c_block_data(0x67, 0x8, [(i-1)<<6])
|
bus.write_i2c_block_data(0x67, 0x8, [(i - 1) << 6])
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
bus.close()
|
bus.close()
|
||||||
|
|
|
@ -100,7 +100,7 @@ def set_eon_fan(val):
|
||||||
else:
|
else:
|
||||||
#bus.write_i2c_block_data(0x67, 0x45, [0])
|
#bus.write_i2c_block_data(0x67, 0x45, [0])
|
||||||
bus.write_i2c_block_data(0x67, 0xa, [0x20])
|
bus.write_i2c_block_data(0x67, 0xa, [0x20])
|
||||||
bus.write_i2c_block_data(0x67, 0x8, [(val-1)<<6])
|
bus.write_i2c_block_data(0x67, 0x8, [(val - 1) << 6])
|
||||||
else:
|
else:
|
||||||
bus.write_byte_data(0x21, 0x04, 0x2)
|
bus.write_byte_data(0x21, 0x04, 0x2)
|
||||||
bus.write_byte_data(0x21, 0x03, (val*2)+1)
|
bus.write_byte_data(0x21, 0x03, (val*2)+1)
|
||||||
|
|
|
@ -51,7 +51,7 @@ pygame.joystick.init()
|
||||||
textPrint = TextPrint()
|
textPrint = TextPrint()
|
||||||
|
|
||||||
# -------- Main Program Loop -----------
|
# -------- Main Program Loop -----------
|
||||||
while done==False:
|
while not done:
|
||||||
# EVENT PROCESSING STEP
|
# EVENT PROCESSING STEP
|
||||||
for event in pygame.event.get(): # User did something
|
for event in pygame.event.get(): # User did something
|
||||||
if event.type == pygame.QUIT: # If user clicked close
|
if event.type == pygame.QUIT: # If user clicked close
|
||||||
|
@ -122,4 +122,4 @@ while done==False:
|
||||||
# Close the window and quit.
|
# Close the window and quit.
|
||||||
# If you forget this line, the program will 'hang'
|
# If you forget this line, the program will 'hang'
|
||||||
# on exit if running from IDLE.
|
# on exit if running from IDLE.
|
||||||
pygame.quit ()
|
pygame.quit()
|
||||||
|
|
|
@ -111,10 +111,12 @@ class RouteSegment(object):
|
||||||
self.camera_path = camera_path
|
self.camera_path = camera_path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self): return str(self._name)
|
def name(self):
|
||||||
|
return str(self._name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def canonical_name(self): return self._name
|
def canonical_name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
class RouteSegmentName(object):
|
class RouteSegmentName(object):
|
||||||
def __init__(self, name_str):
|
def __init__(self, name_str):
|
||||||
|
@ -123,6 +125,8 @@ class RouteSegmentName(object):
|
||||||
self._num = int(num_str)
|
self._num = int(num_str)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def segment_num(self): return self._num
|
def segment_num(self):
|
||||||
|
return self._num
|
||||||
|
|
||||||
def __str__(self): return self._segment_name_str
|
def __str__(self):
|
||||||
|
return self._segment_name_str
|
||||||
|
|
|
@ -82,5 +82,8 @@ class RouteFrameReader(object):
|
||||||
for fr in frs:
|
for fr in frs:
|
||||||
fr.close()
|
fr.close()
|
||||||
|
|
||||||
def __enter__(self): return self
|
def __enter__(self):
|
||||||
def __exit__(self, type, value, traceback): self.close()
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
self.close()
|
||||||
|
|
|
@ -73,7 +73,7 @@ def draw_path(y, x, color, img, calibration, top_down, lid_color=None):
|
||||||
uv_model > 0, axis=1), uv_model[:, 0] < img.shape[1] - 1, uv_model[:, 1] <
|
uv_model > 0, axis=1), uv_model[:, 0] < img.shape[1] - 1, uv_model[:, 1] <
|
||||||
img.shape[0] - 1))]
|
img.shape[0] - 1))]
|
||||||
|
|
||||||
for i, j in ((-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)):
|
for i, j in ((-1, 0), (0, -1), (0, 0), (0, 1), (1, 0)):
|
||||||
img[uv_model_dots[:, 1] + i, uv_model_dots[:, 0] + j] = color
|
img[uv_model_dots[:, 1] + i, uv_model_dots[:, 0] + j] = color
|
||||||
|
|
||||||
# draw lidar path point on lidar
|
# draw lidar path point on lidar
|
||||||
|
@ -88,12 +88,12 @@ def draw_path(y, x, color, img, calibration, top_down, lid_color=None):
|
||||||
def draw_steer_path(speed_ms, curvature, color, img,
|
def draw_steer_path(speed_ms, curvature, color, img,
|
||||||
calibration, top_down, VM, lid_color=None):
|
calibration, top_down, VM, lid_color=None):
|
||||||
path_x = np.arange(101.)
|
path_x = np.arange(101.)
|
||||||
path_y = np.multiply(path_x, np.tan(np.arcsin(np.clip(path_x * curvature, -0.999, 0.999)) / 2.))
|
path_y = np.multiply(path_x, np.tan(np.arcsin(np.clip(path_x * curvature, -0.999, 0.999)) / 2.))
|
||||||
|
|
||||||
draw_path(path_y, path_x, color, img, calibration, top_down, lid_color)
|
draw_path(path_y, path_x, color, img, calibration, top_down, lid_color)
|
||||||
|
|
||||||
def draw_lead_car(closest, top_down):
|
def draw_lead_car(closest, top_down):
|
||||||
if closest != None:
|
if closest is not None:
|
||||||
closest_y = int(round(UP.lidar_car_y - closest * UP.lidar_zoom))
|
closest_y = int(round(UP.lidar_car_y - closest * UP.lidar_zoom))
|
||||||
if closest_y > 0:
|
if closest_y > 0:
|
||||||
top_down[1][int(round(UP.lidar_car_x - METER_WIDTH * 2)):int(
|
top_down[1][int(round(UP.lidar_car_x - METER_WIDTH * 2)):int(
|
||||||
|
@ -118,12 +118,10 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
|
||||||
"p": (0,1,1),
|
"p": (0,1,1),
|
||||||
"m": (1,0,1) }
|
"m": (1,0,1) }
|
||||||
|
|
||||||
if bigplots == True:
|
if bigplots:
|
||||||
fig = plt.figure(figsize=(6.4, 7.0))
|
fig = plt.figure(figsize=(6.4, 7.0))
|
||||||
elif bigplots == False:
|
|
||||||
fig = plt.figure()
|
|
||||||
else:
|
else:
|
||||||
fig = plt.figure(figsize=bigplots)
|
fig = plt.figure()
|
||||||
|
|
||||||
fig.set_facecolor((0.2,0.2,0.2))
|
fig.set_facecolor((0.2,0.2,0.2))
|
||||||
|
|
||||||
|
@ -135,7 +133,7 @@ def init_plots(arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_co
|
||||||
ax.patch.set_facecolor((0.4, 0.4, 0.4))
|
ax.patch.set_facecolor((0.4, 0.4, 0.4))
|
||||||
axs.append(ax)
|
axs.append(ax)
|
||||||
|
|
||||||
plots = [] ;idxs = [] ;plot_select = []
|
plots, idxs, plot_select = [], [], []
|
||||||
for i, pl_list in enumerate(plot_names):
|
for i, pl_list in enumerate(plot_names):
|
||||||
for j, item in enumerate(pl_list):
|
for j, item in enumerate(pl_list):
|
||||||
plot, = axs[i].plot(arr[:, name_to_arr_idx[item]],
|
plot, = axs[i].plot(arr[:, name_to_arr_idx[item]],
|
||||||
|
|
|
@ -341,15 +341,19 @@ def get_arg_parser():
|
||||||
parser.add_argument("route_name", type=(lambda x: x.replace("#", "|")), nargs="?",
|
parser.add_argument("route_name", type=(lambda x: x.replace("#", "|")), nargs="?",
|
||||||
help="The route whose messages will be published.")
|
help="The route whose messages will be published.")
|
||||||
parser.add_argument("data_dir", nargs='?', default=os.getenv('UNLOGGER_DATA_DIR'),
|
parser.add_argument("data_dir", nargs='?', default=os.getenv('UNLOGGER_DATA_DIR'),
|
||||||
help="Path to directory in which log and camera files are located.")
|
help="Path to directory in which log and camera files are located.")
|
||||||
|
|
||||||
parser.add_argument("--no-loop", action="store_true", help="Stop at the end of the replay.")
|
parser.add_argument("--no-loop", action="store_true", help="Stop at the end of the replay.")
|
||||||
|
|
||||||
key_value_pair = lambda x: x.split("=")
|
def key_value_pair(x):
|
||||||
|
return x.split("=")
|
||||||
|
|
||||||
parser.add_argument("address_mapping", nargs="*", type=key_value_pair,
|
parser.add_argument("address_mapping", nargs="*", type=key_value_pair,
|
||||||
help="Pairs <service>=<zmq_addr> to publish <service> on <zmq_addr>.")
|
help="Pairs <service>=<zmq_addr> to publish <service> on <zmq_addr>.")
|
||||||
|
|
||||||
comma_list = lambda x: x.split(",")
|
def comma_list(x):
|
||||||
|
return x.split(",")
|
||||||
|
|
||||||
to_mock_group = parser.add_mutually_exclusive_group()
|
to_mock_group = parser.add_mutually_exclusive_group()
|
||||||
to_mock_group.add_argument("--min", action="store_true", default=os.getenv("MIN"))
|
to_mock_group.add_argument("--min", action="store_true", default=os.getenv("MIN"))
|
||||||
to_mock_group.add_argument("--enabled", default=os.getenv("ENABLED"), type=comma_list)
|
to_mock_group.add_argument("--enabled", default=os.getenv("ENABLED"), type=comma_list)
|
||||||
|
|
|
@ -200,7 +200,7 @@ def go(q):
|
||||||
speed = math.sqrt(vel.x**2 + vel.y**2 + vel.z**2) * 3.6
|
speed = math.sqrt(vel.x**2 + vel.y**2 + vel.z**2) * 3.6
|
||||||
can_function(pm, speed, fake_wheel.angle, rk.frame, cruise_button=cruise_button, is_engaged=is_openpilot_engaged)
|
can_function(pm, speed, fake_wheel.angle, rk.frame, cruise_button=cruise_button, is_engaged=is_openpilot_engaged)
|
||||||
|
|
||||||
if rk.frame%1 == 0: # 20Hz?
|
if rk.frame % 1 == 0: # 20Hz?
|
||||||
throttle_op, brake_op, steer_torque_op = sendcan_function(sendcan)
|
throttle_op, brake_op, steer_torque_op = sendcan_function(sendcan)
|
||||||
# print(" === torq, ",steer_torque_op, " ===")
|
# print(" === torq, ",steer_torque_op, " ===")
|
||||||
if is_openpilot_engaged:
|
if is_openpilot_engaged:
|
||||||
|
|
|
@ -28,8 +28,8 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
|
||||||
|
|
||||||
msg.append(packer.make_can_msg("SCM_BUTTONS", 0, {"CRUISE_BUTTONS": cruise_button}, idx))
|
msg.append(packer.make_can_msg("SCM_BUTTONS", 0, {"CRUISE_BUTTONS": cruise_button}, idx))
|
||||||
|
|
||||||
values = {"COUNTER_PEDAL": idx&0xF}
|
values = {"COUNTER_PEDAL": idx & 0xF}
|
||||||
checksum = crc8_pedal(packer.make_can_msg("GAS_SENSOR", 0, {"COUNTER_PEDAL": idx&0xF}, -1)[2][:-1])
|
checksum = crc8_pedal(packer.make_can_msg("GAS_SENSOR", 0, {"COUNTER_PEDAL": idx & 0xF}, -1)[2][:-1])
|
||||||
values["CHECKSUM_PEDAL"] = checksum
|
values["CHECKSUM_PEDAL"] = checksum
|
||||||
msg.append(packer.make_can_msg("GAS_SENSOR", 0, values, -1))
|
msg.append(packer.make_can_msg("GAS_SENSOR", 0, values, -1))
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ def can_function(pm, speed, angle, idx, cruise_button=0, is_engaged=False):
|
||||||
msg.append(packer.make_can_msg("BRAKE_COMMAND", 2, {}, idx))
|
msg.append(packer.make_can_msg("BRAKE_COMMAND", 2, {}, idx))
|
||||||
|
|
||||||
# radar
|
# radar
|
||||||
if idx%5 == 0:
|
if idx % 5 == 0:
|
||||||
msg.append(rpacker.make_can_msg("RADAR_DIAGNOSTIC", 1, {"RADAR_STATE": 0x79}, -1))
|
msg.append(rpacker.make_can_msg("RADAR_DIAGNOSTIC", 1, {"RADAR_STATE": 0x79}, -1))
|
||||||
for i in range(16):
|
for i in range(16):
|
||||||
msg.append(rpacker.make_can_msg("TRACK_%d" % i, 1, {"LONG_DIST": 255.5}, -1))
|
msg.append(rpacker.make_can_msg("TRACK_%d" % i, 1, {"LONG_DIST": 255.5}, -1))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# set up wheel
|
# set up wheel
|
||||||
import os, struct, array
|
import array
|
||||||
|
import os
|
||||||
|
import struct
|
||||||
from fcntl import ioctl
|
from fcntl import ioctl
|
||||||
|
|
||||||
# Iterate over the joystick devices.
|
# Iterate over the joystick devices.
|
||||||
|
|
|
@ -6,4 +6,4 @@ if __name__ == '__main__':
|
||||||
params = Params()
|
params = Params()
|
||||||
params.put("HasAcceptedTerms", str(terms_version, 'utf-8'))
|
params.put("HasAcceptedTerms", str(terms_version, 'utf-8'))
|
||||||
params.put("CompletedTrainingVersion", str(training_version, 'utf-8'))
|
params.put("CompletedTrainingVersion", str(training_version, 'utf-8'))
|
||||||
print("Terms Accepted!")
|
print("Terms Accepted!")
|
||||||
|
|
Loading…
Reference in New Issue