diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f0cdc3cef..02fbd9c892 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ variables: stages: - build + - sanity - publish - notify @@ -70,6 +71,7 @@ build: paths: - "${CI_DIR}/scons_cache" before_script: + - find $BUILD_DIR/ -mindepth 1 -delete - *default_before_script - "echo Starting build stage..." - "echo BUILD_DIR: ${BUILD_DIR}" @@ -79,7 +81,6 @@ build: - git config --global --add safe.directory ${CI_PROJECT_DIR} script: - export PYTHONPATH="$BUILD_DIR" - - "echo Calling to build [${CI_DIR}/build.sh ${CI_PROJECT_DIR} ${BUILD_DIR} ${VERSION}]" - "echo Building Panda..." - scons -j$(nproc) cache_dir=${CI_DIR}/scons_cache ${CI_PROJECT_DIR}/panda - mkdir -p ${BUILD_DIR} @@ -89,28 +90,50 @@ build: - cd $BUILD_DIR - sed -i '/from .board.jungle import PandaJungle, PandaJungleDFU/s/^/#/' panda/__init__.py # comment panda jungle when prebuilt - scons -j$(nproc) cache_dir=${CI_DIR}/scons_cache - - # Cleanup - - echo "Doing cleanup for prebuilt\n\n" - - echo "Deleting specified files..." - - find ${BUILD_DIR} \( -name '*.a' -o -name '*.o' -o -name '*.os' -o -name '*.pyc' -o -name 'moc_*' -o -name '*.cc' -o -name "Jenkinsfile" -o -name "supercombo.onnx" -o -name ".sconsign.dblite" \) -print -delete - - - echo "Deleting Headers from selfdrive/ui path..." - - find ${BUILD_DIR}/selfdrive/ui -type f -name '*.h' -print -delete - - - echo "Deleting the following folders and subdirectories..." - - find "${BUILD_DIR}" -type d \( -path "*panda/board" -o -path "*panda/certs" -o -path "*panda/crypto" -o -path "*release" -o -path "*.github" -o -path "*selfdrive/ui/replay" -o -path "*__pycache__" \) -print -exec rm -rf {} + - - # Move back signed panda fw - - mkdir -p ${BUILD_DIR}/panda/board/obj - - cp ${CI_PROJECT_DIR}/panda/board/obj/panda.bin.signed ${BUILD_DIR}/panda/board/obj/panda.bin.signed - - cp ${CI_PROJECT_DIR}/panda/board/obj/panda_h7.bin.signed ${BUILD_DIR}/panda/board/obj/panda_h7.bin.signed - - cp ${CI_PROJECT_DIR}/panda/board/obj/bootstub.panda.bin ${BUILD_DIR}/panda/board/obj/bootstub.panda.bin - - cp ${CI_PROJECT_DIR}/panda/board/obj/bootstub.panda_h7.bin ${BUILD_DIR}/panda/board/obj/bootstub.panda_h7.bin - touch ${BUILD_DIR}/prebuilt + - sudo rm -rf ${OUTPUT_DIR} - mkdir -p ${OUTPUT_DIR} - - shopt -s dotglob && mv ${BUILD_DIR}/* ${OUTPUT_DIR} - - sudo chown -R comma:comma ${OUTPUT_DIR} + # We first include the paths we want to keep, even if we later will be excluding the other things on those paths + - rsync -av + --include='**/panda/board/' + --include='**/panda/board/obj' + --include='**/panda/board/obj/panda.bin.signed' + --include='**/panda/board/obj/panda_h7.bin.signed' + --include='**/panda/board/obj/bootstub.panda.bin' + --include='**/panda/board/obj/bootstub.panda_h7.bin' + --exclude='.sconsign.dblite' + --exclude='*.a' + --exclude='*.A' + --exclude='*.o' + --exclude='*.O' + --exclude='*.os' + --exclude='*.OS' + --exclude='*.pyc' + --exclude='*.PYC' + --exclude='moc_*' + --exclude='MOC_*' + --exclude='*.cc' + --exclude='*.CC' + --exclude='Jenkinsfile' + --exclude='supercombo.onnx' + --exclude='**/panda/board/*' + --exclude='**/panda/board/obj/**' + --exclude='**/panda/certs/' + --exclude='**/panda/crypto/' + --exclude='**/release/' + --exclude='**/.github/' + --exclude='**/selfdrive/ui/replay/' + --exclude='**/__pycache__/' + --exclude='**/selfdrive/ui/*.h' + --exclude='**/selfdrive/ui/**/*.h' + --exclude='**/selfdrive/ui/qt/offroad/sunnypilot/' + --exclude='**/.git/' + --delete-excluded + --chown=comma:comma + ${BUILD_DIR}/ ${OUTPUT_DIR}/ + after_script: + # cleanup build dir after doing work + - find $BUILD_DIR/ -mindepth 1 -delete artifacts: paths: - ${OUTPUT_DIR}/ @@ -120,6 +143,27 @@ build: when: manual - if: $NEW_BRANCH when: always + +check no source code sent: + stage: sanity + variables: + FORBIDDEN_FILE_EXTENSIONS: "*.a,*.o,*.os,*.pyc,moc_*,*.cc,Jenkinsfile,supercombo.onnx,.sconsign.dblite" + FORBIDDEN_DIR_PATTERNS: "*panda/certs,*panda/crypto,*release,*.github,*selfdrive/ui/replay,*__pycache__" + REQUIRED_FILE_EXTENSIONS: "*.py,*.json" + REQUIRED_DIR_PATTERNS: "*selfdrive/ui,*openpilot" + before_script: + - apk update && apk upgrade + - apk add bash findutils + script: + - cd ${OUTPUT_DIR} + - echo "Checking that we have properly cleaned up" + - ${CI_DIR}/sanity_check.sh "$FORBIDDEN_FILE_EXTENSIONS" "$FORBIDDEN_DIR_PATTERNS" true + - echo "Checking that our sanity check works and also checking that some required files are indeed found" + - ${CI_DIR}/sanity_check.sh "$REQUIRED_FILE_EXTENSIONS" "$REQUIRED_DIR_PATTERNS" false + rules: + - if: $NEW_BRANCH + when: on_success + - when: never .publish_base: &publish_base variables: @@ -128,6 +172,9 @@ build: needs: - job: build artifacts: true + - job: "check no source code sent" + artifacts: false + optional: false before_script: - 'apk update && apk upgrade' - 'apk add git bash openssh' diff --git a/CHANGELOGS.md b/CHANGELOGS.md index 76cbb73382..7f729fc9cf 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -4,6 +4,7 @@ sunnypilot - 0.9.6.0 (2024-xx-xx) * NEW❗: Default Driving Model: Los Angeles v2 (January 24, 2024) * UPDATED: Driving Model Selector v3 * NEW❗: Driving Model additions + * Certified Herbalist v2 (February 13, 2024) - CHv2 * Certified Herbalist (February 5, 2024) - CH * Los Angeles v2 (January 24, 2024) - LAv2 * Los Angeles (January 22, 2024) - LAv1 @@ -16,15 +17,15 @@ sunnypilot - 0.9.6.0 (2024-xx-xx) * Blue Diamond (November 18, 2023) - BDv1 * Farmville (November 7, 2023) - FV * Night Strike (October 3, 2023) - NS - * Certain features are deprecated with Legacy Driving Models + * Certain features are deprecated with newer Driving Models * Dynamic Lane Profile * Custom Offsets * UPDATED: Dynamic Lane Profile (DLP) * Continued support for Legacy Driving Models (e.g., ND, BDv2, BDv1, FV, NS) - * Deprecate support for newer Driving Models (e.g., CH, LAv2, LAv1) + * Deprecate support for newer Driving Models (e.g., CHv2, CH, LAv2, LAv1) * UPDATED: Custom Offsets * Continued support for Legacy Driving Models (e.g., ND, BDv2, BDv1, FV, NS) - * Deprecate support for newer Driving Models (e.g., CH, LAv2, LAv1) + * Deprecate support for newer Driving Models (e.g., CHv2, CH, LAv2, LAv1) * FIXED: New comma 3X support * FIXED: New comma eSIM support * Bug fixes and performance improvements diff --git a/release/ci/install_gitlab_runner.sh b/release/ci/install_gitlab_runner.sh index a44c13cc92..0dccc95154 100755 --- a/release/ci/install_gitlab_runner.sh +++ b/release/ci/install_gitlab_runner.sh @@ -64,6 +64,7 @@ set_gitlab_directory_permissions() { sudo chmod g+s "$GITLAB_BASE_DIR" } +# Please note that when the gitlab runner is started, linux implicitly executes "source /etc/profile" for every logged shell. This will make scons available create_gitlab_runner_service() { cat <= CONTROL_N + if model_good and (self.use_nn or self.use_lateral_jerk): # prepare "look-ahead" desired lateral jerk lookahead = interp(CS.vEgo, self.friction_look_ahead_bp, self.friction_look_ahead_v) friction_upper_idx = next((i for i, val in enumerate(ModelConstants.T_IDXS) if val > lookahead), 16) predicted_lateral_jerk = get_predicted_lateral_jerk(model_data.acceleration.y, self.t_diffs) - desired_lateral_jerk = (interp(self.desired_lat_jerk_time, ModelConstants.T_IDXS, model_data.acceleration.y) - actual_lateral_accel) / self.desired_lat_jerk_time + desired_lateral_jerk = (interp(self.desired_lat_jerk_time, ModelConstants.T_IDXS, model_data.acceleration.y) - desired_lateral_accel) / self.desired_lat_jerk_time lookahead_lateral_jerk = get_lookahead_value(predicted_lateral_jerk[LAT_PLAN_MIN_IDX:friction_upper_idx], desired_lateral_jerk) if self.use_steering_angle or lookahead_lateral_jerk == 0.0: lookahead_lateral_jerk = 0.0 @@ -203,12 +204,12 @@ class LatControlTorque(LatControl): lateral_jerk_setpoint = self.lat_jerk_friction_factor * lookahead_lateral_jerk lateral_jerk_measurement = self.lat_jerk_friction_factor * actual_lateral_jerk - model_good = model_data is not None and len(model_data.orientation.x) >= CONTROL_N if self.use_nn and model_good: # update past data roll = params.roll - pitch = self.pitch.update(llk.calibratedOrientationNED.value[1]) - roll = roll_pitch_adjust(roll, pitch) + if len(llk.calibratedOrientationNED.value) > 1: + pitch = self.pitch.update(llk.calibratedOrientationNED.value[1]) + roll = roll_pitch_adjust(roll, pitch) self.roll_deque.append(roll) self.lateral_accel_desired_deque.append(desired_lateral_accel) diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index cd7e14a8e3..e39892a13b 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -166,6 +166,10 @@ def manager_init() -> None: if os.path.isfile(os.path.join(sentry.CRASHES_DIR, 'error.txt')): os.remove(os.path.join(sentry.CRASHES_DIR, 'error.txt')) + models_dir = "/data/media/0/models" + if not os.path.exists(models_dir): + os.makedirs(models_dir) + # preimport all processes for p in managed_processes.values(): p.prepare() diff --git a/selfdrive/modeld/navmodeld.py b/selfdrive/modeld/navmodeld.py index bfe9c8fbed..47439dbab6 100755 --- a/selfdrive/modeld/navmodeld.py +++ b/selfdrive/modeld/navmodeld.py @@ -15,6 +15,7 @@ from openpilot.common.params import Params from openpilot.common.realtime import set_realtime_priority from openpilot.selfdrive.modeld.constants import ModelConstants from openpilot.selfdrive.modeld.runners import ModelRunner, Runtime +from openpilot.selfdrive.sunnypilot import get_model_generation NAV_INPUT_SIZE = 256*256 NAV_FEATURE_LEN = 256 @@ -51,7 +52,8 @@ class ModelState: assert ctypes.sizeof(NavModelResult) == NAV_OUTPUT_SIZE * ctypes.sizeof(ctypes.c_float) self.output = np.zeros(NAV_OUTPUT_SIZE, dtype=np.float32) self.param_s = Params() - if self.param_s.get_bool("CustomDrivingModel"): + self.custom_model, self.model_gen = get_model_generation(self.param_s) + if self.custom_model and self.model_gen != 0: _model_name = self.param_s.get("NavModelText", encoding="utf8") _model_paths = { ModelRunner.SNPE: f"{CUSTOM_MODEL_PATH}/navmodel_q_{_model_name}.dlc"} diff --git a/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc b/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc index 616bee253d..17e219ec7c 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot/software_settings_sp.cc @@ -68,7 +68,7 @@ QString SoftwarePanelSP::GetModelName() { return selectedModelToDownload->displayName; } - if (params.getBool("CustomDrivingModel")) { + if (params.getBool("CustomDrivingModel") && QString::fromStdString(params.get("DrivingModelGeneration")) != "0") { return QString::fromStdString(params.get("DrivingModelName")); }