From 84d2fa68f70a7e1e056348b6d00576d2f34bacf1 Mon Sep 17 00:00:00 2001 From: YassineYousfi Date: Wed, 8 Nov 2023 10:06:30 -0800 Subject: [PATCH 01/24] modeld: handle division by zero (#30411) * modeld: avoid division by zero * undefined at 0 --- selfdrive/modeld/fill_model_msg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/modeld/fill_model_msg.py b/selfdrive/modeld/fill_model_msg.py index 2b8a72b9be..7434e94287 100644 --- a/selfdrive/modeld/fill_model_msg.py +++ b/selfdrive/modeld/fill_model_msg.py @@ -92,7 +92,7 @@ def fill_model_msg(msg: capnp._DynamicStructBuilder, net_output_data: Dict[str, # interpolate to find `t` for the current xidx current_x_val = plan_x[tidx] next_x_val = plan_x[tidx+1] - p = (ModelConstants.X_IDXS[xidx] - current_x_val) / (next_x_val - current_x_val) + p = (ModelConstants.X_IDXS[xidx] - current_x_val) / (next_x_val - current_x_val) if abs(next_x_val - current_x_val) > 1e-9 else float('nan') PLAN_T_IDXS[xidx] = p * ModelConstants.T_IDXS[tidx+1] + (1 - p) * ModelConstants.T_IDXS[tidx] # lane lines From 4967377b3fcfddc1099cd82cd8192893271ad1f1 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 8 Nov 2023 11:05:23 -0800 Subject: [PATCH 02/24] Update RELEASES.md --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 0efa3d3918..1d88480278 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,4 @@ -Version 0.9.5 (2023-XX-XX) +Version 0.9.5 (2023-11-16) ======================== * New driving model * Improved navigate on openpilot performance using navigation instructions as an additional model input From d02dd50749c8dabc1cd3385bdf2cf3fb7cb7ac63 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 8 Nov 2023 16:43:32 -0500 Subject: [PATCH 03/24] Pytest: consistent codecov (#30408) * seed only * random seed * ignore version.py * increase max examples * increase default max examples --- .github/workflows/selfdrive_tests.yaml | 2 +- codecov.yml | 3 ++- conftest.py | 3 +++ selfdrive/car/tests/test_car_interfaces.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index bd6885cf5b..a83b495f11 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -27,7 +27,7 @@ env: RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c UNIT_TEST: coverage run --append -m unittest discover - PYTEST: pytest --continue-on-collection-errors --cov --cov-report=xml --cov-append --durations=0 --durations-min=5 + PYTEST: pytest --continue-on-collection-errors --cov --cov-report=xml --cov-append --durations=0 --durations-min=5 --hypothesis-seed 0 jobs: build_release: diff --git a/codecov.yml b/codecov.yml index 686d9b03f7..40d03dcd7a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -8,4 +8,5 @@ coverage: ignore: - "**/test_*.py" - - "selfdrive/test/**" \ No newline at end of file + - "selfdrive/test/**" + - "system/version.py" # codecov changes depending on if we are in a branch or not \ No newline at end of file diff --git a/conftest.py b/conftest.py index 085ad5b28a..08ddb0d1ea 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,6 @@ import os import pytest +import random from openpilot.common.prefix import OpenpilotPrefix from openpilot.system.hardware import TICI @@ -9,6 +10,8 @@ from openpilot.system.hardware import TICI def openpilot_function_fixture(): starting_env = dict(os.environ) + random.seed(0) + # setup a clean environment for each test with OpenpilotPrefix(): prefix = os.environ["OPENPILOT_PREFIX"] diff --git a/selfdrive/car/tests/test_car_interfaces.py b/selfdrive/car/tests/test_car_interfaces.py index 5fa1a02897..a920bd45da 100755 --- a/selfdrive/car/tests/test_car_interfaces.py +++ b/selfdrive/car/tests/test_car_interfaces.py @@ -18,7 +18,7 @@ from openpilot.selfdrive.test.fuzzy_generation import DrawType, FuzzyGenerator ALL_ECUS = list({ecu for ecus in FW_VERSIONS.values() for ecu in ecus.keys()}) -MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '5')) +MAX_EXAMPLES = int(os.environ.get('MAX_EXAMPLES', '20')) def get_fuzzy_car_interface_args(draw: DrawType) -> dict: From fa9d3ec1f5c3ca0b32d61a1fdd410cd7bb59c932 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 8 Nov 2023 17:15:15 -0500 Subject: [PATCH 04/24] build_release: increase timeout (#30416) inc timeout --- .github/workflows/selfdrive_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index a83b495f11..3efdb8a98b 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -54,7 +54,7 @@ jobs: cd $STRIPPED_DIR ${{ env.RUN }} "CI=1 python selfdrive/manager/build.py" - name: Run tests - timeout-minutes: 2 + timeout-minutes: 2.5 run: | cd $STRIPPED_DIR ${{ env.RUN }} "release/check-dirty.sh && \ From 844cbd95e73b9ea5cc9571534644342458c36d14 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 8 Nov 2023 17:32:16 -0500 Subject: [PATCH 05/24] build_release: increase timeout again (#30417) * inc timeout * 3 minute timeout --- .github/workflows/selfdrive_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 3efdb8a98b..63d9a7d47d 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -54,7 +54,7 @@ jobs: cd $STRIPPED_DIR ${{ env.RUN }} "CI=1 python selfdrive/manager/build.py" - name: Run tests - timeout-minutes: 2.5 + timeout-minutes: 3 run: | cd $STRIPPED_DIR ${{ env.RUN }} "release/check-dirty.sh && \ From 2eb487c9a5a905b502433db2e7c5e52a52224f39 Mon Sep 17 00:00:00 2001 From: Vivek Aithal Date: Wed, 8 Nov 2023 15:25:41 -0800 Subject: [PATCH 06/24] params: Remove separate CarParams from each daemon (#30405) * remove separate previous route carparams from each daemon and add centrally to controlsd * extract out sigint handler * make process replay work for torqued * don't write param if None --- common/params.cc | 2 +- selfdrive/controls/controlsd.py | 5 ++++ selfdrive/locationd/helpers.py | 27 +++++++++++++++++++ selfdrive/locationd/torqued.py | 22 ++++----------- .../test/process_replay/process_replay.py | 8 +++--- 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/common/params.cc b/common/params.cc index 3f6cb7044c..9b40773475 100644 --- a/common/params.cc +++ b/common/params.cc @@ -99,6 +99,7 @@ std::unordered_map keys = { {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"CarParamsCache", CLEAR_ON_MANAGER_START}, {"CarParamsPersistent", PERSISTENT}, + {"CarParamsPrevRoute", PERSISTENT}, {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"CompletedTrainingVersion", PERSISTENT}, {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, @@ -154,7 +155,6 @@ std::unordered_map keys = { {"LastUpdateException", CLEAR_ON_MANAGER_START}, {"LastUpdateTime", PERSISTENT}, {"LiveParameters", PERSISTENT}, - {"LiveTorqueCarParams", PERSISTENT}, {"LiveTorqueParameters", PERSISTENT | DONT_LOG}, {"LongitudinalPersonality", PERSISTENT}, {"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 437cf2d7ce..19ce407932 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -121,6 +121,11 @@ class Controls: safety_config.safetyModel = car.CarParams.SafetyModel.noOutput self.CP.safetyConfigs = [safety_config] + # Write previous route's CarParams + prev_cp = self.params.get("CarParamsPersistent") + if prev_cp is not None: + self.params.put("CarParamsPrevRoute", prev_cp) + # Write CarParams for radard cp_bytes = self.CP.to_bytes() self.params.put("CarParams", cp_bytes) diff --git a/selfdrive/locationd/helpers.py b/selfdrive/locationd/helpers.py index f41b72c703..bde21f7879 100644 --- a/selfdrive/locationd/helpers.py +++ b/selfdrive/locationd/helpers.py @@ -1,6 +1,12 @@ import numpy as np +import signal +import sys from typing import List, Optional, Tuple, Any +from cereal import log +from openpilot.common.params import Params +from openpilot.system.swaglog import cloudlog + class NPQueue: def __init__(self, maxlen: int, rowsize: int) -> None: @@ -48,3 +54,24 @@ class PointBuckets: def load_points(self, points: List[List[float]]) -> None: for point in points: self.add_point(*point) + + +class ParameterEstimator: + """ Base class for parameter estimators """ + def reset(self) -> None: + raise NotImplementedError + + def handle_log(self, t: int, which: str, msg: log.Event) -> None: + raise NotImplementedError + + def get_msg(self, valid: bool, with_points: bool) -> log.Event: + raise NotImplementedError + + +def cache_points_onexit(param_name, estimator, sig, frame): + signal.signal(sig, signal.SIG_DFL) + cloudlog.warning(f"Caching {param_name} param") + params = Params() + msg = estimator.get_msg(valid=True, with_points=True) + params.put(param_name, msg.to_bytes()) + sys.exit(0) diff --git a/selfdrive/locationd/torqued.py b/selfdrive/locationd/torqued.py index 829f8db417..ff1fac2c22 100755 --- a/selfdrive/locationd/torqued.py +++ b/selfdrive/locationd/torqued.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 import os -import sys import signal import numpy as np from collections import deque, defaultdict +from functools import partial import cereal.messaging as messaging from cereal import car, log @@ -12,7 +12,7 @@ from openpilot.common.realtime import config_realtime_process, DT_MDL from openpilot.common.filter_simple import FirstOrderFilter from openpilot.system.swaglog import cloudlog from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY -from openpilot.selfdrive.locationd.helpers import PointBuckets +from openpilot.selfdrive.locationd.helpers import PointBuckets, ParameterEstimator, cache_points_onexit HISTORY = 5 # secs POINTS_PER_BUCKET = 1500 @@ -52,7 +52,7 @@ class TorqueBuckets(PointBuckets): break -class TorqueEstimator: +class TorqueEstimator(ParameterEstimator): def __init__(self, CP, decimated=False): self.hist_len = int(HISTORY / DT_MDL) self.lag = CP.steerActuatorDelay + .2 # from controlsd @@ -95,7 +95,7 @@ class TorqueEstimator: # try to restore cached params params = Params() - params_cache = params.get("LiveTorqueCarParams") + params_cache = params.get("CarParamsPrevRoute") torque_cache = params.get("LiveTorqueParameters") if params_cache is not None and torque_cache is not None: try: @@ -116,7 +116,6 @@ class TorqueEstimator: cloudlog.info("restored torque params from cache") except Exception: cloudlog.exception("failed to restore cached torque params") - params.remove("LiveTorqueCarParams") params.remove("LiveTorqueParameters") self.filtered_params = {} @@ -228,19 +227,8 @@ def main(): with car.CarParams.from_bytes(params.get("CarParams", block=True)) as CP: estimator = TorqueEstimator(CP) - def cache_params(sig, frame): - signal.signal(sig, signal.SIG_DFL) - cloudlog.warning("caching torque params") - - params = Params() - params.put("LiveTorqueCarParams", CP.as_builder().to_bytes()) - - msg = estimator.get_msg(with_points=True) - params.put("LiveTorqueParameters", msg.to_bytes()) - - sys.exit(0) if "REPLAY" not in os.environ: - signal.signal(signal.SIGINT, cache_params) + signal.signal(signal.SIGINT, partial(cache_points_onexit, "LiveTorqueParameters", estimator)) while True: sm.update() diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index a520b3d740..a26e964550 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -594,10 +594,13 @@ def get_custom_params_from_lr(lr: LogIterable, initial_state: str = "first") -> assert initial_state in ["first", "last"] msg_index = 0 if initial_state == "first" else -1 - assert len(car_params) > 0, "carParams required for initial state of liveParameters and liveTorqueCarParams" + assert len(car_params) > 0, "carParams required for initial state of liveParameters and CarParamsPrevRoute" CP = car_params[msg_index].carParams - custom_params = {} + custom_params = { + "CarParamsPrevRoute": CP.as_builder().to_bytes() + } + if len(live_calibration) > 0: custom_params["CalibrationParams"] = live_calibration[msg_index].as_builder().to_bytes() if len(live_parameters) > 0: @@ -605,7 +608,6 @@ def get_custom_params_from_lr(lr: LogIterable, initial_state: str = "first") -> lp_dict["carFingerprint"] = CP.carFingerprint custom_params["LiveParameters"] = json.dumps(lp_dict) if len(live_torque_parameters) > 0: - custom_params["LiveTorqueCarParams"] = CP.as_builder().to_bytes() custom_params["LiveTorqueParameters"] = live_torque_parameters[msg_index].as_builder().to_bytes() return custom_params From 53b6ab9e180381134c3809239768477bcc6cbd25 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 8 Nov 2023 19:04:02 -0500 Subject: [PATCH 07/24] CI: pytest for the rest for GHA (#30418) * pytest car * all pytest * need more time * keep release test short * keep it short --- .github/workflows/selfdrive_tests.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 63d9a7d47d..0bdba64662 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -26,8 +26,8 @@ env: RUN_CL: docker run --shm-size 1G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e PYTHONWARNINGS=error -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $CL_BASE_IMAGE /bin/sh -c - UNIT_TEST: coverage run --append -m unittest discover PYTEST: pytest --continue-on-collection-errors --cov --cov-report=xml --cov-append --durations=0 --durations-min=5 --hypothesis-seed 0 + XDIST: -n auto --dist=loadscope jobs: build_release: @@ -58,7 +58,7 @@ jobs: run: | cd $STRIPPED_DIR ${{ env.RUN }} "release/check-dirty.sh && \ - python -m unittest discover selfdrive/car" + MAX_EXAMPLES=5 $PYTEST $XDIST selfdrive/car" - name: pre-commit timeout-minutes: 3 run: | @@ -176,7 +176,7 @@ jobs: - name: Run unit tests timeout-minutes: 15 run: | - ${{ env.RUN }} "$PYTEST -n auto --dist=loadscope --timeout 30 -o cpp_files=test_* -m 'not slow' && \ + ${{ env.RUN }} "$PYTEST $XDIST --timeout 30 -o cpp_files=test_* -m 'not slow' && \ ./selfdrive/ui/tests/create_test_translations.sh && \ QT_QPA_PLATFORM=offscreen ./selfdrive/ui/tests/test_translations && \ ./selfdrive/ui/tests/test_translations.py && \ @@ -253,7 +253,7 @@ jobs: - name: Run regen timeout-minutes: 30 run: | - ${{ env.RUN_CL }} "ONNXCPU=1 $PYTEST -n auto --dist=loadscope selfdrive/test/process_replay/test_regen.py && \ + ${{ env.RUN_CL }} "ONNXCPU=1 $PYTEST $XDIST selfdrive/test/process_replay/test_regen.py && \ chmod -R 777 /tmp/comma_download_cache" test_modeld: @@ -283,8 +283,7 @@ jobs: timeout-minutes: 4 run: | ${{ env.RUN_CL }} "unset PYTHONWARNINGS && \ - $UNIT_TEST selfdrive/modeld && \ - coverage xml" + $PYTEST selfdrive/modeld" - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 @@ -311,7 +310,7 @@ jobs: - name: Test car models timeout-minutes: 25 run: | - ${{ env.RUN }} "$PYTEST -n auto --dist=loadscope selfdrive/car/tests/test_models.py && \ + ${{ env.RUN }} "$PYTEST $XDIST selfdrive/car/tests/test_models.py && \ chmod -R 777 /tmp/comma_download_cache" env: NUM_JOBS: 5 From eed0ddc3b83dd88f0a927f3d5ad04d2260800948 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Wed, 8 Nov 2023 19:30:22 -0500 Subject: [PATCH 08/24] bump panda (#30419) --- panda | 2 +- selfdrive/car/subaru/interface.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda b/panda index fa04f47600..3f25ccabd6 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit fa04f476000e8cfff72780212b115b5ab059b079 +Subproject commit 3f25ccabd6c46ba06bf32fb15b221c2fcdfc5191 diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index 10ed728812..79576f6433 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -97,7 +97,7 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.1 elif candidate in (CAR.FORESTER_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018): - ret.safetyConfigs[0].safetyParam = 1 # Outback 2018-2019 and Forester have reversed driver torque signal + ret.safetyConfigs[0].safetyParam = Panda.FLAG_SUBARU_PREGLOBAL_REVERSED_DRIVER_TORQUE # Outback 2018-2019 and Forester have reversed driver torque signal ret.mass = 1568 ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 From f9a5f64498bf4bcb8b5f69629de34266aa6de341 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 9 Nov 2023 10:54:24 -0800 Subject: [PATCH 09/24] bump panda --- panda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda b/panda index 3f25ccabd6..d2ea9ad293 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 3f25ccabd6c46ba06bf32fb15b221c2fcdfc5191 +Subproject commit d2ea9ad293df232bcd7dc808bb6e577e3d8b483d From 5c2796a104fd2bfb4ef7a541108bd4faee587ba5 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 9 Nov 2023 14:12:19 -0500 Subject: [PATCH 10/24] CI: label codecov uploads (#30426) * label * matrix --- .github/workflows/selfdrive_tests.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 0bdba64662..bb5b0a137a 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -184,6 +184,8 @@ jobs: ./selfdrive/test/process_replay/test_fuzzy.py" - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 + with: + name: ${{ github.job }} process_replay: name: process replay @@ -228,6 +230,8 @@ jobs: ${{ env.RUN }} "unset PYTHONWARNINGS && CI=1 AZURE_TOKEN='$AZURE_TOKEN' python selfdrive/test/process_replay/test_processes.py -j$(nproc) --upload-only" - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 + with: + name: ${{ github.job }} regen: name: regen @@ -286,6 +290,8 @@ jobs: $PYTEST selfdrive/modeld" - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 + with: + name: ${{ github.job }} test_cars: name: cars @@ -317,6 +323,8 @@ jobs: JOB_ID: ${{ matrix.job }} - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v3 + with: + name: ${{ github.job }}-${{ matrix.job }} car_docs_diff: name: PR comments From 1e91cf92a180f7093279d19e4a8694c353910d15 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 9 Nov 2023 18:19:10 -0500 Subject: [PATCH 11/24] CI: codecov for multiprocessing (#30428) * concurrencty codecov * its a list * retrigger ci * increase delay --- .github/workflows/selfdrive_tests.yaml | 2 ++ pyproject.toml | 3 +++ selfdrive/athena/tests/test_athenad.py | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index bb5b0a137a..aba630f67c 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -213,6 +213,7 @@ jobs: run: | ${{ env.RUN }} "CI=1 coverage run selfdrive/test/process_replay/test_processes.py -j$(nproc) && \ chmod -R 777 /tmp/comma_download_cache && \ + coverage combine && \ coverage xml" - name: Print diff id: print-diff @@ -282,6 +283,7 @@ jobs: run: | ${{ env.RUN_CL }} "unset PYTHONWARNINGS && \ ONNXCPU=1 CI=1 NO_NAV=1 coverage run selfdrive/test/process_replay/model_replay.py && \ + coverage combine && \ coverage xml" - name: Run unit tests timeout-minutes: 4 diff --git a/pyproject.toml b/pyproject.toml index 71b677fbb7..16dad2c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -199,3 +199,6 @@ flake8-implicit-str-concat.allow-multiline=false "system".msg = "Use openpilot.system" "third_party".msg = "Use openpilot.third_party" "tools".msg = "Use openpilot.tools" + +[tool.coverage.run] +concurrency = ["multiprocessing", "thread"] \ No newline at end of file diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py index e81753a6a0..6d3c5fdb33 100755 --- a/selfdrive/athena/tests/test_athenad.py +++ b/selfdrive/athena/tests/test_athenad.py @@ -87,7 +87,7 @@ class TestAthenadMethods(unittest.TestCase): p = Process(target=send_deviceState) p.start() - time.sleep(0.1) + time.sleep(0.2) try: deviceState = dispatcher["getMessage"]("deviceState") assert deviceState['deviceState'] From 863fdec50e6e222b4b50157c7fe2e254de3435bd Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 9 Nov 2023 18:52:28 -0500 Subject: [PATCH 12/24] Revert "CI: codecov for multiprocessing" (#30431) Revert "CI: codecov for multiprocessing (#30428)" This reverts commit 1e91cf92a180f7093279d19e4a8694c353910d15. --- .github/workflows/selfdrive_tests.yaml | 2 -- pyproject.toml | 3 --- selfdrive/athena/tests/test_athenad.py | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index aba630f67c..bb5b0a137a 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -213,7 +213,6 @@ jobs: run: | ${{ env.RUN }} "CI=1 coverage run selfdrive/test/process_replay/test_processes.py -j$(nproc) && \ chmod -R 777 /tmp/comma_download_cache && \ - coverage combine && \ coverage xml" - name: Print diff id: print-diff @@ -283,7 +282,6 @@ jobs: run: | ${{ env.RUN_CL }} "unset PYTHONWARNINGS && \ ONNXCPU=1 CI=1 NO_NAV=1 coverage run selfdrive/test/process_replay/model_replay.py && \ - coverage combine && \ coverage xml" - name: Run unit tests timeout-minutes: 4 diff --git a/pyproject.toml b/pyproject.toml index 16dad2c643..71b677fbb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -199,6 +199,3 @@ flake8-implicit-str-concat.allow-multiline=false "system".msg = "Use openpilot.system" "third_party".msg = "Use openpilot.third_party" "tools".msg = "Use openpilot.tools" - -[tool.coverage.run] -concurrency = ["multiprocessing", "thread"] \ No newline at end of file diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py index 6d3c5fdb33..e81753a6a0 100755 --- a/selfdrive/athena/tests/test_athenad.py +++ b/selfdrive/athena/tests/test_athenad.py @@ -87,7 +87,7 @@ class TestAthenadMethods(unittest.TestCase): p = Process(target=send_deviceState) p.start() - time.sleep(0.2) + time.sleep(0.1) try: deviceState = dispatcher["getMessage"]("deviceState") assert deviceState['deviceState'] From bd00fba980f60b8434e428d1ffa5a948cbe83629 Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Thu, 9 Nov 2023 18:11:44 -0700 Subject: [PATCH 13/24] Fix typo in CARS.md (#30433) --- docs/CARS.md | 2 +- selfdrive/car/CARS_template.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/CARS.md b/docs/CARS.md index eb7f88d731..3e7d8bbeb8 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -318,7 +318,7 @@ If your car has the following packages or features, then it's a good candidate f ### FlexRay -All the cars that openpilot supports use a [CAN bus](https://en.wikipedia.org/wiki/CAN_bus) for communication between all the car's computers, however a CAN bus isn't the only way that the cars in your computer can communicate. Most, if not all, vehicles from the following manufacturers use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) instead of a CAN bus: **BMW, Mercedes, Audi, Land Rover, and some Volvo**. These cars may one day be supported, but we have no immediate plans to support FlexRay. +All the cars that openpilot supports use a [CAN bus](https://en.wikipedia.org/wiki/CAN_bus) for communication between all the car's computers, however a CAN bus isn't the only way that the computers in your car can communicate. Most, if not all, vehicles from the following manufacturers use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) instead of a CAN bus: **BMW, Mercedes, Audi, Land Rover, and some Volvo**. These cars may one day be supported, but we have no immediate plans to support FlexRay. ### Toyota Security diff --git a/selfdrive/car/CARS_template.md b/selfdrive/car/CARS_template.md index 9d045e7627..ab4d231fa7 100644 --- a/selfdrive/car/CARS_template.md +++ b/selfdrive/car/CARS_template.md @@ -53,7 +53,7 @@ If your car has the following packages or features, then it's a good candidate f ### FlexRay -All the cars that openpilot supports use a [CAN bus](https://en.wikipedia.org/wiki/CAN_bus) for communication between all the car's computers, however a CAN bus isn't the only way that the cars in your computer can communicate. Most, if not all, vehicles from the following manufacturers use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) instead of a CAN bus: **BMW, Mercedes, Audi, Land Rover, and some Volvo**. These cars may one day be supported, but we have no immediate plans to support FlexRay. +All the cars that openpilot supports use a [CAN bus](https://en.wikipedia.org/wiki/CAN_bus) for communication between all the car's computers, however a CAN bus isn't the only way that the computers in your car can communicate. Most, if not all, vehicles from the following manufacturers use [FlexRay](https://en.wikipedia.org/wiki/FlexRay) instead of a CAN bus: **BMW, Mercedes, Audi, Land Rover, and some Volvo**. These cars may one day be supported, but we have no immediate plans to support FlexRay. ### Toyota Security From cf2d4fd7ea85034983bb7ce0d3f56e3d79a8949a Mon Sep 17 00:00:00 2001 From: Nickolas Komarnitsky Date: Thu, 9 Nov 2023 18:42:36 -0700 Subject: [PATCH 14/24] Subaru: Add FW for 2022 Legacy (#30434) Update values.py --- selfdrive/car/subaru/values.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index c9dc6ba5db..882d46b7c3 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -207,6 +207,7 @@ FW_VERSIONS = { b'\xa1\\ x04\x01', b'\xa1 \x03\x03', b'\xa1 \x02\x01', + b'\xa1 \x02\x02', ], (Ecu.eps, 0x746, None): [ b'\x9b\xc0\x11\x00', @@ -220,11 +221,13 @@ FW_VERSIONS = { b'\xde\"a0\x07', b'\xe2"aq\x07', b'\xde,\xa0@\x07', + b'\xe2,\xa0@\x07', ], (Ecu.transmission, 0x7e1, None): [ b'\xa5\xf6\x05@\x00', b'\xa7\xf6\x04@\x00', b'\xa5\xfe\xc7@\x00', + b'\xa7\xfe\xc4@\x00', ], }, CAR.IMPREZA: { From 26a82e70d547a479c768d1971dca151f34aadcb6 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 10 Nov 2023 10:02:48 +0800 Subject: [PATCH 15/24] replay: make `speed_` atomic (#30429) make speed_ atomic --- tools/replay/replay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/replay/replay.h b/tools/replay/replay.h index 01969b0a9f..e26ef883b6 100644 --- a/tools/replay/replay.h +++ b/tools/replay/replay.h @@ -144,7 +144,7 @@ protected: std::vector> timeline; std::set allow_list; std::string car_fingerprint_; - float speed_ = 1.0; + std::atomic speed_ = 1.0; replayEventFilter event_filter = nullptr; void *filter_opaque = nullptr; int segment_cache_limit = MIN_SEGMENTS_CACHE; From 515e57402a4ea1c6637b2a377af0dd86214a9373 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 9 Nov 2023 18:09:18 -0800 Subject: [PATCH 16/24] SOM boot recovery (#30427) * SOM boot recovery * bump * master --- common/params.cc | 1 + panda | 2 +- selfdrive/boardd/pandad.py | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/params.cc b/common/params.cc index 9b40773475..54168165a1 100644 --- a/common/params.cc +++ b/common/params.cc @@ -180,6 +180,7 @@ std::unordered_map keys = { {"Offroad_UpdateFailed", CLEAR_ON_MANAGER_START}, {"OpenpilotEnabledToggle", PERSISTENT}, {"PandaHeartbeatLost", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, + {"PandaSomResetTriggered", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION}, {"PandaSignatures", CLEAR_ON_MANAGER_START}, {"Passive", PERSISTENT}, {"PrimeType", PERSISTENT}, diff --git a/panda b/panda index d2ea9ad293..a1d699b87d 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit d2ea9ad293df232bcd7dc808bb6e577e3d8b483d +Subproject commit a1d699b87d05d4ae9d93adc422026864aaedcbdc diff --git a/selfdrive/boardd/pandad.py b/selfdrive/boardd/pandad.py index 433de70d43..14d272965d 100755 --- a/selfdrive/boardd/pandad.py +++ b/selfdrive/boardd/pandad.py @@ -144,6 +144,9 @@ def main() -> NoReturn: if health["heartbeat_lost"]: params.put_bool("PandaHeartbeatLost", True) cloudlog.event("heartbeat lost", deviceState=health, serial=panda.get_usb_serial()) + if health["som_reset_triggered"]: + params.put_bool("PandaSomResetTriggered", True) + cloudlog.event("panda.som_reset_triggered", health=health, serial=panda.get_usb_serial()) if first_run: if panda.is_internal(): From db3f56a6f6f3160aa1ff94cf2434f791957049b1 Mon Sep 17 00:00:00 2001 From: Jason Young <46612682+jyoung8607@users.noreply.github.com> Date: Thu, 9 Nov 2023 23:18:35 -0500 Subject: [PATCH 17/24] VW MQB: Add FW for 2020 Volkswagen Atlas (#30430) * VW MQB: Add FW for 2020 Volkswagen Atlas * oops --- docs/CARS.md | 2 +- selfdrive/car/volkswagen/values.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/CARS.md b/docs/CARS.md index 3e7d8bbeb8..b7f083b8e8 100644 --- a/docs/CARS.md +++ b/docs/CARS.md @@ -244,7 +244,7 @@ A supported vehicle is one that just works when you install a comma device. All |Volkswagen|Arteon eHybrid 2020-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Volkswagen|Arteon R 2020-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Volkswagen|Atlas 2018-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| -|Volkswagen|Atlas Cross Sport 2021-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| +|Volkswagen|Atlas Cross Sport 2020-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Volkswagen|California 2021-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|31 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 angled mount (8 degrees)
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Volkswagen|Caravelle 2020|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|31 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 angled mount (8 degrees)
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| |Volkswagen|CC 2018-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[1,12](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|
Parts- 1 J533 connector
- 1 USB-C coupler
- 1 comma 3X
- 1 harness box
- 1 long OBD-C cable
- 1 mount
- 1 right angle OBD-C cable (1.5 ft)
Buy Here
|| diff --git a/selfdrive/car/volkswagen/values.py b/selfdrive/car/volkswagen/values.py index 6439fb0b6b..3c9aeb55d7 100644 --- a/selfdrive/car/volkswagen/values.py +++ b/selfdrive/car/volkswagen/values.py @@ -196,7 +196,7 @@ CAR_INFO: Dict[str, Union[VWCarInfo, List[VWCarInfo]]] = { ], CAR.ATLAS_MK1: [ VWCarInfo("Volkswagen Atlas 2018-23"), - VWCarInfo("Volkswagen Atlas Cross Sport 2021-22"), + VWCarInfo("Volkswagen Atlas Cross Sport 2020-22"), VWCarInfo("Volkswagen Teramont 2018-22"), VWCarInfo("Volkswagen Teramont Cross Sport 2021-22"), VWCarInfo("Volkswagen Teramont X 2021-22"), @@ -350,6 +350,7 @@ FW_VERSIONS = { CAR.ATLAS_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8703H906026AA\xf1\x899970', + b'\xf1\x8703H906026AG\xf1\x899973', b'\xf1\x8703H906026AJ\xf1\x890638', b'\xf1\x8703H906026AJ\xf1\x891017', b'\xf1\x8703H906026AT\xf1\x891922', @@ -375,6 +376,7 @@ FW_VERSIONS = { (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655BC\xf1\x890503\xf1\x82\0161914151912001103111122031200', b'\xf1\x873Q0959655BN\xf1\x890713\xf1\x82\0162214152212001105141122052900', + b'\xf1\x873Q0959655DB\xf1\x890720\xf1\x82\x0e1114151112001105111122052900', b'\xf1\x873Q0959655DB\xf1\x890720\xf1\x82\0162214152212001105141122052900', b'\xf1\x873Q0959655DM\xf1\x890732\xf1\x82\x0e1114151112001105161122052J00', b'\xf1\x873Q0959655DM\xf1\x890732\xf1\x82\x0e1115151112001105171122052J00', @@ -382,6 +384,7 @@ FW_VERSIONS = { (Ecu.eps, 0x712, None): [ b'\xf1\x873QF909144B \xf1\x891582\xf1\x82\00571B60924A1', b'\xf1\x873QF909144B \xf1\x891582\xf1\x82\x0571B6G920A1', + b'\xf1\x873QF909144B \xf1\x891582\xf1\x82\x0571B6M921A1', b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820528B6080105', b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820528B6090105', ], From 86efd70fa9e1ec2d125cc713e58c76740bc6eee5 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 10 Nov 2023 12:20:48 +0800 Subject: [PATCH 18/24] cabana: allocate qt objects on the heap instead of stack (#30374) allocate qobject in heap --- tools/cabana/chart/chart.cc | 13 +++++++------ tools/cabana/chart/chart.h | 2 +- tools/cabana/chart/chartswidget.cc | 16 +++++++++------- tools/cabana/chart/chartswidget.h | 4 ++-- tools/cabana/videowidget.cc | 9 +++++---- tools/cabana/videowidget.h | 2 +- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/tools/cabana/chart/chart.cc b/tools/cabana/chart/chart.cc index 28d122576c..4cd8eaf8b4 100644 --- a/tools/cabana/chart/chart.cc +++ b/tools/cabana/chart/chart.cc @@ -25,7 +25,7 @@ const int AXIS_X_TOP_MARGIN = 4; static inline bool xLessThan(const QPointF &p, float x) { return p.x() < x; } ChartView::ChartView(const std::pair &x_range, ChartsWidget *parent) - : charts_widget(parent), tip_label(this), QChartView(parent) { + : charts_widget(parent), QChartView(parent) { series_type = (SeriesType)settings.chart_series_type; chart()->setBackgroundVisible(false); axis_x = new QValueAxis(this); @@ -38,6 +38,7 @@ ChartView::ChartView(const std::pair &x_range, ChartsWidget *par axis_x->setRange(x_range.first, x_range.second); + tip_label = new TipLabel(this); createToolButtons(); setRubberBand(QChartView::HorizontalRubberBand); setMouseTracking(true); @@ -416,7 +417,7 @@ qreal ChartView::niceNumber(qreal x, bool ceiling) { } void ChartView::leaveEvent(QEvent *event) { - if (tip_label.isVisible()) { + if (tip_label->isVisible()) { charts_widget->showValueTip(-1); } QChartView::leaveEvent(event); @@ -543,7 +544,7 @@ void ChartView::mouseMoveEvent(QMouseEvent *ev) { if (!is_zooming && plot_area.contains(ev->pos())) { const double sec = chart()->mapToValue(ev->pos()).x(); charts_widget->showValueTip(sec); - } else if (tip_label.isVisible()) { + } else if (tip_label->isVisible()) { charts_widget->showValueTip(-1); } @@ -563,7 +564,7 @@ void ChartView::showTip(double sec) { QRect tip_area(0, chart()->plotArea().top(), rect().width(), chart()->plotArea().height()); QRect visible_rect = charts_widget->chartVisibleRect(this).intersected(tip_area); if (visible_rect.isEmpty()) { - tip_label.hide(); + tip_label->hide(); return; } @@ -593,14 +594,14 @@ void ChartView::showTip(double sec) { QPoint pt(x, chart()->plotArea().top()); text_list.push_front(QString::number(chart()->mapToValue({x, 0}).x(), 'f', 3)); QString text = "

" % text_list.join("
") % "

"; - tip_label.showText(pt, text, this, visible_rect); + tip_label->showText(pt, text, this, visible_rect); viewport()->update(); } void ChartView::hideTip() { clearTrackPoints(); tooltip_x = -1; - tip_label.hide(); + tip_label->hide(); viewport()->update(); } diff --git a/tools/cabana/chart/chart.h b/tools/cabana/chart/chart.h index 896eaaf2a3..d690a14d1c 100644 --- a/tools/cabana/chart/chart.h +++ b/tools/cabana/chart/chart.h @@ -108,7 +108,7 @@ private: QGraphicsPixmapItem *move_icon; QGraphicsProxyWidget *close_btn_proxy; QGraphicsProxyWidget *manage_btn_proxy; - TipLabel tip_label; + TipLabel *tip_label; std::vector sigs; double cur_sec = 0; SeriesType series_type = SeriesType::Line; diff --git a/tools/cabana/chart/chartswidget.cc b/tools/cabana/chart/chartswidget.cc index 0db99063e0..63d6091cac 100644 --- a/tools/cabana/chart/chartswidget.cc +++ b/tools/cabana/chart/chartswidget.cc @@ -14,7 +14,9 @@ const int MAX_COLUMN_COUNT = 4; const int CHART_SPACING = 4; -ChartsWidget::ChartsWidget(QWidget *parent) : align_timer(this), auto_scroll_timer(this), QFrame(parent) { +ChartsWidget::ChartsWidget(QWidget *parent) : QFrame(parent) { + align_timer = new QTimer(this); + auto_scroll_timer = new QTimer(this); setFrameStyle(QFrame::StyledPanel | QFrame::Plain); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(0, 0, 0, 0); @@ -95,9 +97,9 @@ ChartsWidget::ChartsWidget(QWidget *parent) : align_timer(this), auto_scroll_tim range_slider->setValue(max_chart_range); updateToolBar(); - align_timer.setSingleShot(true); - QObject::connect(&align_timer, &QTimer::timeout, this, &ChartsWidget::alignCharts); - QObject::connect(&auto_scroll_timer, &QTimer::timeout, this, &ChartsWidget::doAutoScroll); + align_timer->setSingleShot(true); + QObject::connect(align_timer, &QTimer::timeout, this, &ChartsWidget::alignCharts); + QObject::connect(auto_scroll_timer, &QTimer::timeout, this, &ChartsWidget::doAutoScroll); QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &ChartsWidget::removeAll); QObject::connect(can, &AbstractStream::eventsMerged, this, &ChartsWidget::eventsMerged); QObject::connect(can, &AbstractStream::msgsReceived, this, &ChartsWidget::updateState); @@ -253,7 +255,7 @@ ChartView *ChartsWidget::createChart() { chart->setFixedHeight(settings.chart_height); chart->setMinimumWidth(CHART_MIN_WIDTH); chart->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - QObject::connect(chart, &ChartView::axisYLabelWidthChanged, &align_timer, qOverload<>(&QTimer::start)); + QObject::connect(chart, &ChartView::axisYLabelWidthChanged, align_timer, qOverload<>(&QTimer::start)); charts.push_front(chart); currentCharts().push_front(chart); updateLayout(true); @@ -334,11 +336,11 @@ void ChartsWidget::updateLayout(bool force) { } void ChartsWidget::startAutoScroll() { - auto_scroll_timer.start(50); + auto_scroll_timer->start(50); } void ChartsWidget::stopAutoScroll() { - auto_scroll_timer.stop(); + auto_scroll_timer->stop(); auto_scroll_count = 0; } diff --git a/tools/cabana/chart/chartswidget.h b/tools/cabana/chart/chartswidget.h index c85cd09963..a39b4d73a5 100644 --- a/tools/cabana/chart/chartswidget.h +++ b/tools/cabana/chart/chartswidget.h @@ -109,8 +109,8 @@ private: int column_count = 1; int current_column_count = 0; int auto_scroll_count = 0; - QTimer auto_scroll_timer; - QTimer align_timer; + QTimer *auto_scroll_timer; + QTimer *align_timer; int current_theme = 0; friend class ZoomCommand; friend class ChartView; diff --git a/tools/cabana/videowidget.cc b/tools/cabana/videowidget.cc index bbb1ef28da..1ecdc8da1c 100644 --- a/tools/cabana/videowidget.cc +++ b/tools/cabana/videowidget.cc @@ -232,7 +232,8 @@ void VideoWidget::updatePlayBtnState() { // Slider -Slider::Slider(QWidget *parent) : thumbnail_label(parent), QSlider(Qt::Horizontal, parent) { +Slider::Slider(QWidget *parent) : QSlider(Qt::Horizontal, parent) { + thumbnail_label = new InfoLabel(parent); setMouseTracking(true); } @@ -321,9 +322,9 @@ void Slider::mouseMoveEvent(QMouseEvent *e) { if (!thumb.isNull()) { int x = std::clamp(pos - thumb.width() / 2, THUMBNAIL_MARGIN, width() - thumb.width() - THUMBNAIL_MARGIN + 1); int y = -thumb.height() - THUMBNAIL_MARGIN; - thumbnail_label.showPixmap(mapToParent(QPoint(x, y)), utils::formatSeconds(seconds), thumb, alertInfo(seconds)); + thumbnail_label->showPixmap(mapToParent(QPoint(x, y)), utils::formatSeconds(seconds), thumb, alertInfo(seconds)); } else { - thumbnail_label.hide(); + thumbnail_label->hide(); } QSlider::mouseMoveEvent(e); } @@ -335,7 +336,7 @@ bool Slider::event(QEvent *event) { case QEvent::FocusIn: case QEvent::FocusOut: case QEvent::Leave: - thumbnail_label.hide(); + thumbnail_label->hide(); break; default: break; diff --git a/tools/cabana/videowidget.h b/tools/cabana/videowidget.h index 69f1edd2bc..e163241fb1 100644 --- a/tools/cabana/videowidget.h +++ b/tools/cabana/videowidget.h @@ -56,7 +56,7 @@ private: QMap thumbnails; std::map alerts; - InfoLabel thumbnail_label; + InfoLabel *thumbnail_label; }; class VideoWidget : public QFrame { From 72cc2e34cbd3ad25557c4b226c12790cb97457cd Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 9 Nov 2023 20:52:21 -0800 Subject: [PATCH 19/24] camerad: reduce to 1s of buffers --- system/camerad/cameras/camera_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/camerad/cameras/camera_common.h b/system/camerad/cameras/camera_common.h index 3e56f5690d..0f69aa3774 100644 --- a/system/camerad/cameras/camera_common.h +++ b/system/camerad/cameras/camera_common.h @@ -26,7 +26,7 @@ #define CAMERA_ID_OX03C10 9 #define CAMERA_ID_MAX 10 -const int YUV_BUFFER_COUNT = 40; +const int YUV_BUFFER_COUNT = 20; enum CameraType { RoadCam = 0, From e94c3c556959112fbe0a465289eb5fec7f4ca63a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 10 Nov 2023 01:20:23 -0800 Subject: [PATCH 20/24] Hyundai CAN: update driver braking signal (#30424) * use DriverOverride * bump --- panda | 2 +- selfdrive/car/hyundai/carstate.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda b/panda index a1d699b87d..5e22e87cf6 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit a1d699b87d05d4ae9d93adc422026864aaedcbdc +Subproject commit 5e22e87cf649ddbef7267bfeb1b7b0793b46dc6c diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index bd3ef828f8..edc9e4855f 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -115,7 +115,7 @@ class CarState(CarStateBase): # TODO: Find brake pressure ret.brake = 0 - ret.brakePressed = cp.vl["TCS13"]["DriverBraking"] != 0 + ret.brakePressed = cp.vl["TCS13"]["DriverOverride"] == 2 # 2 includes regen braking by user on HEV/EV ret.brakeHoldActive = cp.vl["TCS15"]["AVH_LAMP"] == 2 # 0 OFF, 1 ERROR, 2 ACTIVE, 3 READY ret.parkingBrake = cp.vl["TCS13"]["PBRAKE_ACT"] == 1 ret.accFaulted = cp.vl["TCS13"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED From 26294173207cd5e3c586ca71a88fdd3a09fc7345 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Fri, 10 Nov 2023 10:02:05 -0800 Subject: [PATCH 21/24] CI: codecov for multiprocessing (#30432) --- .github/workflows/selfdrive_tests.yaml | 2 ++ pyproject.toml | 3 +++ selfdrive/athena/tests/test_athenad.py | 17 +++++++++-------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index bb5b0a137a..aba630f67c 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -213,6 +213,7 @@ jobs: run: | ${{ env.RUN }} "CI=1 coverage run selfdrive/test/process_replay/test_processes.py -j$(nproc) && \ chmod -R 777 /tmp/comma_download_cache && \ + coverage combine && \ coverage xml" - name: Print diff id: print-diff @@ -282,6 +283,7 @@ jobs: run: | ${{ env.RUN_CL }} "unset PYTHONWARNINGS && \ ONNXCPU=1 CI=1 NO_NAV=1 coverage run selfdrive/test/process_replay/model_replay.py && \ + coverage combine && \ coverage xml" - name: Run unit tests timeout-minutes: 4 diff --git a/pyproject.toml b/pyproject.toml index 71b677fbb7..16dad2c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -199,3 +199,6 @@ flake8-implicit-str-concat.allow-multiline=false "system".msg = "Use openpilot.system" "third_party".msg = "Use openpilot.third_party" "tools".msg = "Use openpilot.tools" + +[tool.coverage.run] +concurrency = ["multiprocessing", "thread"] \ No newline at end of file diff --git a/selfdrive/athena/tests/test_athenad.py b/selfdrive/athena/tests/test_athenad.py index e81753a6a0..8829ebfbf1 100755 --- a/selfdrive/athena/tests/test_athenad.py +++ b/selfdrive/athena/tests/test_athenad.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import json +import multiprocessing import os import requests import shutil @@ -12,7 +13,6 @@ from datetime import datetime, timedelta from parameterized import parameterized from typing import Optional -from multiprocessing import Process from pympler.tracker import SummaryTracker from unittest import mock from websocket import ABNF @@ -75,24 +75,25 @@ class TestAthenadMethods(unittest.TestCase): with self.assertRaises(TimeoutError) as _: dispatcher["getMessage"]("controlsState") - def send_deviceState(): - messaging.context = messaging.Context() - pub_sock = messaging.pub_sock("deviceState") - start = time.time() + end_event = multiprocessing.Event() + + pub_sock = messaging.pub_sock("deviceState") - while time.time() - start < 1: + def send_deviceState(): + while not end_event.is_set(): msg = messaging.new_message('deviceState') pub_sock.send(msg.to_bytes()) time.sleep(0.01) - p = Process(target=send_deviceState) + p = multiprocessing.Process(target=send_deviceState) p.start() time.sleep(0.1) try: deviceState = dispatcher["getMessage"]("deviceState") assert deviceState['deviceState'] finally: - p.terminate() + end_event.set() + p.join() def test_listDataDirectory(self): route = '2021-03-29--13-32-47' From 5f7143df02b857201e2615240ccd1be06daa32fe Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 10 Nov 2023 16:55:25 -0800 Subject: [PATCH 22/24] jenkins: use build.py to manage cache size (#30440) * jenkins: use build.py to manage cache size * label * set pp * double * cleanup * non mimimal build on PC --------- Co-authored-by: Justin Newberry --- Jenkinsfile | 4 ++-- selfdrive/manager/build.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 314170341e..6857ce36e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,7 +85,7 @@ def pcStage(String stageName, Closure body) { checkout scm - def dockerArgs = '--user=batman -v /tmp/comma_download_cache:/tmp/comma_download_cache -v /tmp/scons_cache:/tmp/scons_cache'; + def dockerArgs = "--user=batman -v /tmp/comma_download_cache:/tmp/comma_download_cache -v /tmp/scons_cache:/tmp/scons_cache -e PYTHONPATH=${env.WORKSPACE}"; docker.build("openpilot-base:build-${env.GIT_COMMIT}", "-f Dockerfile.openpilot_base .").inside(dockerArgs) { timeout(time: 20, unit: 'MINUTES') { try { @@ -228,7 +228,7 @@ node { }, 'car tests': { pcStage("car tests") { - sh "scons -j30" + sh label: "build", script: "selfdrive/manager/build.py" sh label: "test_models.py", script: "INTERNAL_SEG_CNT=250 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \ pytest -n42 --dist=loadscope selfdrive/car/tests/test_models.py" sh label: "test_car_interfaces.py", script: "MAX_EXAMPLES=100 pytest -n42 selfdrive/car/tests/test_car_interfaces.py" diff --git a/selfdrive/manager/build.py b/selfdrive/manager/build.py index be37b3e7e4..247f3c8fb8 100755 --- a/selfdrive/manager/build.py +++ b/selfdrive/manager/build.py @@ -19,19 +19,21 @@ TOTAL_SCONS_NODES = 2560 MAX_BUILD_PROGRESS = 100 PREBUILT = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) -def build(spinner: Spinner, dirty: bool = False) -> None: +def build(spinner: Spinner, dirty: bool = False, minimal: bool = False) -> None: env = os.environ.copy() env['SCONS_PROGRESS'] = "1" nproc = os.cpu_count() if nproc is None: nproc = 2 + extra_args = ["--minimal"] if minimal else [] + # building with all cores can result in using too # much memory, so retry with less parallelism compile_output: List[bytes] = [] for n in (nproc, nproc/2, 1): compile_output.clear() - scons: subprocess.Popen = subprocess.Popen(["scons", f"-j{int(n)}", "--cache-populate", "--minimal"], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) + scons: subprocess.Popen = subprocess.Popen(["scons", f"-j{int(n)}", "--cache-populate", *extra_args], cwd=BASEDIR, env=env, stderr=subprocess.PIPE) assert scons.stderr is not None # Read progress from stderr and update spinner @@ -86,4 +88,4 @@ def build(spinner: Spinner, dirty: bool = False) -> None: if __name__ == "__main__" and not PREBUILT: spinner = Spinner() spinner.update_progress(0, 100) - build(spinner, is_dirty()) + build(spinner, is_dirty(), minimal = AGNOS) From 252531e1bbe0ea9ad2eaf97bdf52e0d3f5d77629 Mon Sep 17 00:00:00 2001 From: Hoya Date: Sat, 11 Nov 2023 13:58:59 +0900 Subject: [PATCH 23/24] Hyundai: Add FW for Genesis G80 2018 (#30425) * Update values.py * Update selfdrive/car/hyundai/values.py --------- Co-authored-by: Shane Smiskol --- selfdrive/car/hyundai/values.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index e20bbe279b..edd4f5177c 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -1327,20 +1327,24 @@ FW_VERSIONS = { CAR.GENESIS_G80: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00DH__ SCC F-CUP 1.00 1.01 96400-B1120 ', + b'\xf1\x00DH__ SCC FHCUP 1.00 1.01 96400-B1110 ', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00DH LKAS AT USA LHD 1.01 1.03 95895-B1500 180713', b'\xf1\x00DH LKAS AT USA LHD 1.01 1.02 95895-B1500 170810', b'\xf1\x00DH LKAS AT USA LHD 1.01 1.01 95895-B1500 161014', + b'\xf1\x00DH LKAS AT KOR LHD 1.01 1.02 95895-B1500 170810', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SDH0T33NH4\xd7O\x9e\xc9', b'\xf1\x00bcsh8p54 E18\x00\x00\x00\x00\x00\x00\x00TDH0G38NH3:-\xa9n', b'\xf1\x00bcsh8p54 E18\x00\x00\x00\x00\x00\x00\x00SDH0G38NH2j\x9dA\x1c', b'\xf1\x00bcsh8p54 E18\x00\x00\x00\x00\x00\x00\x00SDH0T33NH3\x97\xe6\xbc\xb8', + b'\xf1\x00bcsh8p54 E18\x00\x00\x00\x00\x00\x00\x00SDH0G33KH2\xae\xde\xd5!', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81640F0051\x00\x00\x00\x00\x00\x00\x00\x00', + b'\xf1\x81640A4051\x00\x00\x00\x00\x00\x00\x00\x00', ], }, CAR.GENESIS_G90: { From 816c18a4ec08441e037f54053fe3da8ecd13b06c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 10 Nov 2023 20:59:14 -0800 Subject: [PATCH 24/24] bump panda (#30437) * bump * bump --- panda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda b/panda index 5e22e87cf6..5fe1d67b77 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 5e22e87cf649ddbef7267bfeb1b7b0793b46dc6c +Subproject commit 5fe1d67b7729c843df7dd15df5d375d08ed410c6