From 72b5c6f61abe1d83540bbd1d0d4e5709500eb200 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 15 Aug 2024 22:23:37 -0700 Subject: [PATCH 1/7] jenkins: remove unused pcStage --- Jenkinsfile | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2dffeecc7..799b4fbbeb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -95,42 +95,6 @@ def deviceStage(String stageName, String deviceType, List extra_env, def steps) } } -def pcStage(String stageName, Closure body) { - node { - stage(stageName) { - if (currentBuild.result != null) { - return - } - - checkout scm - - def dockerArgs = "--user=batman -v /tmp/comma_download_cache:/tmp/comma_download_cache -v /tmp/scons_cache:/tmp/scons_cache -e PYTHONPATH=${env.WORKSPACE} --cpus=8 --memory 16g -e PYTEST_ADDOPTS='-n8'"; - - def openpilot_base = retryWithDelay (3, 15) { - return docker.build("openpilot-base:build-${env.GIT_COMMIT}", "-f Dockerfile.openpilot_base .") - } - - lock(resource: "", label: 'pc', inversePrecedence: true, quantity: 1) { - openpilot_base.inside(dockerArgs) { - timeout(time: 20, unit: 'MINUTES') { - try { - retryWithDelay (3, 15) { - sh "git config --global --add safe.directory '*'" - sh "git submodule update --init --recursive" - sh "git lfs pull" - } - body() - } finally { - sh "rm -rf ${env.WORKSPACE}/* || true" - sh "rm -rf .* || true" - } - } - } - } - } - } -} - def setupCredentials() { withCredentials([ string(credentialsId: 'azure_token', variable: 'AZURE_TOKEN'), From b41f9f2dfe89cdb94b60dfa8c619829725dc8226 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:08:17 -0700 Subject: [PATCH 2/7] run_process_on_route.py: use zstd --- selfdrive/debug/run_process_on_route.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/debug/run_process_on_route.py b/selfdrive/debug/run_process_on_route.py index c98763f3c9..45665e8a48 100755 --- a/selfdrive/debug/run_process_on_route.py +++ b/selfdrive/debug/run_process_on_route.py @@ -25,6 +25,6 @@ if __name__ == "__main__": inputs = [i for i in inputs if i.which() not in produces] outputs = sorted(inputs + outputs, key=lambda x: x.logMonoTime) - fn = f"{args.route.replace('/', '_')}_{args.process}.bz2" - print(f"Saved log to {fn}") + fn = f"{args.route.replace('/', '_')}_{args.process}.zst" + print(f"Saving log to {fn}") save_log(fn, outputs) From f6780fca2fdd4998ed45a6295d64399e9fd23d41 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:18:37 -0700 Subject: [PATCH 3/7] toyota: pycapnp enum which should be called --- selfdrive/car/toyota/values.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index ca422c73ef..345fe3c1f5 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -32,7 +32,7 @@ class CarControllerParams: ANGLE_RATE_LIMIT_DOWN = AngleRateLimit(speed_bp=[5, 25], angle_v=[0.36, 0.26]) def __init__(self, CP): - if CP.lateralTuning.which == 'torque': + if CP.lateralTuning.which() == 'torque': self.STEER_DELTA_UP = 15 # 1.0s time to peak torque self.STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50) else: From bce11e393fe0298e6b759781b6d4182c70966261 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:26:40 -0700 Subject: [PATCH 4/7] hyundai: declare type override of cruise_buttons --- selfdrive/car/hyundai/carstate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index a2940a3b91..2173565d06 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -27,8 +27,8 @@ class CarState(CarStateBase): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) - self.cruise_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES) - self.main_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES) + self.cruise_buttons: deque = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES) + self.main_buttons: deque = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES) self.gear_msg_canfd = "GEAR_ALT" if CP.flags & HyundaiFlags.CANFD_ALT_GEARS else \ "GEAR_ALT_2" if CP.flags & HyundaiFlags.CANFD_ALT_GEARS_2 else \ From 207c77ea93d53b3b5c916f7232503d01492c70c1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:30:11 -0700 Subject: [PATCH 5/7] hyundai: test some feature detection (#33315) test some feature detection --- selfdrive/car/hyundai/tests/test_hyundai.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 4d31d7d15e..66b65ea95b 100644 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -3,11 +3,14 @@ from hypothesis import settings, given, strategies as st import pytest from cereal import car +from openpilot.selfdrive.car import gen_empty_fingerprint from openpilot.selfdrive.car.fw_versions import build_fw_dict +from openpilot.selfdrive.car.hyundai.interface import CarInterface +from openpilot.selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR from openpilot.selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ HYBRID_CAR, EV_CAR, FW_QUERY_CONFIG, LEGACY_SAFETY_MODE_CAR, CANFD_FUZZY_WHITELIST, \ UNSUPPORTED_LONGITUDINAL_CAR, PLATFORM_CODE_ECUS, HYUNDAI_VERSION_REQUEST_LONG, \ - get_platform_codes + HyundaiFlags, get_platform_codes from openpilot.selfdrive.car.hyundai.fingerprints import FW_VERSIONS Ecu = car.CarParams.Ecu @@ -40,6 +43,21 @@ CANFD_EXPECTED_ECUS = {Ecu.fwdCamera, Ecu.fwdRadar} class TestHyundaiFingerprint: + def test_feature_detection(self): + # HDA2 + for has_adas in (True, False): + car_fw = [car.CarParams.CarFw(ecu=Ecu.adas if has_adas else Ecu.fwdCamera)] + CP = CarInterface.get_params(CAR.KIA_EV6, gen_empty_fingerprint(), car_fw, False, False) + assert bool(CP.flags & HyundaiFlags.CANFD_HDA2) == has_adas + + # radar available + for radar in (True, False): + fingerprint = gen_empty_fingerprint() + if radar: + fingerprint[1][RADAR_START_ADDR] = 8 + CP = CarInterface.get_params(CAR.HYUNDAI_SONATA, fingerprint, car_fw, False, False) + assert CP.radarUnavailable != radar + def test_can_features(self): # Test no EV/HEV in any gear lists (should all use ELECT_GEAR) assert set.union(*CAN_GEARS.values()) & (HYBRID_CAR | EV_CAR) == set() From c2ab62c2b2e43f0930564bb27c76554fa8b9810c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:37:31 -0700 Subject: [PATCH 6/7] radard: remove redundant NoneType check --- selfdrive/controls/radard.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index a7e3c0211d..bf19801a87 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -208,23 +208,17 @@ class RadarD: self.ready = False - def update(self, sm: messaging.SubMaster, rr): + def update(self, sm: messaging.SubMaster, rr: car.RadarData): self.ready = sm.seen['modelV2'] self.current_time = 1e-9*max(sm.logMonoTime.values()) - radar_points = [] - radar_errors = [] - if rr is not None: - radar_points = rr.points - radar_errors = rr.errors - if sm.recv_frame['carState'] != self.last_v_ego_frame: self.v_ego = sm['carState'].vEgo self.v_ego_hist.append(self.v_ego) self.last_v_ego_frame = sm.recv_frame['carState'] ar_pts = {} - for pt in radar_points: + for pt in rr.points: ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured] # *** remove missing points from meta data *** @@ -245,10 +239,10 @@ class RadarD: self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) # *** publish radarState *** - self.radar_state_valid = sm.all_checks() and len(radar_errors) == 0 + self.radar_state_valid = sm.all_checks() and len(rr.errors) == 0 self.radar_state = log.RadarState.new_message() self.radar_state.mdMonoTime = sm.logMonoTime['modelV2'] - self.radar_state.radarErrors = list(radar_errors) + self.radar_state.radarErrors = list(rr.errors) self.radar_state.carStateMonoTime = sm.logMonoTime['carState'] if len(sm['modelV2'].temporalPose.trans): @@ -283,7 +277,7 @@ class RadarD: # fuses camera and radar data for best lead detection -def main(): +def main() -> None: config_realtime_process(5, Priority.CTRL_LOW) # wait for stats about the car to come in from controls @@ -307,7 +301,7 @@ def main(): while 1: can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) - rr = RI.update(can_capnp_to_list(can_strings)) + rr: car.RadarData | None = RI.update(can_capnp_to_list(can_strings)) sm.update(0) if rr is None: continue From 6a5bbb261eb8ea8154220e18f47f3e78a65bd664 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 16 Aug 2024 00:38:28 -0700 Subject: [PATCH 7/7] fw_versions.py: mark raw in f-string --- selfdrive/debug/car/fw_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/debug/car/fw_versions.py b/selfdrive/debug/car/fw_versions.py index 5c0426f28b..e52c8bf915 100755 --- a/selfdrive/debug/car/fw_versions.py +++ b/selfdrive/debug/car/fw_versions.py @@ -62,7 +62,7 @@ if __name__ == "__main__": for version in fw_vers: subaddr = None if version.subAddress == 0 else hex(version.subAddress) print(f" Brand: {version.brand:{padding}}, bus: {version.bus}, OBD: {version.obdMultiplexing} - " + - f"(Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") + f"(Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion!r}]") print("}") print()