mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-11-30 03:24:03 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 691d46c7e6 | |||
| 658b45a5ed | |||
| 33f549d0c4 | |||
| 5fe5ec7ad1 | |||
| aa9bc9ddd1 | |||
| 6f903a7806 | |||
| e3829360d0 | |||
| a598f43690 | |||
| 7f8db47fd0 | |||
| 1291d14108 | |||
| c831334d76 | |||
| 5958b2d25b | |||
| 73c8b30fa9 | |||
| 8bdb2f54d9 | |||
| 9c1bdde65b | |||
| 914aaefac1 | |||
| d05649c0a4 | |||
| 3521140920 | |||
| 56628fc770 | |||
| 60a9cc8657 |
@@ -1,56 +0,0 @@
|
||||
name: Compile and check the big warps
|
||||
description: Compile the chestnut warps for each camera and warm up stock modeld on them, on the amd mock
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: ./tools/op.sh setup
|
||||
shell: bash
|
||||
|
||||
- name: Build modeld deps
|
||||
shell: bash
|
||||
run: scons -j$(nproc) msgq_repo/msgq openpilot/common
|
||||
|
||||
- name: Compile big warp
|
||||
shell: bash
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
|
||||
CHESTNUT_TG_FLAGS="DEBUG=1 DEV=USB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 CHECK_OOB=0 TC_OPT=2 TC_MIN_GLOBALS=32"
|
||||
COMPILER="${{ github.workspace }}/tinygrad_repo/examples/openpilot"
|
||||
MODELS_DIR="${{ github.workspace }}/openpilot/selfdrive/modeld/models"
|
||||
MODEL_SIZE=$(python3 -c "from openpilot.common.transformations.model import MEDMODEL_INPUT_SIZE as s; print(f'{s[0]}x{s[1]}')")
|
||||
|
||||
for res in $(python3 -c "from openpilot.common.transformations.camera import _ar_ox_fisheye as a, _os_fisheye as o; print(f'{a.width}x{a.height} {o.width}x{o.height}')"); do
|
||||
CAM_W=$(echo $res | cut -d x -f1)
|
||||
CAM_H=$(echo $res | cut -d x -f2)
|
||||
STRIDE_INFO=$(python3 -c "
|
||||
import sys
|
||||
from openpilot.system.camerad.cameras.nv12_info import get_nv12_info
|
||||
s,y,u,sz = get_nv12_info(int(sys.argv[1]), int(sys.argv[2]))
|
||||
print(f'{s},{y},{u},{s*(y+u)}')
|
||||
" $CAM_W $CAM_H)
|
||||
WARP_PKL="${MODELS_DIR}/big_driving_warp_${res}_tinygrad.pkl"
|
||||
python3 tinygrad_repo/test/mockgpu/usb_server.py env PYTHONPATH="$PYTHONPATH" ${CHESTNUT_TG_FLAGS} python3 "${COMPILER}/compile_warp.py" \
|
||||
--frame ${CAM_W},${CAM_H},${STRIDE_INFO} \
|
||||
--warp-to ${MODEL_SIZE} \
|
||||
--layout yuv420 \
|
||||
--frames 2 \
|
||||
--benchmark-runs 0 \
|
||||
--retargetable \
|
||||
--output "${WARP_PKL}"
|
||||
done
|
||||
|
||||
- name: Warm up stock modeld on the big warps
|
||||
shell: bash
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
fail=0
|
||||
for res in $(python3 -c "from openpilot.common.transformations.camera import _ar_ox_fisheye as a, _os_fisheye as o; print(f'{a.width}x{a.height} {o.width}x{o.height}')"); do
|
||||
echo "warming up stock modeld on ${res}"
|
||||
python3 tinygrad_repo/test/mockgpu/usb_server.py env PYTHONPATH="$PYTHONPATH" GMMU=0 CHECK_OOB=0 python3 -c "
|
||||
import sys
|
||||
from openpilot.selfdrive.modeld.modeld import ModelState
|
||||
ModelState(*map(int, sys.argv[1].split('x')), chestnut=True).warmup()
|
||||
" $res || { echo "::error::stock modeld warmup failed on the ${res} big warp"; fail=1; }
|
||||
done
|
||||
exit $fail
|
||||
@@ -166,7 +166,37 @@ jobs:
|
||||
with:
|
||||
emu_cache: big-warp
|
||||
|
||||
- uses: ./.github/workflows/big-warp
|
||||
- name: Install the amd mock build dependencies
|
||||
run: python3 -m pip install -q numpy zstandard
|
||||
|
||||
- name: Compile big warp
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
|
||||
CHESTNUT_TG_FLAGS="DEBUG=1 DEV=USB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 CHECK_OOB=0 TC_OPT=2 TC_MIN_GLOBALS=32"
|
||||
COMPILER="${{ github.workspace }}/tinygrad_repo/examples/openpilot"
|
||||
MODELS_DIR="${{ github.workspace }}/openpilot/selfdrive/modeld/models"
|
||||
MODEL_SIZE=$(python3 -c "from openpilot.common.transformations.model import MEDMODEL_INPUT_SIZE as s; print(f'{s[0]}x{s[1]}')")
|
||||
|
||||
for res in $(python3 -c "from openpilot.common.transformations.camera import _ar_ox_fisheye as a, _os_fisheye as o; print(f'{a.width}x{a.height} {o.width}x{o.height}')"); do
|
||||
CAM_W=$(echo $res | cut -d x -f1)
|
||||
CAM_H=$(echo $res | cut -d x -f2)
|
||||
STRIDE_INFO=$(python3 -c "
|
||||
import sys
|
||||
from openpilot.system.camerad.cameras.nv12_info import get_nv12_info
|
||||
s,y,u,sz = get_nv12_info(int(sys.argv[1]), int(sys.argv[2]))
|
||||
print(f'{s},{y},{u},{sz}')
|
||||
" $CAM_W $CAM_H)
|
||||
WARP_PKL="${MODELS_DIR}/big_driving_warp_${res}_tinygrad.pkl"
|
||||
python3 tinygrad_repo/test/mockgpu/usb_server.py env PYTHONPATH="$PYTHONPATH" ${CHESTNUT_TG_FLAGS} python3 "${COMPILER}/compile_warp.py" \
|
||||
--frame ${CAM_W},${CAM_H},${STRIDE_INFO} \
|
||||
--warp-to ${MODEL_SIZE} \
|
||||
--layout yuv420 \
|
||||
--frames 2 \
|
||||
--benchmark-runs 0 \
|
||||
--retargetable \
|
||||
--output "${WARP_PKL}"
|
||||
done
|
||||
|
||||
- name: Prepare output
|
||||
env:
|
||||
|
||||
@@ -39,6 +39,11 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
default: 'qcom'
|
||||
on_device:
|
||||
description: 'Compile on the tici / chestnut runner instead of on a hosted runner with tinygrad''s qcom / amd mock'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
hf_repo:
|
||||
description: 'Hugging Face dataset repository (e.g. sunnypilot/sunnypilot_models_v1)'
|
||||
required: false
|
||||
@@ -117,6 +122,11 @@ on:
|
||||
options:
|
||||
- qcom
|
||||
- chestnut
|
||||
on_device:
|
||||
description: 'Compile on the tici / chestnut runner instead of on a hosted runner with tinygrad''s qcom / amd mock'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
hf_repo:
|
||||
description: 'Hugging Face dataset repository'
|
||||
required: false
|
||||
@@ -141,6 +151,7 @@ jobs:
|
||||
is_20hz: ${{ inputs.is_20hz }}
|
||||
artifact_suffix: ${{ inputs.artifact_suffix }}
|
||||
target_hardware: ${{ inputs.target_hardware }}
|
||||
on_device: ${{ inputs.on_device || false }}
|
||||
secrets: inherit
|
||||
|
||||
publish_model:
|
||||
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
concurrency:
|
||||
group: build-${{ github.head_ref || github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
runs-on: ubuntu-24.04-arm
|
||||
runs-on: [self-hosted, tici]
|
||||
if: ${{
|
||||
(always() && !cancelled() && !failure()) &&
|
||||
needs.prepare_strategy.result == 'success' &&
|
||||
@@ -129,59 +129,55 @@ jobs:
|
||||
repository: ${{ github.event.pull_request.head.repo.fork && github.event.pull_request.head.repo.full_name || github.repository }}
|
||||
- run: ./lfs.py pull --exclude=''
|
||||
|
||||
- name: Import the AGNOS system image this commit pins
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
read -r URL HASH HASH_RAW < <(python3 -c "import json; p = next(p for p in json.load(open('openpilot/common/hardware/comma/agnos.json')) if p['name'] == 'system'); print(p['url'], p['hash'], p['hash_raw'])")
|
||||
curl -fsSL --retry 3 "$URL" | xz -dc -T0 > "$RUNNER_TEMP/system.sparse.img"
|
||||
echo "$HASH $RUNNER_TEMP/system.sparse.img" | sha256sum -c
|
||||
sudo apt-get -qq update && sudo apt-get -qq install -y --no-install-recommends android-sdk-libsparse-utils
|
||||
simg2img "$RUNNER_TEMP/system.sparse.img" "$RUNNER_TEMP/system.img" && rm "$RUNNER_TEMP/system.sparse.img"
|
||||
echo "$HASH_RAW $RUNNER_TEMP/system.img" | sha256sum -c
|
||||
sudo mkdir -p /mnt/agnos && sudo mount -o loop,ro "$RUNNER_TEMP/system.img" /mnt/agnos
|
||||
sudo tar -C /mnt/agnos --exclude=./etc/resolv.conf -c . | docker import - agnos # a symlink into /run: docker writes its own
|
||||
sudo umount /mnt/agnos && rm "$RUNNER_TEMP/system.img"
|
||||
|
||||
- name: Build Main Project in AGNOS
|
||||
run: |
|
||||
cat > "$RUNNER_TEMP/build.sh" <<'EOF'
|
||||
set -e
|
||||
source /etc/profile
|
||||
set -x
|
||||
# Set up common environment
|
||||
source /etc/profile;
|
||||
export UV_PROJECT_ENVIRONMENT=${HOME}/venv
|
||||
export UV_PYTHON_PREFERENCE=managed
|
||||
export UV_PYTHON_INSTALL_DIR=${HOME}/uv/python
|
||||
export VIRTUAL_ENV=$UV_PROJECT_ENVIRONMENT
|
||||
mkdir -p "$HOME"
|
||||
git config --global --add safe.directory '*'
|
||||
cat /VERSION
|
||||
clang --version | head -1
|
||||
cd /src
|
||||
uv sync
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Setup build environment
|
||||
run: |
|
||||
mkdir -p "${BUILD_DIR}/"
|
||||
sudo find $BUILD_DIR/ -mindepth 1 -delete
|
||||
echo "Starting build stage..."
|
||||
echo "BUILD_DIR: ${BUILD_DIR}"
|
||||
echo "CI_DIR: ${CI_DIR}"
|
||||
echo "VERSION: ${{ needs.prepare_strategy.outputs.version }}"
|
||||
echo "UV_PROJECT_ENVIRONMENT: ${UV_PROJECT_ENVIRONMENT}"
|
||||
echo "VIRTUAL_ENV: ${VIRTUAL_ENV}"
|
||||
echo "-------"
|
||||
if [[ "${{ runner.debug }}" == "1" ]]; then
|
||||
printenv
|
||||
fi
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
|
||||
- name: Build Main Project
|
||||
run: |
|
||||
export PYTHONPATH="$BUILD_DIR:$BUILD_DIR/msgq_repo:$BUILD_DIR/opendbc_repo:$BUILD_DIR/rednose_repo:$BUILD_DIR/teleoprtc_repo:$BUILD_DIR/tinygrad_repo"
|
||||
./tools/release/release_files.py | xargs -0 cp -pR --parents -t "$BUILD_DIR" --
|
||||
pip install -q tinymesa==25.2.7.2
|
||||
# scons passes the warp commands only PATH, TMPDIR and PYTHONPATH, so the mock goes into the command itself
|
||||
sed -i "s/'DEV=QCOM /'DEV=MOCK+QCOM HCQ_RUNTIME_DEV=CPU:LLVM:arm64,cortex-a75,fp-armv8,sha2,lse,neon,crc,aes /" "$BUILD_DIR/openpilot/selfdrive/modeld/SConscript"
|
||||
grep -q "'DEV=MOCK+QCOM " "$BUILD_DIR/openpilot/selfdrive/modeld/SConscript"
|
||||
# msgq builds the ION vision buffers only when /dev/ion exists; the device has one, the runner does not
|
||||
touch /dev/ion
|
||||
SCONS_CACHE=/data/scons_cache
|
||||
# outside the checkout, which is wiped each run. /data/scons_cache is the device's, not ours.
|
||||
SCONS_CACHE="$RUNNER_WORKSPACE/scons_cache"
|
||||
mkdir -p "$SCONS_CACHE"
|
||||
cd $BUILD_DIR
|
||||
rm -rf /tmp/* || true
|
||||
echo "Building locationd..."
|
||||
# -j1: parallel rednose generators OOM the device
|
||||
scons -j1 cache_dir="$SCONS_CACHE" --minimal \
|
||||
openpilot/selfdrive/locationd
|
||||
echo "Building rest of sunnypilot"
|
||||
sudo rm -rf /tmp/* || true
|
||||
mkdir -p "$BUILD_DIR/tmp"
|
||||
export TMPDIR="$BUILD_DIR/tmp"
|
||||
SKIP_TINYGRAD_COMPILE=1 scons -j$(nproc) cache_dir="$SCONS_CACHE" --minimal
|
||||
SKIP_TINYGRAD_COMPILE=1 /usr/bin/time -v scons -j$(nproc) cache_dir="$SCONS_CACHE" --minimal
|
||||
touch ${BUILD_DIR}/prebuilt
|
||||
EOF
|
||||
sudo mkdir -p "$BUILD_DIR" && sudo chown -R "$(id -u):$(id -g)" /data
|
||||
# AGNOS mounts these at boot (usr/comma/boot.sh); its uv and pip shims remount / read-only and resize /tmp
|
||||
# /root: scons drops HOME, so tinygrad's compile cache lands in root's home
|
||||
docker run --rm --privileged -e CI=true -e HOME=/data/media/0/github -e BUILD_DIR \
|
||||
--tmpfs /tmp:rw,exec,nosuid,nodev,size=150m,nr_inodes=1m,mode=1777 --tmpfs /var:rw,exec,nosuid,nodev,size=128m,mode=755 \
|
||||
--tmpfs /home:rw,exec,nosuid,nodev,size=100m,mode=755 --tmpfs /root:rw,exec,nosuid,nodev,size=1g,mode=700 \
|
||||
-v "$GITHUB_WORKSPACE:/src" -v /data:/data -v "$RUNNER_TEMP/build.sh:/build.sh:ro" agnos bash /build.sh
|
||||
sudo chown -R "$(id -u):$(id -g)" "$BUILD_DIR"
|
||||
if [[ "${{ runner.debug }}" == "1" ]]; then
|
||||
ls -la ${BUILD_DIR}
|
||||
fi
|
||||
|
||||
- name: Strip release tree
|
||||
run: |
|
||||
@@ -194,7 +190,7 @@ jobs:
|
||||
find . -name '__pycache__' -type d -exec rm -rf {} +
|
||||
find . -name 'SConstruct' -delete
|
||||
find . -name 'SConscript' -delete
|
||||
rm -rf .sconsign.dblite tools/release/ release/
|
||||
rm -rf .sconsign.dblite Jenkinsfile tools/release/ release/
|
||||
rm -f openpilot/selfdrive/modeld/models/*.onnx*
|
||||
rm -f openpilot/sunnypilot/modeld*/models/*.onnx*
|
||||
find openpilot/third_party/ -name '*x86*' -exec rm -r {} +
|
||||
@@ -213,6 +209,12 @@ jobs:
|
||||
path: prebuilt.tar.gz
|
||||
compression-level: 0
|
||||
|
||||
- name: Re-enable powersave
|
||||
if: always()
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
prepare_chestnut:
|
||||
needs: [ prepare_strategy ]
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
@@ -3,6 +3,8 @@ name: Build dev
|
||||
env:
|
||||
DEFAULT_SOURCE_BRANCH: "master"
|
||||
DEFAULT_TARGET_BRANCH: "master-dev"
|
||||
LFS_URL: 'https://gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git/info/lfs'
|
||||
LFS_PUSH_URL: 'ssh://git@gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git'
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -64,6 +66,15 @@ jobs:
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
|
||||
- name: Set up SSH
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
|
||||
- name: Add GitLab public keys
|
||||
run: |
|
||||
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
@@ -156,6 +167,13 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Update LFS Config
|
||||
run: |
|
||||
echo '[lfs]' > .lfsconfig
|
||||
echo ' url = ${{ env.LFS_URL }}' >> .lfsconfig
|
||||
echo ' pushurl = ${{ env.LFS_PUSH_URL }}' >> .lfsconfig
|
||||
echo ' locksverify = false' >> .lfsconfig
|
||||
|
||||
- name: Restore workflows from source
|
||||
run: |
|
||||
TARGET_BRANCH="${{ inputs.target_branch || env.DEFAULT_TARGET_BRANCH }}"
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Test big warps with stock modeld
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'openpilot/selfdrive/modeld/**'
|
||||
- 'tinygrad_repo'
|
||||
- 'openpilot/system/camerad/cameras/nv12_info.py'
|
||||
- '.github/workflows/big-warp/**'
|
||||
- '.github/workflows/test-big-warp.yaml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
big-warp:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Pull big PKL via LFS
|
||||
run: ./lfs.py pull --exclude=''
|
||||
- uses: ./.github/workflows/setup-amd-mock
|
||||
with:
|
||||
emu_cache: big-warp
|
||||
- uses: ./.github/workflows/big-warp
|
||||
@@ -4,6 +4,7 @@
|
||||
[submodule "opendbc"]
|
||||
path = opendbc_repo
|
||||
url = https://github.com/sunnypilot/opendbc.git
|
||||
branch = toyotabsmhack
|
||||
[submodule "msgq"]
|
||||
path = msgq_repo
|
||||
url = https://github.com/sunnypilot/msgq.git
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[lfs]
|
||||
url = https://gitlab.com/commaai/openpilot-lfs.git/info/lfs
|
||||
pushurl = ssh://git@gitlab.com/commaai/openpilot-lfs.git
|
||||
locksverify = false
|
||||
+2
-16
@@ -41,7 +41,7 @@ run = "tools/release/check-dirty.sh"
|
||||
# the UP replays the CAN until the step ends
|
||||
[[jobs.onroad.steps]]
|
||||
name = "Onroad tests"
|
||||
run = "openpilot/tools/replay/can_replay.py && ./openpilot/selfdrive/test/test_onroad.py TestOnroad"
|
||||
run = "openpilot/tools/replay/can_replay.py --up && ./openpilot/selfdrive/test/test_onroad.py TestOnroad"
|
||||
timeout-minutes = 1.5
|
||||
|
||||
[jobs.hardware]
|
||||
@@ -63,20 +63,6 @@ run = "./openpilot/system/manager/test/test_manager.py"
|
||||
name = "Power draw"
|
||||
run = "./openpilot/selfdrive/test/test_power_draw.py"
|
||||
|
||||
[jobs.install]
|
||||
runs-on = "up-mici"
|
||||
timeout-minutes = 45
|
||||
|
||||
[[jobs.install.steps]]
|
||||
name = "Install this branch on a fresh mici"
|
||||
run = 'scripts/test_mici_install.sh "https://installer.comma.ai/${GIT_REPO%/*}/$GIT_BRANCH" "$GIT_COMMIT"'
|
||||
timeout-minutes = 20
|
||||
|
||||
[[jobs.install.steps]]
|
||||
name = "Install the release on a fresh mici"
|
||||
run = "scripts/test_mici_install.sh https://openpilot.comma.ai origin/release-mici"
|
||||
timeout-minutes = 20
|
||||
|
||||
[jobs.replay]
|
||||
runs-on = "up-mici"
|
||||
timeout-minutes = 35
|
||||
@@ -159,7 +145,7 @@ mkdir -p /data/pandaextra/certs && printf '%s\n' "$PANDA_RELEASE_KEY" > /data/pa
|
||||
unset RELEASE_KEY PANDA_RELEASE_KEY
|
||||
export GIT_SSH_COMMAND="ssh -i /data/gitkey -o StrictHostKeyChecking=accept-new"
|
||||
git config remote.origin.url git@github.com:commaai/openpilot.git
|
||||
if [ -n "${UP_REMOTE:-}" ]; then openpilot/tools/replay/can_replay.py; fi
|
||||
if [ -n "${UP_REMOTE:-}" ]; then openpilot/tools/replay/can_replay.py --up; fi
|
||||
tools/release/build_release.sh $RELEASE_TESTS
|
||||
"""
|
||||
|
||||
|
||||
@@ -12,6 +12,13 @@ function agnos_init {
|
||||
# set success flag for current boot slot
|
||||
sudo abctl --set_success
|
||||
|
||||
# TODO: do this without udev in AGNOS
|
||||
# udev does this, but sometimes we startup faster
|
||||
sudo chgrp gpu /dev/adsprpc-smd /dev/ion /dev/kgsl-3d0
|
||||
sudo chmod 660 /dev/adsprpc-smd /dev/ion /dev/kgsl-3d0
|
||||
sudo chgrp audio /dev/snd/*C*
|
||||
sudo chmod 660 /dev/snd/*C*
|
||||
|
||||
# Check if AGNOS update is required
|
||||
if [ "$(< /VERSION)" != "$AGNOS_VERSION" ]; then
|
||||
AGNOS_PY="$DIR/openpilot/common/hardware/comma/agnos.py"
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ export OPENBLAS_NUM_THREADS=1
|
||||
export VECLIB_MAXIMUM_THREADS=1
|
||||
|
||||
if [ -z "$AGNOS_VERSION" ]; then
|
||||
export AGNOS_VERSION="20.6"
|
||||
export AGNOS_VERSION="20.6-994bc1b"
|
||||
fi
|
||||
|
||||
export STAGING_ROOT="/data/safe_staging"
|
||||
|
||||
+1
-1
Submodule opendbc_repo updated: 07fb3ab9bc...2f8d0f6894
@@ -3,7 +3,6 @@ from openpilot.common.api.comma_connect import API_HOST as API_HOST, CommaConnec
|
||||
|
||||
class Api:
|
||||
def __init__(self, dongle_id):
|
||||
self.dongle_id = dongle_id
|
||||
self.service = CommaConnectApi(dongle_id)
|
||||
|
||||
def request(self, method, endpoint, **params):
|
||||
|
||||
@@ -137,7 +137,6 @@ class AtClient:
|
||||
|
||||
def send_raw(self, data: bytes) -> None:
|
||||
self._ensure_serial()
|
||||
assert self._serial is not None
|
||||
self._serial.reset_input_buffer()
|
||||
self._serial.write(data)
|
||||
self._serial.flush()
|
||||
@@ -157,11 +156,9 @@ class AtClient:
|
||||
def _send(self, cmd: str) -> None:
|
||||
if DEBUG:
|
||||
print(f"SER >> {cmd}", file=sys.stderr)
|
||||
assert self._serial is not None
|
||||
self._serial.write((cmd + "\r").encode("ascii"))
|
||||
|
||||
def _expect(self) -> list[str]:
|
||||
assert self._serial is not None
|
||||
lines: list[str] = []
|
||||
while True:
|
||||
raw = self._serial.readline()
|
||||
|
||||
@@ -112,9 +112,6 @@ class HardwareBase(ABC):
|
||||
def get_network_metered(self, network_type) -> bool:
|
||||
return network_type not in (NetworkType.none, NetworkType.wifi, NetworkType.ethernet)
|
||||
|
||||
def get_voltage(self):
|
||||
return 0
|
||||
|
||||
def get_current_power_draw(self):
|
||||
return 0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"name": "xbl",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/xbl-e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/xbl-e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb.img.xz",
|
||||
"hash": "e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb",
|
||||
"hash_raw": "e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb",
|
||||
"size": 3282256,
|
||||
@@ -12,7 +12,7 @@
|
||||
},
|
||||
{
|
||||
"name": "xbl_config",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/xbl_config-758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/xbl_config-758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85.img.xz",
|
||||
"hash": "758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85",
|
||||
"hash_raw": "758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85",
|
||||
"size": 98124,
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
{
|
||||
"name": "abl",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/abl-29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/abl-29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35.img.xz",
|
||||
"hash": "29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35",
|
||||
"hash_raw": "29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35",
|
||||
"size": 274432,
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
{
|
||||
"name": "aop",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/aop-78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/aop-78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1.img.xz",
|
||||
"hash": "78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1",
|
||||
"hash_raw": "78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1",
|
||||
"size": 184364,
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
{
|
||||
"name": "devcfg",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/devcfg-f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/devcfg-f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc.img.xz",
|
||||
"hash": "f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc",
|
||||
"hash_raw": "f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc",
|
||||
"size": 40336,
|
||||
@@ -56,28 +56,28 @@
|
||||
},
|
||||
{
|
||||
"name": "boot",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/boot-2388598cda7c5c09a44b8f2683ff473d7ce8096a545a1c4ea2ff1cff65456c5a.img.xz",
|
||||
"hash": "2388598cda7c5c09a44b8f2683ff473d7ce8096a545a1c4ea2ff1cff65456c5a",
|
||||
"hash_raw": "2388598cda7c5c09a44b8f2683ff473d7ce8096a545a1c4ea2ff1cff65456c5a",
|
||||
"size": 46897152,
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/boot-7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4.img.xz",
|
||||
"hash": "7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4",
|
||||
"hash_raw": "7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4",
|
||||
"size": 47855616,
|
||||
"sparse": false,
|
||||
"full_check": true,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "3519123cc1ec417e56ed2bdd449094e6e6e38ecb610ea4452dd44d5bdce5604c"
|
||||
"ondevice_hash": "f456444afa8d821c5e482240af5bcfb717d8c840d16dd98100941e5f665eefa1"
|
||||
},
|
||||
{
|
||||
"name": "system",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e.img.xz",
|
||||
"hash": "6042848e01cd245df7570fc96cff28c831b4d3713e4321ee38735cb4e4591593",
|
||||
"hash_raw": "ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a.img.xz",
|
||||
"hash": "bd3c6cc917f8fdd74c1248324fa1518b091a8e810d1466c5e8fea9cf1e23f6d0",
|
||||
"hash_raw": "cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a",
|
||||
"size": 2147483648,
|
||||
"sparse": true,
|
||||
"full_check": false,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "b2fc71b9071ddb0664a7e3a837df8d57ee36a2befabd8f044eb8be8d73ee66b7",
|
||||
"ondevice_hash": "71814ad7b2ab4344790f660d463a1dc12142a8cf6a31dfabf4c43bd8545f152d",
|
||||
"alt": {
|
||||
"hash": "ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e.img",
|
||||
"hash": "cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a.img",
|
||||
"size": 2147483648
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"name": "gpt_main_0",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_0-8928a31fd9ee20f8703649f89833eba9b55e84b6415e67799c777b163c95a0bd.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_0-8928a31fd9ee20f8703649f89833eba9b55e84b6415e67799c777b163c95a0bd.img.xz",
|
||||
"hash": "8928a31fd9ee20f8703649f89833eba9b55e84b6415e67799c777b163c95a0bd",
|
||||
"hash_raw": "8928a31fd9ee20f8703649f89833eba9b55e84b6415e67799c777b163c95a0bd",
|
||||
"size": 24576,
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gpt_main_1",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_1-fe8ef7653db588d7420a625920ca06927dfcb0ed8aff3e3a1c74a52a24398ba6.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_1-fe8ef7653db588d7420a625920ca06927dfcb0ed8aff3e3a1c74a52a24398ba6.img.xz",
|
||||
"hash": "fe8ef7653db588d7420a625920ca06927dfcb0ed8aff3e3a1c74a52a24398ba6",
|
||||
"hash_raw": "fe8ef7653db588d7420a625920ca06927dfcb0ed8aff3e3a1c74a52a24398ba6",
|
||||
"size": 24576,
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gpt_main_2",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_2-5ccfc7240c8cbfa2f1a018a2e376cf274a6baf858c9bfe71951d8e28cab53c21.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_2-5ccfc7240c8cbfa2f1a018a2e376cf274a6baf858c9bfe71951d8e28cab53c21.img.xz",
|
||||
"hash": "5ccfc7240c8cbfa2f1a018a2e376cf274a6baf858c9bfe71951d8e28cab53c21",
|
||||
"hash_raw": "5ccfc7240c8cbfa2f1a018a2e376cf274a6baf858c9bfe71951d8e28cab53c21",
|
||||
"size": 24576,
|
||||
@@ -49,7 +49,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gpt_main_3",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_3-c707979fa21e89519328f4f30c2b21c9c453401ca8303f914c1873d410a95159.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_3-c707979fa21e89519328f4f30c2b21c9c453401ca8303f914c1873d410a95159.img.xz",
|
||||
"hash": "c707979fa21e89519328f4f30c2b21c9c453401ca8303f914c1873d410a95159",
|
||||
"hash_raw": "c707979fa21e89519328f4f30c2b21c9c453401ca8303f914c1873d410a95159",
|
||||
"size": 24576,
|
||||
@@ -65,7 +65,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gpt_main_4",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_4-e9405dcd785dbe79412184e1894a9c51ab7deb33bb612166c4c42a3d2bf42a0e.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_4-e9405dcd785dbe79412184e1894a9c51ab7deb33bb612166c4c42a3d2bf42a0e.img.xz",
|
||||
"hash": "e9405dcd785dbe79412184e1894a9c51ab7deb33bb612166c4c42a3d2bf42a0e",
|
||||
"hash_raw": "e9405dcd785dbe79412184e1894a9c51ab7deb33bb612166c4c42a3d2bf42a0e",
|
||||
"size": 24576,
|
||||
@@ -81,7 +81,7 @@
|
||||
},
|
||||
{
|
||||
"name": "gpt_main_5",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/gpt_main_5-21ae965f05b2fa8d02e04f1eb74718f9779864f6eacdeb859757d6435e8ccce3.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/gpt_main_5-21ae965f05b2fa8d02e04f1eb74718f9779864f6eacdeb859757d6435e8ccce3.img.xz",
|
||||
"hash": "21ae965f05b2fa8d02e04f1eb74718f9779864f6eacdeb859757d6435e8ccce3",
|
||||
"hash_raw": "21ae965f05b2fa8d02e04f1eb74718f9779864f6eacdeb859757d6435e8ccce3",
|
||||
"size": 24576,
|
||||
@@ -97,7 +97,7 @@
|
||||
},
|
||||
{
|
||||
"name": "persist",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/persist-d6af4ec18df180c7417353b52a9e05e43a6480b29425f087874136436cefe786.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/persist-d6af4ec18df180c7417353b52a9e05e43a6480b29425f087874136436cefe786.img.xz",
|
||||
"hash": "d6af4ec18df180c7417353b52a9e05e43a6480b29425f087874136436cefe786",
|
||||
"hash_raw": "d6af4ec18df180c7417353b52a9e05e43a6480b29425f087874136436cefe786",
|
||||
"size": 4096,
|
||||
@@ -108,7 +108,7 @@
|
||||
},
|
||||
{
|
||||
"name": "systemrw",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/systemrw-8ce150ca38ef64a0885fc2fe816e5b63bae8adb4df5d809c5b318e6996366c7e.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/systemrw-8ce150ca38ef64a0885fc2fe816e5b63bae8adb4df5d809c5b318e6996366c7e.img.xz",
|
||||
"hash": "8ce150ca38ef64a0885fc2fe816e5b63bae8adb4df5d809c5b318e6996366c7e",
|
||||
"hash_raw": "8ce150ca38ef64a0885fc2fe816e5b63bae8adb4df5d809c5b318e6996366c7e",
|
||||
"size": 16777216,
|
||||
@@ -119,7 +119,7 @@
|
||||
},
|
||||
{
|
||||
"name": "cache",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/cache-ebfbaaa2f96dc4e5fea4f126364e5bf5b3b44c12cbc753b62fdd8baab82f70b4.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/cache-ebfbaaa2f96dc4e5fea4f126364e5bf5b3b44c12cbc753b62fdd8baab82f70b4.img.xz",
|
||||
"hash": "ebfbaaa2f96dc4e5fea4f126364e5bf5b3b44c12cbc753b62fdd8baab82f70b4",
|
||||
"hash_raw": "ebfbaaa2f96dc4e5fea4f126364e5bf5b3b44c12cbc753b62fdd8baab82f70b4",
|
||||
"size": 134217728,
|
||||
@@ -130,7 +130,7 @@
|
||||
},
|
||||
{
|
||||
"name": "xbl",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/xbl-e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/xbl-e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb.img.xz",
|
||||
"hash": "e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb",
|
||||
"hash_raw": "e8acf2a9cc7f0ce84cb803bfea9477f765c0d7b4daf26048e59651b9e6a7bfbb",
|
||||
"size": 3282256,
|
||||
@@ -141,7 +141,7 @@
|
||||
},
|
||||
{
|
||||
"name": "xbl_config",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/xbl_config-758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/xbl_config-758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85.img.xz",
|
||||
"hash": "758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85",
|
||||
"hash_raw": "758552ecf92b5569677197783bf0ccb73d7f961685308e45d3276ac9dd974f85",
|
||||
"size": 98124,
|
||||
@@ -152,18 +152,18 @@
|
||||
},
|
||||
{
|
||||
"name": "abl",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/abl-b6fba807b9bcd66a31f2afb0eba5163ec239693ad32e2e4200f6c356adfe098c.img.xz",
|
||||
"hash": "b6fba807b9bcd66a31f2afb0eba5163ec239693ad32e2e4200f6c356adfe098c",
|
||||
"hash_raw": "b6fba807b9bcd66a31f2afb0eba5163ec239693ad32e2e4200f6c356adfe098c",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/abl-29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35.img.xz",
|
||||
"hash": "29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35",
|
||||
"hash_raw": "29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35",
|
||||
"size": 274432,
|
||||
"sparse": false,
|
||||
"full_check": true,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "b6fba807b9bcd66a31f2afb0eba5163ec239693ad32e2e4200f6c356adfe098c"
|
||||
"ondevice_hash": "29fd7ed1c012e599420764840f9f11286d34dbff4adaf102a447f06d8c5e0b35"
|
||||
},
|
||||
{
|
||||
"name": "aop",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/aop-78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/aop-78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1.img.xz",
|
||||
"hash": "78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1",
|
||||
"hash_raw": "78b2287ca219a0811b3004c523fa0f4749e4d1fd92be3aba61699305b7943ad1",
|
||||
"size": 184364,
|
||||
@@ -174,7 +174,7 @@
|
||||
},
|
||||
{
|
||||
"name": "bluetooth",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/bluetooth-9bb766d2d2ce0cc4491664b3010fe1ef62f8ffc1e362d55f78e48c4141f75533.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/bluetooth-9bb766d2d2ce0cc4491664b3010fe1ef62f8ffc1e362d55f78e48c4141f75533.img.xz",
|
||||
"hash": "9bb766d2d2ce0cc4491664b3010fe1ef62f8ffc1e362d55f78e48c4141f75533",
|
||||
"hash_raw": "9bb766d2d2ce0cc4491664b3010fe1ef62f8ffc1e362d55f78e48c4141f75533",
|
||||
"size": 1048576,
|
||||
@@ -185,7 +185,7 @@
|
||||
},
|
||||
{
|
||||
"name": "cmnlib64",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/cmnlib64-1a876bd151bb9635f18719c4a17f953079de6e11d3eaec800968fc75669e0dc3.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/cmnlib64-1a876bd151bb9635f18719c4a17f953079de6e11d3eaec800968fc75669e0dc3.img.xz",
|
||||
"hash": "1a876bd151bb9635f18719c4a17f953079de6e11d3eaec800968fc75669e0dc3",
|
||||
"hash_raw": "1a876bd151bb9635f18719c4a17f953079de6e11d3eaec800968fc75669e0dc3",
|
||||
"size": 524288,
|
||||
@@ -196,7 +196,7 @@
|
||||
},
|
||||
{
|
||||
"name": "cmnlib",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/cmnlib-63df823e8a5fae01d66cb2b8c20f0d2ddb5c5f2425e5d0992a64676273ba1c82.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/cmnlib-63df823e8a5fae01d66cb2b8c20f0d2ddb5c5f2425e5d0992a64676273ba1c82.img.xz",
|
||||
"hash": "63df823e8a5fae01d66cb2b8c20f0d2ddb5c5f2425e5d0992a64676273ba1c82",
|
||||
"hash_raw": "63df823e8a5fae01d66cb2b8c20f0d2ddb5c5f2425e5d0992a64676273ba1c82",
|
||||
"size": 524288,
|
||||
@@ -207,7 +207,7 @@
|
||||
},
|
||||
{
|
||||
"name": "devcfg",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/devcfg-f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/devcfg-f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc.img.xz",
|
||||
"hash": "f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc",
|
||||
"hash_raw": "f71df3a86958c093ba3969254c4db025187eef9385427f1ade946742939b43cc",
|
||||
"size": 40336,
|
||||
@@ -218,7 +218,7 @@
|
||||
},
|
||||
{
|
||||
"name": "devinfo",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/devinfo-143869c499a7e878fbeab756e9c53074195770cc41d6d0d10e45c043141389a3.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/devinfo-143869c499a7e878fbeab756e9c53074195770cc41d6d0d10e45c043141389a3.img.xz",
|
||||
"hash": "143869c499a7e878fbeab756e9c53074195770cc41d6d0d10e45c043141389a3",
|
||||
"hash_raw": "143869c499a7e878fbeab756e9c53074195770cc41d6d0d10e45c043141389a3",
|
||||
"size": 4096,
|
||||
@@ -229,7 +229,7 @@
|
||||
},
|
||||
{
|
||||
"name": "dsp",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/dsp-4b15fbd2f45581f1553f33f01649e450b24aa19d5deff2ac7dcb16a534d9c248.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/dsp-4b15fbd2f45581f1553f33f01649e450b24aa19d5deff2ac7dcb16a534d9c248.img.xz",
|
||||
"hash": "4b15fbd2f45581f1553f33f01649e450b24aa19d5deff2ac7dcb16a534d9c248",
|
||||
"hash_raw": "4b15fbd2f45581f1553f33f01649e450b24aa19d5deff2ac7dcb16a534d9c248",
|
||||
"size": 33554432,
|
||||
@@ -240,7 +240,7 @@
|
||||
},
|
||||
{
|
||||
"name": "hyp",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/hyp-ff5ece6a4e3d2b4d898c77ffe193fc8bbc8acebe78263996ecf52373d8088927.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/hyp-ff5ece6a4e3d2b4d898c77ffe193fc8bbc8acebe78263996ecf52373d8088927.img.xz",
|
||||
"hash": "ff5ece6a4e3d2b4d898c77ffe193fc8bbc8acebe78263996ecf52373d8088927",
|
||||
"hash_raw": "ff5ece6a4e3d2b4d898c77ffe193fc8bbc8acebe78263996ecf52373d8088927",
|
||||
"size": 524288,
|
||||
@@ -251,7 +251,7 @@
|
||||
},
|
||||
{
|
||||
"name": "keymaster",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/keymaster-5c968c76f29b9a4d66fbe57e639bac6b7a2c83b1758e25abbaf5d276b8a6af04.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/keymaster-5c968c76f29b9a4d66fbe57e639bac6b7a2c83b1758e25abbaf5d276b8a6af04.img.xz",
|
||||
"hash": "5c968c76f29b9a4d66fbe57e639bac6b7a2c83b1758e25abbaf5d276b8a6af04",
|
||||
"hash_raw": "5c968c76f29b9a4d66fbe57e639bac6b7a2c83b1758e25abbaf5d276b8a6af04",
|
||||
"size": 524288,
|
||||
@@ -262,7 +262,7 @@
|
||||
},
|
||||
{
|
||||
"name": "limits",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/limits-94951a0f7aa55fb6cb975535ce4ebbfe6d695f04cb5424677b01c10dfa2e94e1.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/limits-94951a0f7aa55fb6cb975535ce4ebbfe6d695f04cb5424677b01c10dfa2e94e1.img.xz",
|
||||
"hash": "94951a0f7aa55fb6cb975535ce4ebbfe6d695f04cb5424677b01c10dfa2e94e1",
|
||||
"hash_raw": "94951a0f7aa55fb6cb975535ce4ebbfe6d695f04cb5424677b01c10dfa2e94e1",
|
||||
"size": 4096,
|
||||
@@ -273,7 +273,7 @@
|
||||
},
|
||||
{
|
||||
"name": "logfs",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/logfs-b8b5ac87f3d954404fc7ecbdd9ee3b5b0cf5691e5006e6ec55db4c899ff61220.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/logfs-b8b5ac87f3d954404fc7ecbdd9ee3b5b0cf5691e5006e6ec55db4c899ff61220.img.xz",
|
||||
"hash": "b8b5ac87f3d954404fc7ecbdd9ee3b5b0cf5691e5006e6ec55db4c899ff61220",
|
||||
"hash_raw": "b8b5ac87f3d954404fc7ecbdd9ee3b5b0cf5691e5006e6ec55db4c899ff61220",
|
||||
"size": 8388608,
|
||||
@@ -284,7 +284,7 @@
|
||||
},
|
||||
{
|
||||
"name": "modem",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/modem-a3d014f0896d77a2df7e5a80a70f43a51a047b9d03cfc675b6f0e31a6ecc4994.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/modem-a3d014f0896d77a2df7e5a80a70f43a51a047b9d03cfc675b6f0e31a6ecc4994.img.xz",
|
||||
"hash": "a3d014f0896d77a2df7e5a80a70f43a51a047b9d03cfc675b6f0e31a6ecc4994",
|
||||
"hash_raw": "a3d014f0896d77a2df7e5a80a70f43a51a047b9d03cfc675b6f0e31a6ecc4994",
|
||||
"size": 125829120,
|
||||
@@ -295,7 +295,7 @@
|
||||
},
|
||||
{
|
||||
"name": "qupfw",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/qupfw-64cc7c29d5d69b04267452b8b4ddba9f4809e68f476fc162ca283f58537afe4a.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/qupfw-64cc7c29d5d69b04267452b8b4ddba9f4809e68f476fc162ca283f58537afe4a.img.xz",
|
||||
"hash": "64cc7c29d5d69b04267452b8b4ddba9f4809e68f476fc162ca283f58537afe4a",
|
||||
"hash_raw": "64cc7c29d5d69b04267452b8b4ddba9f4809e68f476fc162ca283f58537afe4a",
|
||||
"size": 65536,
|
||||
@@ -306,7 +306,7 @@
|
||||
},
|
||||
{
|
||||
"name": "splash",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/splash-5c61260048f22ede6e6343fabb27f6ff73f9271f4751a01aaf7abf097afc1f08.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/splash-5c61260048f22ede6e6343fabb27f6ff73f9271f4751a01aaf7abf097afc1f08.img.xz",
|
||||
"hash": "5c61260048f22ede6e6343fabb27f6ff73f9271f4751a01aaf7abf097afc1f08",
|
||||
"hash_raw": "5c61260048f22ede6e6343fabb27f6ff73f9271f4751a01aaf7abf097afc1f08",
|
||||
"size": 34226176,
|
||||
@@ -317,7 +317,7 @@
|
||||
},
|
||||
{
|
||||
"name": "storsec",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/storsec-4494d86f68b125fbf2c004c824b1c6dbe71e61a65d2a1cc7db13c553edcb3fce.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/storsec-4494d86f68b125fbf2c004c824b1c6dbe71e61a65d2a1cc7db13c553edcb3fce.img.xz",
|
||||
"hash": "4494d86f68b125fbf2c004c824b1c6dbe71e61a65d2a1cc7db13c553edcb3fce",
|
||||
"hash_raw": "4494d86f68b125fbf2c004c824b1c6dbe71e61a65d2a1cc7db13c553edcb3fce",
|
||||
"size": 131072,
|
||||
@@ -328,7 +328,7 @@
|
||||
},
|
||||
{
|
||||
"name": "tz",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/tz-e9443bf187641661bfa6c96702b9ab0156e72fb7482500f8799ba9ee2503cb16.img.xz",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/tz-e9443bf187641661bfa6c96702b9ab0156e72fb7482500f8799ba9ee2503cb16.img.xz",
|
||||
"hash": "e9443bf187641661bfa6c96702b9ab0156e72fb7482500f8799ba9ee2503cb16",
|
||||
"hash_raw": "e9443bf187641661bfa6c96702b9ab0156e72fb7482500f8799ba9ee2503cb16",
|
||||
"size": 2097152,
|
||||
@@ -339,51 +339,29 @@
|
||||
},
|
||||
{
|
||||
"name": "boot",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/boot-5463317ca7a231f2ddd55a667a8c2b0d6692982359773ca875a99a0e6fd67fb4.img.xz",
|
||||
"hash": "5463317ca7a231f2ddd55a667a8c2b0d6692982359773ca875a99a0e6fd67fb4",
|
||||
"hash_raw": "5463317ca7a231f2ddd55a667a8c2b0d6692982359773ca875a99a0e6fd67fb4",
|
||||
"size": 46897152,
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/boot-7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4.img.xz",
|
||||
"hash": "7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4",
|
||||
"hash_raw": "7da6f3e3defcc90c599d6a941df0240555d687d0d0c9df83a3e186b83424a0e4",
|
||||
"size": 47855616,
|
||||
"sparse": false,
|
||||
"full_check": true,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "daefa6f897bdcc277e50dbf562fd63e57d50d9fc7a599f2d171208a490e725d9"
|
||||
"ondevice_hash": "f456444afa8d821c5e482240af5bcfb717d8c840d16dd98100941e5f665eefa1"
|
||||
},
|
||||
{
|
||||
"name": "system",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d.img.xz",
|
||||
"hash": "14ab660bb955604ab6c482b3f59e5239e2c40c54e798201afcaed43d5cb0dcfd",
|
||||
"hash_raw": "2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d",
|
||||
"size": 4718592000,
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a.img.xz",
|
||||
"hash": "bd3c6cc917f8fdd74c1248324fa1518b091a8e810d1466c5e8fea9cf1e23f6d0",
|
||||
"hash_raw": "cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a",
|
||||
"size": 2147483648,
|
||||
"sparse": true,
|
||||
"full_check": false,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "18666ca3b529304f5e7a8fc2e3c9dce715b55941e3965a7af43c613f8e18cfce",
|
||||
"ondevice_hash": "71814ad7b2ab4344790f660d463a1dc12142a8cf6a31dfabf4c43bd8545f152d",
|
||||
"alt": {
|
||||
"hash": "2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d.img",
|
||||
"size": 4718592000
|
||||
"hash": "cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-cb1d8ac3c8c8917e584d4a37a78e80dfb614ceed626fdd91f8125ee54baeb97a.img",
|
||||
"size": 2147483648
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "userdata_90",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/userdata_90-871adca25cb254ad1704ce427f3faaae1027f74aff43a3e150188c8a1c3d3cb8.img.xz",
|
||||
"hash": "e4f59e5dcf4758759da9284479163e420febf1c118bf33c83b402e80e241608d",
|
||||
"hash_raw": "871adca25cb254ad1704ce427f3faaae1027f74aff43a3e150188c8a1c3d3cb8",
|
||||
"size": 96636764160,
|
||||
"sparse": true,
|
||||
"full_check": true,
|
||||
"has_ab": false,
|
||||
"ondevice_hash": "17b4ec7449e62c52be5df551542684b953e5c7ffc95103008043602f79ae7112"
|
||||
},
|
||||
{
|
||||
"name": "userdata_89",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/userdata_89-9d84bd64ef237a32675f936594c16932f8acbb52cf2dd82373a0e718cd32dfcf.img.xz",
|
||||
"hash": "652e61ecb5b12250dbfeb9f12fd74af16b867b5ea9bf8a08b5731ffd63a76317",
|
||||
"hash_raw": "9d84bd64ef237a32675f936594c16932f8acbb52cf2dd82373a0e718cd32dfcf",
|
||||
"size": 95563022336,
|
||||
"sparse": true,
|
||||
"full_check": true,
|
||||
"has_ab": false,
|
||||
"ondevice_hash": "acad63821bb48823c871910b1a363ab924d2635a7574cc5045e877c438d3012f"
|
||||
}
|
||||
]
|
||||
@@ -1,5 +1,4 @@
|
||||
import configparser
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
@@ -29,25 +28,9 @@ def affine_irq(val, action):
|
||||
print(f"No IRQs found for '{action}'")
|
||||
return
|
||||
|
||||
# power save takes the big cores offline; their IRQs stay where the kernel moved them until the cores come back
|
||||
# and the IRQs are affined again
|
||||
online = Path(f"/sys/devices/system/cpu/cpu{val}/online")
|
||||
if online.exists() and online.read_text().strip() == "0":
|
||||
return
|
||||
|
||||
for i in irqs:
|
||||
sudo_write(str(val), f"/proc/irq/{i}/smp_affinity_list")
|
||||
|
||||
_hwmon: dict[str, tuple[Path | None, float]] = {}
|
||||
def hwmon(name: str) -> Path | None:
|
||||
"""the hwmon device with this name, hwmon numbering depends on probe order. None until its driver has probed, or on
|
||||
devices without it (the comma four has no INA231): the scan costs ~3 ms, so a miss is only scanned again after 10 s"""
|
||||
path, scanned = _hwmon.get(name, (None, -10.))
|
||||
if path is None and time.monotonic() - scanned >= 10.:
|
||||
path = next((Path(p).parent for p in sorted(glob.glob("/sys/class/hwmon/hwmon*/name")) if Path(p).read_text().strip() == name), None)
|
||||
_hwmon[name] = (path, time.monotonic())
|
||||
return path
|
||||
|
||||
@lru_cache
|
||||
def get_device_type():
|
||||
# lru_cache and cache can cause memory leaks when used in classes
|
||||
@@ -118,11 +101,11 @@ class HardwareComma(HardwareBase):
|
||||
return self.get_cmdline()['androidboot.serialno']
|
||||
|
||||
def get_voltage(self):
|
||||
with open(f"{hwmon('ina231')}/in1_input") as f:
|
||||
with open("/sys/class/hwmon/hwmon1/in1_input") as f:
|
||||
return int(f.read())
|
||||
|
||||
def get_current(self):
|
||||
with open(f"{hwmon('ina231')}/curr1_input") as f:
|
||||
with open("/sys/class/hwmon/hwmon1/curr1_input") as f:
|
||||
return int(f.read())
|
||||
|
||||
def set_ir_power(self, percent: int):
|
||||
@@ -265,7 +248,7 @@ class HardwareComma(HardwareBase):
|
||||
return self.get_modem_state().get('temperatures', [])
|
||||
|
||||
def get_current_power_draw(self):
|
||||
return (self.read_param_file(f"{hwmon('ina231')}/power1_input", int) / 1e6)
|
||||
return (self.read_param_file("/sys/class/hwmon/hwmon1/power1_input", int) / 1e6)
|
||||
|
||||
def get_som_power_draw(self):
|
||||
return (self.read_param_file("/sys/class/power_supply/bms/voltage_now", int) * self.read_param_file("/sys/class/power_supply/bms/current_now", int) / 1e12)
|
||||
|
||||
@@ -7,11 +7,10 @@ from collections import deque
|
||||
|
||||
from openpilot.common.realtime import Ratekeeper
|
||||
from openpilot.common.filter_simple import FirstOrderFilter
|
||||
from openpilot.common.hardware.comma.hardware import hwmon
|
||||
|
||||
|
||||
def read_power():
|
||||
with open(f"{hwmon('ina231')}/power1_input") as f:
|
||||
with open("/sys/bus/i2c/devices/0-0040/hwmon/hwmon1/power1_input") as f:
|
||||
return int(f.read()) / 1e6
|
||||
|
||||
def sample_power(seconds=5) -> list[float]:
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestAmplifier(OpenpilotTestCase):
|
||||
|
||||
def _check_for_i2c_errors(self, expected):
|
||||
dmesg = subprocess.check_output("dmesg", shell=True, encoding='utf8')
|
||||
i2c_lines = [l for l in dmesg.strip().splitlines() if 'a88000.i2c' in l]
|
||||
i2c_lines = [l for l in dmesg.strip().splitlines() if 'i2c_geni a88000.i2c' in l]
|
||||
i2c_str = '\n'.join(i2c_lines)
|
||||
|
||||
if not expected:
|
||||
|
||||
@@ -149,12 +149,15 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"Version", {PERSISTENT, STRING}},
|
||||
|
||||
// --- sunnypilot params --- //
|
||||
{"AccelBoostSP", {PERSISTENT | BACKUP, BOOL, "1"}},
|
||||
{"ApiCache_DriveStats", {PERSISTENT, JSON}},
|
||||
{"AutoLaneChangeBsmDelay", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"AutoLaneChangeTimer", {PERSISTENT | BACKUP, INT, "0"}},
|
||||
{"BlinkerLateralReengageDelay", {PERSISTENT | BACKUP, INT, "0"}}, // seconds
|
||||
{"BlinkerMinLateralControlSpeed", {PERSISTENT | BACKUP, INT, "20"}}, // MPH or km/h
|
||||
{"BlinkerPauseLateralControl", {PERSISTENT | BACKUP, INT, "0"}},
|
||||
{"BluetoothAllowed", {PERSISTENT, BOOL, "1"}},
|
||||
{"BluetoothEnabled", {CLEAR_ON_MANAGER_START, BOOL, "0"}},
|
||||
{"Brightness", {PERSISTENT | BACKUP, INT, "0"}},
|
||||
{"CarList", {PERSISTENT, JSON}},
|
||||
{"CarParamsSP", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BYTES}},
|
||||
@@ -198,6 +201,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"ShowAdvancedControls", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"ShowTurnSignals", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"TripSummary", {PERSISTENT | BACKUP, BOOL, "1"}},
|
||||
{"TrueVEgoUI", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
|
||||
// MADS params
|
||||
@@ -231,6 +235,11 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"SunnylinkDongleId", {PERSISTENT, STRING}},
|
||||
{"SunnylinkdPid", {PERSISTENT, INT}},
|
||||
{"SunnylinkEnabled", {PERSISTENT, BOOL, "1"}},
|
||||
{"SunnylinkLocalConnectPhoneRequest", {CLEAR_ON_MANAGER_START | DONT_LOG, JSON}},
|
||||
{"SunnylinkLocalConnectPhoneWindow", {CLEAR_ON_MANAGER_START | DONT_LOG, JSON}},
|
||||
{"SunnylinkLocalBleGrants", {PERSISTENT | DONT_LOG, JSON}},
|
||||
{"SunnylinkLocalBleKey", {PERSISTENT | DONT_LOG, BYTES}},
|
||||
{"SunnylinkLocalBluetoothStatus", {CLEAR_ON_MANAGER_START | DONT_LOG, JSON}},
|
||||
{"SunnylinkTempFault", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL, "0"}},
|
||||
|
||||
// Backup Manager params
|
||||
@@ -243,6 +252,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
||||
{"SubaruStopAndGoManualParkingBrake", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"TeslaCoopSteering", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"TeslaMadsScreenButton", {PERSISTENT | BACKUP, INT, "0"}},
|
||||
{"ToyotaEnhancedBsm", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"ToyotaEnforceStockLongitudinal", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"ToyotaStopAndGoHack", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"ToyotaTSS2Smooth", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
|
||||
@@ -17,7 +17,7 @@ class Spinner:
|
||||
return self
|
||||
|
||||
def update(self, spinner_text: str):
|
||||
if self.spinner_proc is not None and self.spinner_proc.stdin is not None:
|
||||
if self.spinner_proc is not None:
|
||||
self.spinner_proc.stdin.write(spinner_text.encode('utf8') + b"\n")
|
||||
try:
|
||||
self.spinner_proc.stdin.flush()
|
||||
|
||||
@@ -49,7 +49,7 @@ class SwaglogRotatingFileHandler(BaseRotatingHandler):
|
||||
return sorted(log_files, reverse=True)
|
||||
|
||||
def shouldRollover(self, record):
|
||||
size_exceeded = self.max_bytes > 0 and self.stream is not None and self.stream.tell() >= self.max_bytes
|
||||
size_exceeded = self.max_bytes > 0 and self.stream.tell() >= self.max_bytes
|
||||
time_exceeded = self.interval > 0 and self.last_rollover + self.interval <= time.monotonic()
|
||||
return size_exceeded or time_exceeded
|
||||
|
||||
@@ -91,7 +91,6 @@ class UnixDomainSocketHandler(logging.Handler):
|
||||
self.connect()
|
||||
|
||||
msg = self.format(record).rstrip('\n')
|
||||
assert self.sock is not None
|
||||
try:
|
||||
self.sock.sendto((chr(record.levelno)+msg).encode('utf8'), Paths.swaglog_ipc())
|
||||
except OSError:
|
||||
|
||||
@@ -4,7 +4,6 @@ import inspect
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
from collections.abc import Callable
|
||||
from unittest import mock
|
||||
|
||||
from openpilot.common.hardware import HARDWARE, COMMA_HARDWARE
|
||||
@@ -27,7 +26,6 @@ class OpenpilotTestCase(unittest.TestCase):
|
||||
|
||||
COMMA_HARDWARE_TEST = False
|
||||
SHARED_DOWNLOAD_CACHE = False
|
||||
openpilot_setup_method: Callable[[], None] # a subclass's setup_method, moved here by __init_subclass__
|
||||
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__(**kwargs)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import numpy as np
|
||||
from scipy.io import wavfile
|
||||
|
||||
|
||||
sr = 48000
|
||||
max_int16 = 2**15 - 1
|
||||
|
||||
def harmonic_beep(freq, duration_seconds):
|
||||
n_total = int(sr * duration_seconds)
|
||||
|
||||
signal = np.sin(2 * np.pi * freq * np.arange(n_total) / sr)
|
||||
x = np.arange(n_total)
|
||||
exp_scale = np.exp(-x/5.5e3)
|
||||
return max_int16 * signal * exp_scale
|
||||
|
||||
engage_beep = harmonic_beep(1661.219, 0.5)
|
||||
wavfile.write("engage.wav", sr, engage_beep.astype(np.int16))
|
||||
disengage_beep = harmonic_beep(1318.51, 0.5)
|
||||
wavfile.write("disengage.wav", sr, disengage_beep.astype(np.int16))
|
||||
@@ -119,7 +119,6 @@ class Car:
|
||||
# continue onto next fingerprinting step in pandad
|
||||
self.params.put_bool("FirmwareQueryDone", True, block=True)
|
||||
else:
|
||||
assert RI is not None
|
||||
self.CI, self.CP, self.CP_SP = CI, CI.CP, CI.CP_SP
|
||||
self.RI = RI
|
||||
|
||||
|
||||
@@ -35,9 +35,6 @@ def run_cruise_simulation(cruise, personality, t_end=20.):
|
||||
log.LongitudinalPersonality.schema.enumerants, # personality
|
||||
[5,35])) # speed
|
||||
class TestCruiseSpeed(OpenpilotTestCase):
|
||||
personality: str
|
||||
speed: int
|
||||
|
||||
def test_cruise_speed(self):
|
||||
print(f'Testing {self.speed} m/s')
|
||||
cruise_speed = float(self.speed)
|
||||
@@ -49,9 +46,6 @@ class TestCruiseSpeed(OpenpilotTestCase):
|
||||
# TODO: test pcmCruise and pcmCruiseSpeed
|
||||
@parameterized_class(('pcm_cruise', 'pcm_cruise_speed'), [(False, True)])
|
||||
class TestVCruiseHelper(OpenpilotTestCase):
|
||||
pcm_cruise: bool
|
||||
pcm_cruise_speed: bool
|
||||
|
||||
def setup_method(self):
|
||||
self.CP = car.CarParams(pcmCruise=self.pcm_cruise)
|
||||
self.CP_SP = custom.CarParamsSP(pcmCruiseSpeed=self.pcm_cruise_speed)
|
||||
|
||||
@@ -18,7 +18,6 @@ from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle, STEER_ANGLE_SATURATION_THRESHOLD
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_curvature import LatControlCurvature
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
|
||||
from openpilot.sunnypilot.selfdrive.controls.lib.latcontrol_torque_v0 import LatControlTorque as LatControlTorqueV0
|
||||
from openpilot.selfdrive.controls.lib.longcontrol import LongControl
|
||||
from openpilot.selfdrive.modeld.modeld import LAT_SMOOTH_SECONDS
|
||||
from openpilot.selfdrive.locationd.helpers import PoseCalibrator, Pose
|
||||
@@ -92,7 +91,7 @@ class Controls(ControlsExt):
|
||||
self.curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo, lp.roll)
|
||||
|
||||
# Update Torque Params
|
||||
if isinstance(self.LaC, (LatControlTorque, LatControlTorqueV0)):
|
||||
if self.CP.lateralTuning.which() == 'torque':
|
||||
torque_params = self.sm['lateralTorqueParameters']
|
||||
if self.sm.all_checks(['lateralTorqueParameters']) and torque_params.useParams:
|
||||
self.LaC.update_torque_parameters(torque_params.latAccelFactorFiltered, torque_params.latAccelOffsetFiltered,
|
||||
|
||||
@@ -82,7 +82,7 @@ lenv["CCFLAGS"].append("-Wno-unused")
|
||||
if arch != "Darwin":
|
||||
lenv["LINKFLAGS"].append("-Wl,--disable-new-dtags")
|
||||
else:
|
||||
lenv["LINKFLAGS"].append(f"-Wl,-install_name,@loader_path/{gen}/libacados_ocp_solver_long.dylib")
|
||||
lenv["LINKFLAGS"].append("-Wl,-install_name,@loader_path/libacados_ocp_solver_long.dylib")
|
||||
lenv["LINKFLAGS"].append(f"-Wl,-rpath,@loader_path/{acados_rel_path}")
|
||||
lib_solver = lenv.SharedLibrary(f"{gen}/acados_ocp_solver_long",
|
||||
build_files,
|
||||
@@ -96,7 +96,7 @@ libacados_ocp_solver_c = File(f'{gen}/acados_ocp_solver_pyx.c')
|
||||
|
||||
lenv2 = envCython.Clone()
|
||||
lenv2["LIBPATH"] += [lib_solver[0].dir.abspath]
|
||||
lenv2["RPATH"] += [lenv2.Literal(f'\\$$ORIGIN/{gen}')]
|
||||
lenv2["RPATH"] += [lenv2.Literal('\\$$ORIGIN')]
|
||||
lenv2.Command(libacados_ocp_solver_c,
|
||||
[acados_ocp_solver_pyx, acados_ocp_solver_common, libacados_ocp_solver_pxd],
|
||||
f'cython' + \
|
||||
@@ -104,8 +104,7 @@ lenv2.Command(libacados_ocp_solver_c,
|
||||
f' -I {libacados_ocp_solver_pxd.get_dir().get_labspath()}' + \
|
||||
f' -I {acados_ocp_solver_common.get_dir().get_labspath()}' + \
|
||||
f' {acados_ocp_solver_pyx.get_labspath()}')
|
||||
# outside of gen, next to its committed type stub
|
||||
lib_cython = lenv2.Program('acados_ocp_solver_pyx.so', [libacados_ocp_solver_c], LIBS=['acados_ocp_solver_long'])
|
||||
lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c], LIBS=['acados_ocp_solver_long'])
|
||||
lenv2.Depends(lib_cython, lib_solver)
|
||||
lenv2.Depends(lib_cython, copied_acados_libs)
|
||||
lenv2.Depends(libacados_ocp_solver_c, np_version)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# acados_template's Cython solver, compiled against c_generated_code by the SConscript
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
class AcadosOcpSolverCython:
|
||||
def __init__(self, model_name: str, nlp_solver_type: str, N: int) -> None: ...
|
||||
def solve_for_x0(self, x0_bar: np.ndarray) -> np.ndarray: ...
|
||||
def solve(self) -> int: ...
|
||||
def reset(self, reset_qp_solver_mem: int = 1) -> int: ...
|
||||
def custom_update(self, data_: np.ndarray) -> int: ...
|
||||
def set_new_time_steps(self, new_time_steps: np.ndarray) -> None: ...
|
||||
def update_qp_solver_cond_N(self, qp_solver_cond_N: int) -> None: ...
|
||||
def eval_param_sens(self, index: int, stage: int = 0, field: str = "ex") -> None: ...
|
||||
def get(self, stage: int, field_: str) -> np.ndarray: ...
|
||||
def print_statistics(self) -> None: ...
|
||||
def store_iterate(self, filename: str = '', overwrite: bool = False) -> None: ...
|
||||
def load_iterate(self, filename: str) -> None: ...
|
||||
def get_stats(self, field_: str) -> Any: ...
|
||||
def get_cost(self) -> float: ...
|
||||
def get_residuals(self, recompute: bool = False) -> np.ndarray: ...
|
||||
def set(self, stage: int, field_: str, value_: Any) -> None: ...
|
||||
def cost_set(self, stage: int, field_: str, value_: Any) -> None: ...
|
||||
def constraints_set(self, stage: int, field_: str, value_: Any) -> None: ...
|
||||
def get_from_qp_in(self, stage: int, field_: str) -> np.ndarray: ...
|
||||
def options_set(self, field_: str, value_: Any) -> None: ...
|
||||
def set_params_sparse(self, stage: int, idx_values_: np.ndarray, param_values_: np.ndarray) -> None: ...
|
||||
@@ -13,7 +13,7 @@ from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU
|
||||
if __name__ == '__main__': # generating code
|
||||
from acados.acados_template import AcadosModel, AcadosOcp, AcadosOcpSolver
|
||||
else:
|
||||
from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.acados_ocp_solver_pyx import AcadosOcpSolverCython
|
||||
from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.c_generated_code.acados_ocp_solver_pyx import AcadosOcpSolverCython
|
||||
|
||||
from casadi import SX, vertcat
|
||||
|
||||
|
||||
@@ -35,9 +35,6 @@ def run_following_distance_simulation(v_lead, t_end=100.0, personality=0):
|
||||
log.LongitudinalPersonality.aggressive],
|
||||
[0,10,35])) # speed
|
||||
class TestFollowingDistance(OpenpilotTestCase):
|
||||
personality: int
|
||||
speed: int
|
||||
|
||||
def test_following_distance(self):
|
||||
v_lead = float(self.speed)
|
||||
simulation_steady_state = run_following_distance_simulation(v_lead, personality=self.personality)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
from collections.abc import Callable, Mapping
|
||||
from typing import TYPE_CHECKING, cast
|
||||
import base64
|
||||
import ctypes
|
||||
import gc
|
||||
@@ -12,12 +11,10 @@ os.environ.setdefault('AM_PERF_LEVEL', 'high')
|
||||
from tinygrad.device import Buffer, Device
|
||||
from tinygrad.dtype import DType, dtypes
|
||||
from tinygrad.engine.jit import CapturedJit
|
||||
from tinygrad.codegen.compile import lower_and_compile
|
||||
from tinygrad.engine.realize import compile_linear, lower_and_compile
|
||||
from tinygrad.tensor import Tensor
|
||||
from tinygrad.helpers import round_up
|
||||
from tinygrad.uop.ops import UOp
|
||||
if TYPE_CHECKING:
|
||||
from tinygrad.runtime.ops_amd import AMDDevice
|
||||
import math
|
||||
import pickle
|
||||
import threading
|
||||
@@ -96,7 +93,7 @@ class ChestnutGpuState:
|
||||
|
||||
@cached_property
|
||||
def power_limit(self) -> int:
|
||||
smu = cast("AMDDevice", Device["AMD"]).iface.dev_impl.smu
|
||||
smu = Device["AMD"].iface.dev_impl.smu
|
||||
return smu._send_msg(smu.smu_mod.PPSMC_MSG_GetPptLimit, 0, read_back_arg=True, timeout=100)
|
||||
|
||||
def send(self) -> None:
|
||||
@@ -105,7 +102,7 @@ class ChestnutGpuState:
|
||||
self.sends += 1
|
||||
if self.big and "AMD" in Device._opened_devices and self.sends % 100 == 1:
|
||||
try:
|
||||
smu = cast("AMDDevice", Device["AMD"]).iface.dev_impl.smu
|
||||
smu = Device["AMD"].iface.dev_impl.smu
|
||||
metrics_t = smu.smu_mod.SmuMetricsExternal_t
|
||||
smu._send_msg(smu.smu_mod.PPSMC_MSG_TransferTableSmu2Dram, smu.smu_mod.TABLE_SMU_METRICS, timeout=100)
|
||||
metrics_buf = bytearray(smu.adev.vram.view(smu.driver_table_paddr, ctypes.sizeof(metrics_t))[:])
|
||||
@@ -147,8 +144,7 @@ def input_view(buffer: Buffer, shape: tuple[int, ...], dtype: DType, offset: int
|
||||
|
||||
|
||||
def compile_copy(tensor: Tensor) -> Callable[[], Tensor]:
|
||||
fn, externs = Tensor.export(tensor)
|
||||
jit = CapturedJit(tensor, Tensor.compile(fn), externs, [], [], {})
|
||||
jit = CapturedJit(tensor, compile_linear(tensor.schedule_linear()), [], [])
|
||||
return lambda: jit([], {})
|
||||
|
||||
|
||||
@@ -178,7 +174,7 @@ class ModelState(ModelStateBase):
|
||||
self.outputs = {name: Tensor(np.zeros(shape, dtype=dtype), device=device).realize() for name, (shape, dtype, device) in jits['output_specs'].items()}
|
||||
for name, next_name in self.state_pairs.items():
|
||||
state = self.input_queues[name]
|
||||
self.outputs[next_name] = input_view(state._buffer(), self.input_shapes[name][0], state.dtype, 0)
|
||||
self.outputs[next_name] = input_view(state._buffer(), state.shape, state.dtype, 0)
|
||||
self.copy_outputs = compile_copy(self.outputs['outputs'].to('CPU'))
|
||||
self.parser = Parser()
|
||||
|
||||
@@ -223,7 +219,7 @@ class ModelState(ModelStateBase):
|
||||
self.copy_inputs()
|
||||
self.input_queues['new_img'] = self.run_warp(**self.warp_inputs)
|
||||
self.run_model(output_buffers=self.outputs, **self.input_queues)
|
||||
if self.chestnut and (err := Device[cast(str, self.outputs['outputs'].device)].error_state.host.view(fmt='q')[0]):
|
||||
if self.chestnut and (err := Device[self.outputs['outputs'].device].error_state.host.view(fmt='q')[0]):
|
||||
raise RuntimeError(f"chestnut failed with {err}")
|
||||
if after_enqueue is not None:
|
||||
after_enqueue()
|
||||
@@ -450,7 +446,6 @@ def main(demo=False):
|
||||
params.put_bool("ChestnutActive", False)
|
||||
assert small_model is not None
|
||||
model = small_model
|
||||
assert model is not None
|
||||
if chestnut_state is not None:
|
||||
chestnut_state.big = False
|
||||
run_count = 0
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8891809d3904cdce68359235bfeea8ac853fae4758e20d08a75ccb02c035ab8d
|
||||
size 764657206
|
||||
oid sha256:e62c2ae933bd6d3e7a4b3c548a8b6b90ebf9aee7420bb9cbafbd2b2e1e9379bc
|
||||
size 764592225
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:03e239d1ab9775c3e329a181199b0f9e5b0e905c0e891c67e86722827308c879
|
||||
size 463324
|
||||
oid sha256:1c80960cddf8a463b4a0d9941a684be3acb0938da620f518844419c269173e97
|
||||
size 462613
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1e8b4e7be07b2b3040a33c0abdd9798b55514ee9bae2069c9babdec506cdd360
|
||||
size 463325
|
||||
oid sha256:657dbf7d92b7d8e554dc06fc18038c93318ab373c85af151b184c9ee4d53e1cf
|
||||
size 462615
|
||||
|
||||
@@ -102,7 +102,7 @@ class RouteEngine:
|
||||
lang = lang.replace('main_', '')
|
||||
|
||||
token = self.mapbox_token
|
||||
if self.api is not None:
|
||||
if token is None:
|
||||
token = self.api.get_token()
|
||||
|
||||
params = {
|
||||
|
||||
@@ -98,16 +98,8 @@ def route_engine(sm, pm, values):
|
||||
return RouteEngine(sm, pm, params=params)
|
||||
|
||||
|
||||
class RangeServer(ThreadingHTTPServer):
|
||||
archive: bytes
|
||||
etag: str
|
||||
ignore_range: bool
|
||||
requests: list[dict[str, str]]
|
||||
|
||||
|
||||
class RangeHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
assert isinstance(self.server, RangeServer)
|
||||
self.server.requests.append(dict(self.headers))
|
||||
if self.headers.get('If-Match', self.server.etag) != self.server.etag:
|
||||
self.send_error(412)
|
||||
@@ -116,9 +108,7 @@ class RangeHandler(BaseHTTPRequestHandler):
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
return
|
||||
m = re.fullmatch(r'bytes=(\d+)-(\d+)', self.headers['Range'])
|
||||
assert m is not None
|
||||
offset, end = map(int, m.groups())
|
||||
offset, end = map(int, re.fullmatch(r'bytes=(\d+)-(\d+)', self.headers['Range']).groups())
|
||||
data = self.server.archive[offset:end + 1]
|
||||
self.send_response(206)
|
||||
self.send_header('Content-Range', f'bytes {offset}-{end}/{len(self.server.archive)}')
|
||||
@@ -138,7 +128,7 @@ class TileServerCase(unittest.TestCase):
|
||||
self.directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.directory.cleanup)
|
||||
self.cache = Path(self.directory.name) / 'navigation' / 'tiles'
|
||||
self.server = RangeServer(('127.0.0.1', 0), RangeHandler)
|
||||
self.server = ThreadingHTTPServer(('127.0.0.1', 0), RangeHandler)
|
||||
self.server.archive = make_archive(leaf=True)
|
||||
self.server.etag = '"test-version"'
|
||||
self.server.ignore_range = False
|
||||
|
||||
@@ -132,7 +132,7 @@ def main() -> None:
|
||||
process = subprocess.Popen(["./pandad"], cwd=os.path.join(BASEDIR, "openpilot/selfdrive/pandad"))
|
||||
process.wait()
|
||||
# TODO: wrap all panda exceptions in a base panda exception
|
||||
except usb1.USBError:
|
||||
except (usb1.USBErrorNoDevice, usb1.USBErrorPipe):
|
||||
# a panda was disconnected while setting everything up. let's try again
|
||||
cloudlog.exception("Panda USB exception while setting up")
|
||||
except PandaProtocolMismatch:
|
||||
|
||||
@@ -83,13 +83,12 @@ def processes_context(processes, init_time=0, ignore_stopped=None):
|
||||
if n < len(processes) - 1:
|
||||
time.sleep(init_time)
|
||||
|
||||
procs = [managed_processes[name] for name in processes]
|
||||
assert all(p.proc is not None and p.proc.exitcode is None for p in procs)
|
||||
assert all(managed_processes[name].proc.exitcode is None for name in processes)
|
||||
|
||||
try:
|
||||
yield procs
|
||||
yield [managed_processes[name] for name in processes]
|
||||
# assert processes are still started
|
||||
assert all(p.proc is not None and p.proc.exitcode is None for p in procs if p.name not in ignore_stopped)
|
||||
assert all(managed_processes[name].proc.exitcode is None for name in processes if name not in ignore_stopped)
|
||||
finally:
|
||||
for p in processes:
|
||||
managed_processes[p].stop()
|
||||
|
||||
@@ -10,7 +10,7 @@ import argparse
|
||||
from openpilot.cereal import messaging, log
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.fingerprints import MIGRATION
|
||||
from opendbc.car.toyota.values import CAR as TOYOTA, EPS_SCALE, ToyotaSafetyFlags
|
||||
from opendbc.car.toyota.values import EPS_SCALE, ToyotaSafetyFlags
|
||||
from opendbc.car.ford.values import CAR as FORD, FordFlags, FordSafetyFlags
|
||||
from opendbc.car.hyundai.values import HyundaiSafetyFlags
|
||||
from opendbc.car.gm.values import GMSafetyFlags
|
||||
@@ -102,7 +102,8 @@ def migration(inputs: list[str], product: str|None=None):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
vars(wrapper).update(inputs=inputs, product=product)
|
||||
wrapper.inputs = inputs
|
||||
wrapper.product = product
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
@@ -309,8 +310,8 @@ def migrate_carOutput(msgs):
|
||||
def migrate_pandaStates(msgs):
|
||||
# TODO: safety param migration should be handled automatically
|
||||
safety_param_migration = {
|
||||
"TOYOTA_PRIUS": EPS_SCALE[TOYOTA.TOYOTA_PRIUS] | ToyotaSafetyFlags.STOCK_LONGITUDINAL,
|
||||
"TOYOTA_RAV4": EPS_SCALE[TOYOTA.TOYOTA_RAV4] | ToyotaSafetyFlags.ALT_BRAKE,
|
||||
"TOYOTA_PRIUS": EPS_SCALE["TOYOTA_PRIUS"] | ToyotaSafetyFlags.STOCK_LONGITUDINAL,
|
||||
"TOYOTA_RAV4": EPS_SCALE["TOYOTA_RAV4"] | ToyotaSafetyFlags.ALT_BRAKE,
|
||||
"KIA_EV6": HyundaiSafetyFlags.EV_GAS | HyundaiSafetyFlags.CANFD_LKA_STEER_MSG,
|
||||
"CHEVROLET_VOLT": GMSafetyFlags.EV,
|
||||
"CHEVROLET_BOLT_EUV": GMSafetyFlags.EV | GMSafetyFlags.HW_CAM,
|
||||
@@ -323,7 +324,7 @@ def migrate_pandaStates(msgs):
|
||||
assert CP is not None, "carParams message not found"
|
||||
fingerprint = MIGRATION.get(CP.carFingerprint, CP.carFingerprint)
|
||||
if fingerprint in safety_param_migration:
|
||||
safety_param = int(safety_param_migration[fingerprint])
|
||||
safety_param = safety_param_migration[fingerprint].value
|
||||
elif len(CP.safetyConfigs):
|
||||
safety_param = CP.safetyConfigs[0].safetyParam
|
||||
if CP.safetyConfigs[0].deprecated.safetyParam != 0:
|
||||
|
||||
@@ -19,7 +19,6 @@ from openpilot.selfdrive.test.process_replay.process_replay import get_process_c
|
||||
from openpilot.tools.lib.framereader import FrameReader
|
||||
from openpilot.tools.lib.logreader import LogReader, save_log
|
||||
from openpilot.tools.lib.github_utils import GithubUtils
|
||||
from openpilot.tools.lib.url_file import URLFile
|
||||
|
||||
TEST_ROUTE = "98395b7c5b27882e|0000002b--2686b5a2d0"
|
||||
SEGMENT = 1
|
||||
@@ -249,8 +248,7 @@ if __name__ == "__main__":
|
||||
if not update:
|
||||
log_fn = get_log_fn(TEST_ROUTE)
|
||||
try:
|
||||
# master's ref is overwritten at the same URL, so it can't come from the download cache
|
||||
all_logs = list(LogReader.from_bytes(URLFile(GITHUB.get_file_url(MODEL_REPLAY_BUCKET, log_fn), cache=False).read()))
|
||||
all_logs = list(LogReader(GITHUB.get_file_url(MODEL_REPLAY_BUCKET, log_fn)))
|
||||
cmp_log = []
|
||||
model_start_index = next(i for i, m in enumerate(all_logs) if m.which() in ("modelV2", "drivingModelData", "cameraOdometry"))
|
||||
cmp_log += all_logs[model_start_index+START_FRAME*3:model_start_index + END_FRAME*3]
|
||||
|
||||
@@ -26,7 +26,6 @@ from openpilot.common.timeout import Timeout
|
||||
from openpilot.system.camerad.cameras.nv12_info import get_nv12_info
|
||||
from openpilot.system.manager.process_config import managed_processes
|
||||
from openpilot.selfdrive.car.card import convert_to_capnp
|
||||
from openpilot.system.manager.process import NativeProcess, PythonProcess
|
||||
from openpilot.selfdrive.test.process_replay.vision_meta import meta_from_camera_state, available_streams
|
||||
from openpilot.selfdrive.test.process_replay.capture import ProcessOutputCapture
|
||||
from openpilot.tools.lib.logreader import LogIterable
|
||||
@@ -167,7 +166,6 @@ class ProcessContainer:
|
||||
return self.cfg.subs
|
||||
|
||||
def _clean_env(self):
|
||||
assert self.environ_config is not None
|
||||
for k in self.environ_config.keys():
|
||||
if k in os.environ:
|
||||
del os.environ[k]
|
||||
@@ -217,8 +215,7 @@ class ProcessContainer:
|
||||
|
||||
def _start_process(self):
|
||||
if self.capture is not None:
|
||||
assert isinstance(self.process, NativeProcess | PythonProcess)
|
||||
self.process.launcher = LauncherWithCapture(self.capture, self.process.launcher)
|
||||
self.process.launcher = LauncherWithCapture(self.capture, self.process.launcher) # ty: ignore[invalid-assignment] # intentional wrapper
|
||||
self.process.start()
|
||||
|
||||
def start(
|
||||
@@ -257,7 +254,6 @@ class ProcessContainer:
|
||||
with self.prefix:
|
||||
self.process.signal(signal.SIGKILL)
|
||||
self.process.stop()
|
||||
assert self.rc is not None
|
||||
self.rc.close_context()
|
||||
self.prefix.clean_dirs()
|
||||
self._clean_env()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import numpy as np
|
||||
|
||||
from openpilot.tools.lib.logreader import LogIterable
|
||||
|
||||
|
||||
def check_jerk_rms(inputs: LogIterable, outputs: LogIterable) -> None:
|
||||
msgs = [m for m in inputs if m.which() == 'carControl']
|
||||
msgs += [m for m in outputs if m.which() == 'longitudinalPlan']
|
||||
active = False
|
||||
prev = None
|
||||
jerks = []
|
||||
for m in sorted(msgs, key=lambda m: m.logMonoTime):
|
||||
if m.which() == 'carControl':
|
||||
active = m.carControl.longActive
|
||||
if not active:
|
||||
prev = None
|
||||
continue
|
||||
plan = m.longitudinalPlan
|
||||
if not (m.valid and active and plan.longitudinalPlanSource == 'cruise' and not plan.hasLead):
|
||||
prev = None
|
||||
continue
|
||||
if prev is not None:
|
||||
jerks.append((plan.aTarget - prev.aTarget) / ((plan.modelMonoTime - prev.modelMonoTime) / 1e9))
|
||||
prev = plan
|
||||
|
||||
if jerks:
|
||||
jerk_rms = np.sqrt(np.mean(np.square(jerks)))
|
||||
assert jerk_rms < 0.15, f'{jerk_rms=:.5f}'
|
||||
|
||||
|
||||
PROCESS_CHECKS = {
|
||||
'plannerd': [check_jerk_rms],
|
||||
}
|
||||
@@ -14,6 +14,7 @@ from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs, f
|
||||
from openpilot.selfdrive.test.process_replay.diff_report import diff_process, diff_report
|
||||
from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, PROC_REPLAY_DIR, FAKEDATA, replay_process, \
|
||||
check_most_messages_valid
|
||||
from openpilot.selfdrive.test.process_replay.sanity_checks import PROCESS_CHECKS
|
||||
from openpilot.tools.lib.filereader import FileReader
|
||||
from openpilot.tools.lib.logreader import LogReader, save_log
|
||||
from openpilot.tools.lib.url_file import URLFile
|
||||
@@ -122,6 +123,8 @@ def test_process(cfg, lr, segment, ref_log_msgs, new_log_path, ignore_fields=Non
|
||||
return f"Expected messages: {expected_msgs}, but got: {seen_msgs}", log_msgs
|
||||
|
||||
try:
|
||||
for check in PROCESS_CHECKS.get(cfg.proc_name, []):
|
||||
check(lr, log_msgs)
|
||||
return compare_logs(ref_log_msgs, log_msgs, ignore_fields + cfg.ignore, ignore_msgs, cfg.tolerance), log_msgs
|
||||
except Exception as e:
|
||||
return str(e), log_msgs
|
||||
|
||||
@@ -21,7 +21,7 @@ from openpilot.cereal.services import SERVICE_LIST
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.common.timeout import Timeout
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.selfdrived.events import EVENTS, ET, Alert
|
||||
from openpilot.selfdrive.selfdrived.events import EVENTS, ET
|
||||
from openpilot.selfdrive.test.helpers import set_params_enabled, release_only, processes_context, log_collector
|
||||
from openpilot.common.hardware import HARDWARE
|
||||
from openpilot.common.hardware.hw import Paths
|
||||
@@ -453,9 +453,8 @@ class TestOnroad(OpenpilotTestCase):
|
||||
@unittest.skipIf(HARDWARE.get_device_type() == "mici", "mici has no startup alert")
|
||||
def test_startup(self):
|
||||
startup_alert = self.ts['selfdriveState']['alertText1'][0]
|
||||
expected = EVENTS[log.OnroadEvent.EventName.startup][ET.PERMANENT]
|
||||
assert isinstance(expected, Alert)
|
||||
assert startup_alert == expected.alert_text_1, "wrong startup alert"
|
||||
expected = EVENTS[log.OnroadEvent.EventName.startup][ET.PERMANENT].alert_text_1
|
||||
assert startup_alert == expected, "wrong startup alert"
|
||||
|
||||
def test_engagable(self):
|
||||
no_entries = Counter()
|
||||
|
||||
@@ -40,7 +40,7 @@ PROCS = [
|
||||
Proc(['camerad'], 1.0 if MICI else 1.65, atol=0.4, msgs=['narrowRoadCameraState', 'wideRoadCameraState', 'cabinCameraState']),
|
||||
Proc(['modeld'], 1.5 if MICI else 1.65, atol=0.2, msgs=['modelV2']),
|
||||
Proc(['dmonitoringmodeld'], 0.65, atol=0.35, msgs=['driverStateV2']),
|
||||
Proc(['encoderd'], 0.15 if MICI else 0.23, atol=0.07 if MICI else 0.12, msgs=['narrowRoadEncodeData', 'wideRoadEncodeData']),
|
||||
Proc(['encoderd'], 0.23, msgs=['narrowRoadEncodeData', 'wideRoadEncodeData']),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from collections.abc import Iterable
|
||||
|
||||
from tqdm import tqdm
|
||||
from opendbc.car.tests.routes import routes as test_car_models_routes
|
||||
@@ -15,19 +18,32 @@ SOURCES: list[AzureContainer] = [
|
||||
|
||||
DEST = OpenpilotCIContainer
|
||||
|
||||
def upload_route(path: str, exclude_patterns: Iterable[str] | None = None) -> None:
|
||||
if exclude_patterns is None:
|
||||
exclude_patterns = [r'dcamera\.hevc']
|
||||
|
||||
r, n = path.rsplit("--", 1)
|
||||
r = '/'.join(r.split('/')[-2:]) # strip out anything extra in the path
|
||||
destpath = f"{r}/{n}"
|
||||
for file in os.listdir(path):
|
||||
if any(re.search(pattern, file) for pattern in exclude_patterns):
|
||||
continue
|
||||
DEST.upload_file(os.path.join(path, file), f"{destpath}/{file}")
|
||||
|
||||
|
||||
def sync_to_ci_public(route: str) -> bool:
|
||||
dest_container, dest_key = DEST.get_client_and_key()
|
||||
key_prefix = route.replace('|', '/')
|
||||
dongle_id = key_prefix.split('/')[0]
|
||||
|
||||
if DEST.has_prefix(key_prefix):
|
||||
if next(dest_container.list_blob_names(name_starts_with=key_prefix), None) is not None:
|
||||
return True
|
||||
dest_key = DEST.sas()
|
||||
|
||||
print(f"Uploading {route}")
|
||||
for source_container in SOURCES:
|
||||
# assumes az login has been run
|
||||
print(f"Trying {source_container.ACCOUNT}/{source_container.CONTAINER}")
|
||||
source_key = source_container.sas()
|
||||
_, source_key = source_container.get_client_and_key()
|
||||
cmd = [
|
||||
"azcopy",
|
||||
"copy",
|
||||
|
||||
@@ -10,6 +10,7 @@ from openpilot.selfdrive.ui.onroad.augmented_road_view import AugmentedRoadView
|
||||
from openpilot.selfdrive.ui.ui_state import device, ui_state
|
||||
from openpilot.selfdrive.ui.layouts.onboarding import OnboardingWindow
|
||||
from openpilot.selfdrive.ui.body.layouts.onroad import BodyLayout
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.trip_summary import TripSummary
|
||||
|
||||
if gui_app.sunnypilot_ui():
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.settings import SettingsLayoutSP as SettingsLayout
|
||||
@@ -31,14 +32,14 @@ class MainLayout(Widget):
|
||||
self._sidebar = Sidebar()
|
||||
self._current_mode = MainState.HOME
|
||||
self._prev_onroad = False
|
||||
self._trip_summary = TripSummary()
|
||||
|
||||
# Initialize layouts
|
||||
self._home_layout = HomeLayout()
|
||||
self._home_body_layout = BodyLayout()
|
||||
self._settings_layout = SettingsLayout()
|
||||
self._layouts: dict[MainState, Widget] = {
|
||||
MainState.HOME: self._home_layout,
|
||||
MainState.SETTINGS: self._settings_layout,
|
||||
MainState.SETTINGS: SettingsLayout(),
|
||||
MainState.ONROAD: AugmentedRoadView(),
|
||||
}
|
||||
|
||||
@@ -63,8 +64,8 @@ class MainLayout(Widget):
|
||||
self._sidebar.set_callbacks(on_settings=self._on_settings_clicked,
|
||||
on_flag=self._on_bookmark_clicked,
|
||||
open_settings=lambda: self.open_settings(PanelType.TOGGLES))
|
||||
self._home_layout._setup_widget.set_open_settings_callback(lambda: self.open_settings(PanelType.FIREHOSE))
|
||||
self._settings_layout.set_callbacks(on_close=self._set_mode_for_state)
|
||||
self._layouts[MainState.HOME]._setup_widget.set_open_settings_callback(lambda: self.open_settings(PanelType.FIREHOSE))
|
||||
self._layouts[MainState.SETTINGS].set_callbacks(on_close=self._set_mode_for_state)
|
||||
|
||||
for layout in (self._layouts[MainState.ONROAD], self._home_body_layout):
|
||||
layout.set_click_callback(self._on_onroad_clicked)
|
||||
@@ -107,7 +108,7 @@ class MainLayout(Widget):
|
||||
self._layouts[self._current_mode].show_event()
|
||||
|
||||
def open_settings(self, panel_type: PanelType):
|
||||
self._settings_layout.set_current_panel(panel_type)
|
||||
self._layouts[MainState.SETTINGS].set_current_panel(panel_type)
|
||||
self._set_current_layout(MainState.SETTINGS)
|
||||
self._sidebar.set_visible(False)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class SoftwareLayout(Widget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self._onroad_label = ListItem(lambda: tr("Updates are only downloaded while the car is off."), action_item=None)
|
||||
self._onroad_label = ListItem(lambda: tr("Updates are only downloaded while the car is off."))
|
||||
self._version_item = text_item(lambda: tr("Current Version"), ui_state.params.get("UpdaterCurrentDescription") or "")
|
||||
self._download_btn = button_item(lambda: tr("Download"), lambda: tr("CHECK"), callback=self._on_download_update)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from openpilot.selfdrive.ui.layouts.settings.initial_cruise_speed import Initial
|
||||
if gui_app.sunnypilot_ui():
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp as toggle_item
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import multiple_button_item_sp as multiple_button_item
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.initial_cruise_speed import InitialCruiseSpeedItemSP as ListItem
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.initial_cruise_speed import initial_cruise_speed_item_sp as ListItem
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.initial_cruise_speed import InitialCruiseSpeedControlSP as InitialCruiseSpeedControl
|
||||
|
||||
PERSONALITY_TO_INT = log.LongitudinalPersonality.schema.enumerants
|
||||
@@ -100,7 +100,7 @@ class TogglesLayout(Widget):
|
||||
icon="speed_limit.png"
|
||||
)
|
||||
|
||||
self._toggles: dict[str, ListItem] = {}
|
||||
self._toggles = {}
|
||||
self._initial_cruise_speed = ListItem(
|
||||
title=lambda: tr("Initial Max Speed"),
|
||||
description=lambda: tr("Max speed when engaging openpilot. If you are already driving faster, your current speed is used. " +
|
||||
|
||||
@@ -100,6 +100,8 @@ class Sidebar(Widget, SidebarSP):
|
||||
|
||||
self._draw_buttons(rect)
|
||||
self._draw_network_indicator(rect)
|
||||
if gui_app.sunnypilot_ui():
|
||||
SidebarSP._draw_bluetooth_indicator(self, rect)
|
||||
self._draw_metrics(rect)
|
||||
|
||||
def _update_state(self):
|
||||
@@ -175,7 +177,7 @@ class Sidebar(Widget, SidebarSP):
|
||||
|
||||
tint = Colors.BUTTON_PRESSED if (ui_state.started and flag_pressed) else Colors.BUTTON_NORMAL
|
||||
if icon_opacity < 1.0:
|
||||
tint = rl.Color(tint.r, tint.g, tint.b, int(255 * icon_opacity))
|
||||
tint = rl.Color(tint[0], tint[1], tint[2], int(255 * icon_opacity))
|
||||
rl.draw_texture_ex(button_img, button_pos, 0.0, 1.0, tint)
|
||||
|
||||
# Microphone button
|
||||
|
||||
@@ -127,8 +127,6 @@ class NetworkIcon(Widget):
|
||||
|
||||
|
||||
class MiciHomeLayout(Widget):
|
||||
_set_chestnut_visibility: Callable[[], None]
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._on_settings_click: Callable | None = None
|
||||
|
||||
@@ -11,6 +11,7 @@ from openpilot.selfdrive.ui.body.layouts.onroad import BodyLayout
|
||||
from openpilot.system.ui.widgets import Widget
|
||||
from openpilot.system.ui.widgets.scroller import Scroller
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.trip_summary import TripSummary
|
||||
|
||||
if gui_app.sunnypilot_ui():
|
||||
from openpilot.selfdrive.ui.sunnypilot.mici.layouts.settings import SettingsLayoutSP as SettingsLayout
|
||||
@@ -59,6 +60,7 @@ class MiciMainLayout(Scroller):
|
||||
self._setup_callbacks()
|
||||
|
||||
gui_app.add_nav_stack_tick(self._handle_transitions)
|
||||
self._trip_summary = TripSummary()
|
||||
gui_app.push_widget(self)
|
||||
|
||||
# Start onboarding if terms or training not completed, make sure to push after self
|
||||
|
||||
@@ -366,7 +366,7 @@ class MiciOffroadAlerts(NavScroller):
|
||||
time.sleep(REFRESH_INTERVAL)
|
||||
|
||||
def _sort_items(self):
|
||||
self._scroller.items.sort(key=lambda w: -w.alert_data.severity if isinstance(w, AlertItem | NotificationItem) else 0)
|
||||
self._scroller.items.sort(key=lambda w: -w.alert_data.severity)
|
||||
|
||||
def _refresh(self, pending_params: dict) -> int:
|
||||
"""Refresh alerts from params and return active count."""
|
||||
@@ -401,7 +401,7 @@ class MiciOffroadAlerts(NavScroller):
|
||||
|
||||
if text and not alert_data.visible:
|
||||
# Bump newly visible alerts to the top, severity sort keeps it at the top of its category
|
||||
widget = next(w for w in self.alert_items if w.alert_data is alert_data)
|
||||
widget = next(w for w in self._scroller.items if w.alert_data is alert_data)
|
||||
self._scroller.items.remove(widget)
|
||||
self._scroller.items.insert(0, widget)
|
||||
alert_data.text = text
|
||||
|
||||
@@ -99,7 +99,7 @@ class WifiNetworkButton(BigButton):
|
||||
def _draw_content(self, btn_y: float):
|
||||
super()._draw_content(btn_y)
|
||||
# Render lock icon at lower right of wifi icon if secured
|
||||
if self._draw_lock and self._txt_icon is not None:
|
||||
if self._draw_lock:
|
||||
icon_x = self._rect.x + self._rect.width - 30 - self._txt_icon.width
|
||||
icon_y = btn_y + 30
|
||||
lock_x = icon_x + self._txt_icon.width - self._lock_txt.width + 7
|
||||
|
||||
@@ -19,7 +19,7 @@ def blend_colors(a: rl.Color, b: rl.Color, f: float) -> rl.Color:
|
||||
|
||||
def glow_highlight_texture(asset: str, size: int, center: tuple[float, float] = (0.5, 0.5),
|
||||
radius: tuple[float, float] = (0.5, 0.5)) -> rl.Texture:
|
||||
image = gui_app._load_image_from_path(str(ASSETS_DIR / asset), size, size)
|
||||
image = gui_app._load_image_from_path((ASSETS_DIR / asset).as_posix(), size, size)
|
||||
w, h = image.width, image.height
|
||||
alpha = np.frombuffer(image.to_bytes(w * h * 4), dtype=np.uint8).reshape(h, w, 4)[..., 3] / 255.0
|
||||
rl.unload_image(image)
|
||||
|
||||
@@ -31,11 +31,13 @@ class BaseCabinCameraDialog(Widget):
|
||||
self._pm: messaging.PubMaster | None = None
|
||||
|
||||
# Load eye icons
|
||||
self._eye_fill_texture = None
|
||||
self._eye_orange_texture = None
|
||||
self._eye_size = 74
|
||||
self._glasses_texture = None
|
||||
self._glasses_size = 171
|
||||
self._eye_fill_texture = gui_app.texture("icons_mici/onroad/eye_fill.png", self._eye_size, self._eye_size)
|
||||
self._eye_orange_texture = gui_app.texture("icons_mici/onroad/eye_orange.png", self._eye_size, self._eye_size)
|
||||
self._glasses_texture = gui_app.texture("icons_mici/onroad/glasses.png", self._glasses_size, self._glasses_size)
|
||||
|
||||
self._load_eye_textures()
|
||||
|
||||
def show_event(self):
|
||||
super().show_event()
|
||||
@@ -147,6 +149,15 @@ class BaseCabinCameraDialog(Widget):
|
||||
alignment_vertical=TextAlignmentVertical.BOTTOM,
|
||||
color=rl.Color(255, 255, 255, int(255 * 0.9)))
|
||||
|
||||
def _load_eye_textures(self):
|
||||
"""Lazy load eye textures"""
|
||||
if self._eye_fill_texture is None:
|
||||
self._eye_fill_texture = gui_app.texture("icons_mici/onroad/eye_fill.png", self._eye_size, self._eye_size)
|
||||
if self._eye_orange_texture is None:
|
||||
self._eye_orange_texture = gui_app.texture("icons_mici/onroad/eye_orange.png", self._eye_size, self._eye_size)
|
||||
if self._glasses_texture is None:
|
||||
self._glasses_texture = gui_app.texture("icons_mici/onroad/glasses.png", self._glasses_size, self._glasses_size)
|
||||
|
||||
def _draw_face_detection(self, rect: rl.Rectangle):
|
||||
dm_state = ui_state.sm["driverMonitoringState"]
|
||||
driver_data = self.driver_state_renderer.get_driver_data()
|
||||
|
||||
@@ -52,7 +52,7 @@ class NavigationPanel(Widget):
|
||||
self._unload_texture()
|
||||
self._texture = rl.load_texture_from_image(rl.Image(None, SIZE, SIZE, 1, rl.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8))
|
||||
frame = self._client.recv(timeout_ms=0)
|
||||
if frame is not None and self._texture is not None:
|
||||
if frame is not None:
|
||||
gray = np.frombuffer(frame.data, dtype=np.uint8, count=SIZE * SIZE)
|
||||
rl.update_texture(self._texture, MAP_COLORS[gray])
|
||||
# Without a usable map, mapsd publishes black frames with a zero timestamp.
|
||||
@@ -101,7 +101,7 @@ class NavigationPanel(Widget):
|
||||
alignment_vertical=TextAlignmentVertical.TOP)
|
||||
map_rect = rl.Rectangle(x+8, y+61, rect.width-16, rect.height-111)
|
||||
rl.draw_rectangle_rec(map_rect, rl.BLACK)
|
||||
if self._texture is not None and self.map_ready:
|
||||
if self.map_ready:
|
||||
# A 1:1 crop of the model's frame, centered horizontally with the ego near the bottom.
|
||||
width, height = min(map_rect.width, SIZE), min(map_rect.height, SIZE)
|
||||
source = rl.Rectangle((SIZE - width) // 2, min(SIZE - height, max(0, EGO[1] + MARKER_MARGIN - height)), width, height)
|
||||
|
||||
@@ -290,7 +290,7 @@ class BigToggle(BigButton):
|
||||
def __init__(self, text: str, value: str = "", initial_state: bool = False, toggle_callback: Callable | None = None,
|
||||
*, description: str = "",
|
||||
description_icon: Union[rl.Texture, None] = None):
|
||||
super().__init__(text, value, None, description=description, description_icon=description_icon)
|
||||
super().__init__(text, value, "", description=description, description_icon=description_icon)
|
||||
self._checked = initial_state
|
||||
self._toggle_callback = toggle_callback
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class BigConfirmationDialog(BigDialogBase):
|
||||
def _on_confirm(self):
|
||||
if self._exit_on_confirm:
|
||||
self.dismiss(self._confirm_callback)
|
||||
else:
|
||||
elif self._confirm_callback:
|
||||
self._confirm_callback()
|
||||
|
||||
def _update_state(self):
|
||||
|
||||
@@ -114,7 +114,7 @@ class CameraView(Widget):
|
||||
if self._switching:
|
||||
self._handle_switch()
|
||||
|
||||
if self.client is None or not self._ensure_connection():
|
||||
if not self._ensure_connection():
|
||||
self._draw_placeholder(rect)
|
||||
return
|
||||
|
||||
@@ -165,8 +165,6 @@ class CameraView(Widget):
|
||||
return FRAME_COLOR
|
||||
|
||||
def _ensure_connection(self) -> bool:
|
||||
if self.client is None:
|
||||
return False
|
||||
if not self.client.is_connected():
|
||||
self.frame = None
|
||||
self.available_streams.clear()
|
||||
|
||||
@@ -63,7 +63,7 @@ class ModelRenderer(Widget, ChevronMetrics, ModelRendererSP):
|
||||
# Transform matrix (3x3 for car space to screen space)
|
||||
self._car_space_transform = np.zeros((3, 3), dtype=np.float32)
|
||||
self._transform_dirty = True
|
||||
self._clip_region = rl.Rectangle(0, 0, 0, 0)
|
||||
self._clip_region = None
|
||||
|
||||
self._path_gradient = Gradient(
|
||||
start=(0.0, 1.0), # Bottom of path
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
"""
|
||||
Copyright (c) 2021-, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.connect_phone import ConnectPhoneLayout
|
||||
from openpilot.sunnypilot.system.ble import grants
|
||||
from openpilot.sunnypilot.system.connect_phone import write_request
|
||||
from openpilot.system.ui.lib.application import FontWeight, gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import button_item_sp, simple_button_item_sp, toggle_item_sp
|
||||
from openpilot.system.ui.widgets import DialogResult, Widget
|
||||
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog
|
||||
from openpilot.system.ui.widgets.list_view import ITEM_TEXT_FONT_SIZE
|
||||
from openpilot.system.ui.widgets.scroller_tici import Scroller
|
||||
|
||||
POLL_INTERVAL = 1.0
|
||||
NAME_MAX_WIDTH = 1000 # px at the list font: leaves room for REMOVE in the settings panel
|
||||
|
||||
|
||||
def _fit_name(name: str) -> str:
|
||||
# a phone name is up to 80 bytes; list titles are single line and never elided by stock
|
||||
font = gui_app.font(FontWeight.NORMAL)
|
||||
if measure_text_cached(font, name, ITEM_TEXT_FONT_SIZE).x <= NAME_MAX_WIDTH:
|
||||
return name
|
||||
while name and measure_text_cached(font, name + "...", ITEM_TEXT_FONT_SIZE).x > NAME_MAX_WIDTH:
|
||||
name = name[:-1]
|
||||
return name.rstrip() + "..."
|
||||
|
||||
|
||||
class BluetoothLayout(Widget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._params = Params()
|
||||
|
||||
self._bluetooth_toggle = toggle_item_sp(
|
||||
title=lambda: tr("Bluetooth"),
|
||||
description=lambda: tr("Allow phones to connect to this device over Bluetooth."),
|
||||
param="BluetoothAllowed",
|
||||
)
|
||||
self._connect_phone_button = simple_button_item_sp(
|
||||
button_text=lambda: tr("Connect phone"),
|
||||
callback=lambda: gui_app.push_widget(ConnectPhoneLayout()),
|
||||
enabled=lambda: self._bluetooth_toggle.action_item.get_state(),
|
||||
)
|
||||
|
||||
self._phone_items = []
|
||||
self._grants: list[dict] | None = None
|
||||
self._last_poll = float("-inf")
|
||||
|
||||
self._scroller = Scroller([self._bluetooth_toggle, self._connect_phone_button], line_separator=True, spacing=0)
|
||||
|
||||
def _bluetooth_on(self) -> bool:
|
||||
return self._bluetooth_toggle.action_item.get_state()
|
||||
|
||||
def _update_state(self):
|
||||
now = time.monotonic()
|
||||
if now - self._last_poll < POLL_INTERVAL:
|
||||
return
|
||||
self._last_poll = now
|
||||
phones = grants.load(self._params)
|
||||
if phones != self._grants:
|
||||
self._grants = phones
|
||||
self._rebuild_phone_items()
|
||||
|
||||
def _rebuild_phone_items(self):
|
||||
for item in self._phone_items:
|
||||
self._scroller._items.remove(item)
|
||||
self._phone_items = [self._phone_item(phone) for phone in self._grants or []]
|
||||
for item in self._phone_items:
|
||||
item.set_visible(self._bluetooth_on)
|
||||
self._scroller.add_widget(item)
|
||||
|
||||
def _phone_item(self, phone: dict):
|
||||
spki, name = phone["spki"], _fit_name(phone["name"])
|
||||
return button_item_sp(title=name, button_text=lambda: tr("REMOVE"), callback=lambda: self._remove(spki, name))
|
||||
|
||||
def _remove(self, spki: str, name: str):
|
||||
def done(result: DialogResult):
|
||||
if result == DialogResult.CONFIRM:
|
||||
write_request(self._params, "remove", phone=spki)
|
||||
gui_app.push_widget(ConfirmDialog(tr("Remove \"{}\"?").format(name), tr("Remove"), tr("Cancel"), callback=done))
|
||||
|
||||
def _render(self, rect):
|
||||
self._scroller.render(rect)
|
||||
@@ -0,0 +1,205 @@
|
||||
"""
|
||||
Copyright (c) 2021-, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
import math
|
||||
import time
|
||||
|
||||
import pyray as rl
|
||||
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.ui.ui_state import device
|
||||
from openpilot.selfdrive.ui.widgets.pairing_dialog import PairingDialog
|
||||
from openpilot.sunnypilot.system.connect_phone import WINDOW_SECONDS, display_name, format_code, read_window, write_request
|
||||
from openpilot.system.ui.lib.application import FontWeight, gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr, tr_noop
|
||||
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
from openpilot.system.ui.lib.wrap_text import wrap_text
|
||||
from openpilot.system.ui.widgets import DialogResult
|
||||
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog
|
||||
|
||||
POLL_INTERVAL = 0.25
|
||||
START_TIMEOUT = 15
|
||||
STALE_SECONDS = 3
|
||||
CLOSE_REASON_MESSAGES = {
|
||||
"granted": tr_noop("Phone connected."),
|
||||
"denied": tr_noop("Phone not connected."),
|
||||
"no_answer": tr_noop("Phone not connected: Allow was not tapped in time."),
|
||||
"phone_left": tr_noop("Phone not connected: the phone disconnected."),
|
||||
"wrong_codes": tr_noop("Phone not connected: too many wrong codes. Try again."),
|
||||
"limit": tr_noop("Phone not connected: 8 phones are already connected. Remove one first."),
|
||||
"timeout": tr_noop("The connect window timed out. Try again."),
|
||||
"bluetooth_off": tr_noop("Bluetooth is off. Turn Bluetooth on to connect a phone."),
|
||||
"no_key": tr_noop("The device key is unavailable. Reboot and try again."),
|
||||
}
|
||||
|
||||
|
||||
class ConnectPhoneLayout(PairingDialog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._params = Params()
|
||||
self._name = display_name(self._params)
|
||||
self._close_btn.set_click_callback(self._close_screen)
|
||||
self._started = False
|
||||
self._closed = False
|
||||
self._seq = 0
|
||||
self._opened_at = 0.0
|
||||
self._matched_at = 0.0
|
||||
self._window: dict | None = None
|
||||
self._last_poll = float("-inf")
|
||||
self._qr_source = ""
|
||||
self._check_dialog: ConfirmDialog | None = None
|
||||
self._check_shown_for: float | None = None
|
||||
|
||||
def show_event(self):
|
||||
super().show_event()
|
||||
device.set_override_interactive_timeout(WINDOW_SECONDS + 10)
|
||||
# a tick, not _update_state: it has to keep polling while the Allow dialog is on top
|
||||
gui_app.add_nav_stack_tick(self._tick)
|
||||
if not self._started:
|
||||
self._started = True
|
||||
self._seq = write_request(self._params, "open")
|
||||
self._opened_at = time.monotonic()
|
||||
|
||||
def hide_event(self):
|
||||
super().hide_event()
|
||||
gui_app.remove_nav_stack_tick(self._tick)
|
||||
device.set_override_interactive_timeout(None)
|
||||
if self._seq and not self._closed:
|
||||
write_request(self._params, "cancel")
|
||||
self._closed = True
|
||||
|
||||
def _update_state(self):
|
||||
pass # stock closes itself once the device is paired to comma connect
|
||||
|
||||
def _tick(self):
|
||||
if self._closed:
|
||||
return
|
||||
now = time.monotonic()
|
||||
if now - self._last_poll >= POLL_INTERVAL:
|
||||
self._last_poll = now
|
||||
window = read_window(self._params)
|
||||
if window and window.get("seq") == self._seq:
|
||||
self._window = window
|
||||
self._matched_at = now
|
||||
if window.get("state") == "closed":
|
||||
self._on_closed(window.get("reason", ""))
|
||||
return
|
||||
self._sync_check_dialog(window.get("prompt") or {})
|
||||
|
||||
if self._window is not None and self._window.get("state") == "open":
|
||||
if not self._window.get("held") and now >= self._window.get("deadline", 0.0):
|
||||
self._on_closed("timeout")
|
||||
elif self._matched_at and now - self._matched_at > STALE_SECONDS:
|
||||
self._finish(None)
|
||||
elif now - self._opened_at > START_TIMEOUT:
|
||||
write_request(self._params, "cancel")
|
||||
self._finish(tr("Bluetooth did not start"))
|
||||
|
||||
def _sync_check_dialog(self, prompt: dict):
|
||||
if prompt.get("step") == "allow" and self._check_shown_for != prompt.get("until"):
|
||||
self._check_shown_for = prompt.get("until")
|
||||
text = tr("Code {}\nIs the same code on your phone?").format(prompt.get("check", ""))
|
||||
self._check_dialog = ConfirmDialog(text, tr("Allow"), tr("Deny"), callback=self._answer)
|
||||
gui_app.push_widget(self._check_dialog)
|
||||
elif prompt.get("step") != "allow" and self._check_dialog is not None:
|
||||
gui_app.pop_widgets_to(self, instant=True)
|
||||
self._check_dialog = None
|
||||
|
||||
def _answer(self, result: DialogResult):
|
||||
self._check_dialog = None
|
||||
write_request(self._params, "allow" if result == DialogResult.CONFIRM else "deny")
|
||||
|
||||
def _on_closed(self, reason: str):
|
||||
message = CLOSE_REASON_MESSAGES.get(reason)
|
||||
self._finish(tr(message) if message else None)
|
||||
|
||||
def _finish(self, message: str | None):
|
||||
self._closed = True
|
||||
gui_app.pop_widgets_to(self, instant=True)
|
||||
self._close_screen()
|
||||
if message:
|
||||
gui_app.push_widget(ConfirmDialog(message, tr("OK"), cancel_text=""))
|
||||
|
||||
def _close_screen(self):
|
||||
if gui_app.get_active_widget() is self:
|
||||
gui_app.pop_widget()
|
||||
|
||||
def _get_pairing_url(self) -> str:
|
||||
return self._qr_source
|
||||
|
||||
def _check_qr_refresh(self):
|
||||
qr = (self._window or {}).get("qr", "") if self._is_open() else ""
|
||||
if qr and qr != self._qr_source:
|
||||
self._qr_source = qr
|
||||
self._generate_qr_code()
|
||||
|
||||
def _is_open(self) -> bool:
|
||||
return self._window is not None and self._window.get("state") == "open" and not self._window.get("held")
|
||||
|
||||
def _render(self, rect: rl.Rectangle) -> int:
|
||||
# copied from PairingDialog._render: stock hardcodes its title and steps there
|
||||
rl.clear_background(rl.Color(224, 224, 224, 255))
|
||||
self._check_qr_refresh()
|
||||
|
||||
margin = 70
|
||||
content_rect = rl.Rectangle(rect.x + margin, rect.y + margin, rect.width - 2 * margin, rect.height - 2 * margin)
|
||||
y = content_rect.y
|
||||
close_size = 80
|
||||
pad = 20
|
||||
self._close_btn.render(rl.Rectangle(content_rect.x - pad, y - pad, close_size + pad * 2, close_size + pad * 2))
|
||||
y += close_size + 40
|
||||
|
||||
title_font = gui_app.font(FontWeight.NORMAL)
|
||||
left_width = int(content_rect.width * 0.5 - 15)
|
||||
title_wrapped = wrap_text(title_font, tr("Connect a phone to {}").format(self._name), 75, left_width)
|
||||
rl.draw_text_ex(title_font, "\n".join(title_wrapped), rl.Vector2(content_rect.x, y), 75, 0.0, rl.BLACK)
|
||||
y += len(title_wrapped) * 75 + 60
|
||||
|
||||
remaining_height = content_rect.height - (y - content_rect.y)
|
||||
right_width = content_rect.width // 2 - 20
|
||||
self._render_instructions(rl.Rectangle(content_rect.x, y, left_width, remaining_height))
|
||||
|
||||
qr_size = min(right_width, content_rect.height) - 40
|
||||
qr_rect = rl.Rectangle(content_rect.x + left_width + 40 + (right_width - qr_size) // 2, content_rect.y, qr_size, qr_size)
|
||||
if self._is_open():
|
||||
self._render_qr_code(qr_rect)
|
||||
else:
|
||||
text = tr("Connecting phone") if self._window is not None and self._window.get("held") else tr("Starting Bluetooth")
|
||||
rl.draw_rectangle_rounded(qr_rect, 0.1, 20, rl.Color(240, 240, 240, 255))
|
||||
font = gui_app.font(FontWeight.BOLD)
|
||||
size = measure_text_cached(font, text, 47)
|
||||
rl.draw_text_ex(font, text, rl.Vector2(qr_rect.x + (qr_rect.width - size.x) / 2, qr_rect.y + (qr_rect.height - size.y) / 2), 47, 0,
|
||||
rl.BLACK)
|
||||
return -1
|
||||
|
||||
def _render_instructions(self, rect: rl.Rectangle) -> None:
|
||||
window = self._window if self._is_open() else None
|
||||
instructions = [
|
||||
tr("Open the sunnylink app and tap Connect phone"),
|
||||
tr("Scan the QR code on the right, or type {}").format(format_code(int(window["code"]))) if window else tr("Scan the QR code on the right"),
|
||||
tr("Check that both screens show the same code, then tap Allow"),
|
||||
]
|
||||
font = gui_app.font(FontWeight.BOLD)
|
||||
y = rect.y
|
||||
for i, text in enumerate(instructions):
|
||||
circle_radius = 25
|
||||
circle_x = rect.x + circle_radius + 15
|
||||
text_x = rect.x + circle_radius * 2 + 40
|
||||
wrapped = wrap_text(font, text, 47, int(rect.width - (circle_radius * 2 + 40)))
|
||||
text_height = len(wrapped) * 47
|
||||
circle_y = y + text_height // 2
|
||||
rl.draw_circle(int(circle_x), int(circle_y), circle_radius, rl.Color(70, 70, 70, 255))
|
||||
number = str(i + 1)
|
||||
number_size = measure_text_cached(font, number, 30)
|
||||
rl.draw_text_ex(font, number, (int(circle_x - number_size.x // 2), int(circle_y - number_size.y // 2)), 30, 0, rl.WHITE)
|
||||
rl.draw_text_ex(font, "\n".join(wrapped), rl.Vector2(text_x, y), 47, 0.0, rl.BLACK)
|
||||
y += text_height + 50
|
||||
|
||||
if window:
|
||||
remaining = max(0, math.ceil(window.get("deadline", 0.0) - time.monotonic()))
|
||||
rl.draw_text_ex(gui_app.font(FontWeight.NORMAL), tr("Time left {}:{:02d}").format(remaining // 60, remaining % 60),
|
||||
rl.Vector2(rect.x, y), 47, 0.0, rl.Color(70, 70, 70, 255))
|
||||
@@ -57,6 +57,12 @@ class CruiseLayout(Widget):
|
||||
description=tr("Use map data to estimate the appropriate speed to drive through turns ahead."),
|
||||
param="SmartCruiseControlMap")
|
||||
|
||||
self.accel_boost_toggle = toggle_item_sp(
|
||||
title=tr("Acceleration Boost"),
|
||||
description=tr("Adds a small push on top of sunnypilot's own acceleration, stronger in Aggressive and gentler in Relaxed. " +
|
||||
"Eases off in curves and when sunnypilot slows or stops. Never goes past your set speed, and lead-car following still comes first."),
|
||||
param="AccelBoostSP")
|
||||
|
||||
self.custom_acc_toggle = toggle_item_sp(
|
||||
title=tr("Custom ACC Speed Increments"),
|
||||
description="",
|
||||
@@ -86,6 +92,7 @@ class CruiseLayout(Widget):
|
||||
self.icbm_toggle,
|
||||
self.scc_v_toggle,
|
||||
self.scc_m_toggle,
|
||||
self.accel_boost_toggle,
|
||||
self.custom_acc_toggle,
|
||||
self.custom_acc_short_increment,
|
||||
self.custom_acc_long_increment,
|
||||
@@ -136,6 +143,8 @@ class CruiseLayout(Widget):
|
||||
self.icbm_toggle.set_description(new_desc)
|
||||
self.icbm_toggle.show_description(True)
|
||||
|
||||
self.accel_boost_toggle.action_item.set_enabled(has_long)
|
||||
|
||||
if has_long or has_icbm:
|
||||
self.custom_acc_toggle.action_item.set_enabled(((has_long and not ui_state.CP.pcmCruise) or has_icbm) and ui_state.is_offroad())
|
||||
self.scc_v_toggle.action_item.set_enabled(True)
|
||||
@@ -151,6 +160,7 @@ class CruiseLayout(Widget):
|
||||
else:
|
||||
has_icbm = has_long = False
|
||||
self.icbm_toggle.action_item.set_enabled(False)
|
||||
self.accel_boost_toggle.action_item.set_enabled(False)
|
||||
self.icbm_toggle.set_description(tr(ONROAD_ONLY_DESCRIPTION))
|
||||
|
||||
show_custom_acc_desc = False
|
||||
@@ -160,7 +170,7 @@ class CruiseLayout(Widget):
|
||||
show_custom_acc_desc = True
|
||||
else:
|
||||
if has_long or has_icbm:
|
||||
if has_long and ui_state.CP is not None and ui_state.CP.pcmCruise:
|
||||
if has_long and ui_state.CP.pcmCruise:
|
||||
new_custom_acc_desc = tr(ACC_PCMCRUISE_DISABLED_DESCRIPTION)
|
||||
show_custom_acc_desc = True
|
||||
else:
|
||||
|
||||
@@ -149,7 +149,8 @@ class DeviceLayoutSP(DeviceLayout):
|
||||
def _do_reset(result: int):
|
||||
if result == DialogResult.CONFIRM:
|
||||
for _key in ui_state.params.all_keys():
|
||||
ui_state.params.remove(_key)
|
||||
if not _key.startswith("SunnylinkLocal"):
|
||||
ui_state.params.remove(_key)
|
||||
HARDWARE.reboot()
|
||||
|
||||
def _second_confirm(result: int):
|
||||
|
||||
@@ -33,7 +33,6 @@ class InitialCruiseSpeedControlSP(OptionControlSP):
|
||||
return f"{self._options[self.current_value]} " + (tr("km/h") if ui_state.is_metric else tr("mph"))
|
||||
|
||||
|
||||
class InitialCruiseSpeedItemSP(ListItemSP):
|
||||
def initial_cruise_speed_item_sp(**kwargs) -> ListItemSP:
|
||||
"""Stock row in the sunnypilot option layout: title on top, control below, like option_item_sp."""
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(inline=False, **kwargs)
|
||||
return ListItemSP(inline=False, **kwargs)
|
||||
|
||||
@@ -158,8 +158,8 @@ class ModelsLayout(Widget):
|
||||
|
||||
bundle = self.model_manager.selectedBundle if self.model_manager else None
|
||||
progresses = [model.artifact.downloadProgress for model in bundle.models if model.artifact.fileName] if bundle else []
|
||||
if bundle is None or not progresses or bundle.status not in (custom.ModelManagerSP.DownloadStatus.downloading,
|
||||
custom.ModelManagerSP.DownloadStatus.failed):
|
||||
if not progresses or bundle.status not in (custom.ModelManagerSP.DownloadStatus.downloading,
|
||||
custom.ModelManagerSP.DownloadStatus.failed):
|
||||
self.download_item.action_item.update(name="", segments=self._slot_segments())
|
||||
return
|
||||
|
||||
@@ -261,7 +261,7 @@ class ModelsLayout(Widget):
|
||||
return {"name": name, "text_color": rl.GRAY, "icon": "icons/circled_slash.png", "icon_color": rl.WHITE}
|
||||
|
||||
def _on_model_selected(self, result):
|
||||
if result != DialogResult.CONFIRM or self.model_dialog is None:
|
||||
if result != DialogResult.CONFIRM:
|
||||
self.model_dialog = None
|
||||
return
|
||||
selected_ref = self.model_dialog.selection_ref
|
||||
|
||||
@@ -5,6 +5,7 @@ This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import threading
|
||||
import time
|
||||
import raylib_nb as rl
|
||||
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
@@ -29,6 +30,7 @@ class NetworkUISP(NetworkUI):
|
||||
|
||||
threading.Thread(target=self._wifi_manager._update_networks, daemon=True).start()
|
||||
self._wifi_manager._request_scan()
|
||||
self._wifi_manager._last_network_update = time.monotonic()
|
||||
|
||||
def _on_networks_updated(self, networks):
|
||||
if self._scanning:
|
||||
|
||||
@@ -59,7 +59,7 @@ class OSMLayout(Widget):
|
||||
|
||||
def calculate_size(self):
|
||||
total_size = 0
|
||||
directories_to_scan = [str(MAP_PATH)] if MAP_PATH.exists() else []
|
||||
directories_to_scan = [MAP_PATH] if MAP_PATH.exists() else []
|
||||
while directories_to_scan:
|
||||
try:
|
||||
for entry in os.scandir(directories_to_scan.pop()):
|
||||
|
||||
@@ -11,6 +11,7 @@ import raylib_nb as rl
|
||||
from openpilot.selfdrive.ui.layouts.settings import settings as OP
|
||||
from openpilot.selfdrive.ui.layouts.settings.firehose import FirehoseLayout
|
||||
from openpilot.selfdrive.ui.layouts.settings.toggles import TogglesLayout
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.bluetooth import BluetoothLayout
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.cruise import CruiseLayout
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.developer import DeveloperLayoutSP
|
||||
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.device import DeviceLayoutSP
|
||||
@@ -37,7 +38,7 @@ from openpilot.system.ui.widgets.scroller_tici import Scroller
|
||||
OP.PANEL_COLOR = rl.Color(10, 10, 10, 255)
|
||||
ICON_SIZE = 70
|
||||
|
||||
PanelType = IntEnum(
|
||||
OP.PanelType = IntEnum( # type: ignore[assignment] # ty: ignore[invalid-assignment]
|
||||
"PanelType",
|
||||
[es.name for es in OP.PanelType] + [
|
||||
"SUNNYLINK",
|
||||
@@ -50,10 +51,10 @@ PanelType = IntEnum(
|
||||
"NAVIGATION",
|
||||
"TRIPS",
|
||||
"VEHICLE",
|
||||
"BLUETOOTH",
|
||||
],
|
||||
start=0,
|
||||
)
|
||||
OP.PanelType = PanelType # type: ignore[assignment] # ty: ignore[invalid-assignment]
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -110,22 +111,23 @@ class SettingsLayoutSP(OP.SettingsLayout):
|
||||
wifi_manager.set_active(False)
|
||||
|
||||
self._panels = {
|
||||
PanelType.DEVICE: PanelInfo(tr_noop("Device"), DeviceLayoutSP(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_home.png"),
|
||||
PanelType.NETWORK: PanelInfo(tr_noop("Network"), NetworkUISP(wifi_manager), icon="icons/network.png"),
|
||||
PanelType.SUNNYLINK: PanelInfo(tr_noop("sunnylink"), SunnylinkLayout(), icon="icons/wifi_strength_full.png"),
|
||||
PanelType.TOGGLES: PanelInfo(tr_noop("Toggles"), TogglesLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_toggle.png"),
|
||||
PanelType.SOFTWARE: PanelInfo(tr_noop("Software"), SoftwareLayoutSP(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_software.png"),
|
||||
PanelType.MODELS: PanelInfo(tr_noop("Models"), ModelsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_models.png"),
|
||||
PanelType.STEERING: PanelInfo(tr_noop("Steering"), SteeringLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_lateral.png"),
|
||||
PanelType.CRUISE: PanelInfo(tr_noop("Cruise"), CruiseLayout(), icon="icons/speed_limit.png"),
|
||||
PanelType.VISUALS: PanelInfo(tr_noop("Visuals"), VisualsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_visuals.png"),
|
||||
PanelType.DISPLAY: PanelInfo(tr_noop("Display"), DisplayLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_display.png"),
|
||||
PanelType.OSM: PanelInfo(tr_noop("OSM"), OSMLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_map.png"),
|
||||
# PanelType.NAVIGATION: PanelInfo(tr_noop("Navigation"), NavigationLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_map.png"),
|
||||
PanelType.TRIPS: PanelInfo(tr_noop("Trips"), TripsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_trips.png"),
|
||||
PanelType.VEHICLE: PanelInfo(tr_noop("Vehicle"), VehicleLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_vehicle.png"),
|
||||
PanelType.FIREHOSE: PanelInfo(tr_noop("Firehose"), FirehoseLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_firehose.png"),
|
||||
PanelType.DEVELOPER: PanelInfo(tr_noop("Developer"), DeveloperLayoutSP(), icon="icons/shell.png"),
|
||||
OP.PanelType.DEVICE: PanelInfo(tr_noop("Device"), DeviceLayoutSP(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_home.png"),
|
||||
OP.PanelType.NETWORK: PanelInfo(tr_noop("Network"), NetworkUISP(wifi_manager), icon="icons/network.png"),
|
||||
OP.PanelType.BLUETOOTH: PanelInfo(tr_noop("Bluetooth"), BluetoothLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_bluetooth.png"),
|
||||
OP.PanelType.SUNNYLINK: PanelInfo(tr_noop("sunnylink"), SunnylinkLayout(), icon="icons/wifi_strength_full.png"),
|
||||
OP.PanelType.TOGGLES: PanelInfo(tr_noop("Toggles"), TogglesLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_toggle.png"),
|
||||
OP.PanelType.SOFTWARE: PanelInfo(tr_noop("Software"), SoftwareLayoutSP(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_software.png"),
|
||||
OP.PanelType.MODELS: PanelInfo(tr_noop("Models"), ModelsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_models.png"),
|
||||
OP.PanelType.STEERING: PanelInfo(tr_noop("Steering"), SteeringLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_lateral.png"),
|
||||
OP.PanelType.CRUISE: PanelInfo(tr_noop("Cruise"), CruiseLayout(), icon="icons/speed_limit.png"),
|
||||
OP.PanelType.VISUALS: PanelInfo(tr_noop("Visuals"), VisualsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_visuals.png"),
|
||||
OP.PanelType.DISPLAY: PanelInfo(tr_noop("Display"), DisplayLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_display.png"),
|
||||
OP.PanelType.OSM: PanelInfo(tr_noop("OSM"), OSMLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_map.png"),
|
||||
# OP.PanelType.NAVIGATION: PanelInfo(tr_noop("Navigation"), NavigationLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_map.png"),
|
||||
OP.PanelType.TRIPS: PanelInfo(tr_noop("Trips"), TripsLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_trips.png"),
|
||||
OP.PanelType.VEHICLE: PanelInfo(tr_noop("Vehicle"), VehicleLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_vehicle.png"),
|
||||
OP.PanelType.FIREHOSE: PanelInfo(tr_noop("Firehose"), FirehoseLayout(), icon="../../sunnypilot/selfdrive/assets/offroad/icon_firehose.png"),
|
||||
OP.PanelType.DEVELOPER: PanelInfo(tr_noop("Developer"), DeveloperLayoutSP(), icon="icons/shell.png"),
|
||||
}
|
||||
|
||||
def _draw_sidebar(self, rect: rl.Rectangle):
|
||||
|
||||
@@ -73,7 +73,7 @@ class SoftwareLayoutSP(SoftwareLayout):
|
||||
]
|
||||
|
||||
def _on_branch_selected(result):
|
||||
if result == DialogResult.CONFIRM and isinstance(self._branch_dialog, TreeOptionDialog):
|
||||
if result == DialogResult.CONFIRM and self._branch_dialog is not None:
|
||||
selection = self._branch_dialog.selection_ref
|
||||
if selection:
|
||||
ui_state.params.put("UpdaterTargetBranch", selection)
|
||||
|
||||
@@ -11,11 +11,17 @@ from openpilot.system.ui.lib.multilang import tr, tr_noop
|
||||
from openpilot.system.ui.widgets import DialogResult
|
||||
from openpilot.system.ui.widgets.confirm_dialog import ConfirmDialog
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp
|
||||
from opendbc.car.toyota.values import ToyotaFlags
|
||||
from opendbc.car.toyota.values import CAR, ToyotaFlags
|
||||
from opendbc.sunnypilot.car.toyota.values import ToyotaFlagsSP
|
||||
|
||||
|
||||
ONROAD_ONLY_DESCRIPTION = tr_noop("Start the vehicle to check vehicle compatibility.")
|
||||
SNG_HACK_UNAVAILABLE = tr_noop("sunnypilot Longitudinal Control must be available and enabled for your vehicle to use this feature.")
|
||||
BSM_UNAVAILABLE = tr_noop("Enhanced Blind Spot Monitoring requires a TSS2 Toyota/Lexus without SecOC, " +
|
||||
"or a smartDSU with sunnypilot longitudinal control.")
|
||||
BSM_STOCK_LONG_UNAVAILABLE = tr_noop("Enhanced Blind Spot Monitoring is not available while Enforce Factory Longitudinal Control is enabled.")
|
||||
BSM_REQUIRED = tr_noop("This vehicle does not report blind spot status over the standard CAN signals. " +
|
||||
"Enhanced Blind Spot Monitoring is required for blind spot detection.")
|
||||
PLATFORM_UNAVAILABLE = tr_noop("This feature is currently not available on this platform.")
|
||||
|
||||
DESCRIPTIONS = {
|
||||
@@ -26,6 +32,10 @@ DESCRIPTIONS = {
|
||||
'sunnypilot will allow some Toyota/Lexus cars to auto resume during stop and go traffic. ' +
|
||||
'This feature is only applicable to certain models that are able to use longitudinal control. This is an alpha feature. Use at your own risk.'
|
||||
),
|
||||
'enhanced_bsm': tr_noop(
|
||||
'sunnypilot will poll the blind spot monitor diagnostics directly from the radar. Use this on vehicles whose blind spot monitors ' +
|
||||
'do not report blind spot status over the standard CAN signals. This is an alpha feature. Use at your own risk.'
|
||||
),
|
||||
'tss2_smooth': tr_noop(
|
||||
'Enable smoother longitudinal control for TSS2 vehicles. ' +
|
||||
'Uses a custom speed-dependent integral gain curve for smoother traffic driving.'
|
||||
@@ -53,6 +63,14 @@ class ToyotaSettings(BrandSettings):
|
||||
enabled=lambda: not ui_state.engaged,
|
||||
)
|
||||
|
||||
self.enhanced_bsm = toggle_item_sp(
|
||||
lambda: tr("Enhanced Blind Spot Monitoring (Alpha)"),
|
||||
description=lambda: tr(DESCRIPTIONS["enhanced_bsm"]),
|
||||
initial_state=ui_state.params.get_bool("ToyotaEnhancedBsm"),
|
||||
callback=self._on_enable_enhanced_bsm,
|
||||
enabled=lambda: not ui_state.engaged,
|
||||
)
|
||||
|
||||
self.tss2_smooth = toggle_item_sp(
|
||||
lambda: tr("TSS2 Smooth Longitudinal (Alpha)"),
|
||||
description=lambda: tr(DESCRIPTIONS["tss2_smooth"]),
|
||||
@@ -64,6 +82,7 @@ class ToyotaSettings(BrandSettings):
|
||||
self.items = [
|
||||
self.enforce_stock_longitudinal,
|
||||
self.stop_and_go_hack,
|
||||
self.enhanced_bsm,
|
||||
self.tss2_smooth,
|
||||
]
|
||||
|
||||
@@ -130,6 +149,25 @@ class ToyotaSettings(BrandSettings):
|
||||
ui_state.params.put_bool("ToyotaStopAndGoHack", False)
|
||||
ui_state.params.put_bool("OnroadCycleRequested", True)
|
||||
|
||||
def _on_enable_enhanced_bsm(self, state: bool):
|
||||
if state:
|
||||
def confirm_callback(result: int):
|
||||
if result == DialogResult.CONFIRM:
|
||||
ui_state.params.put_bool("ToyotaEnhancedBsm", True)
|
||||
ui_state.params.put_bool("OnroadCycleRequested", True)
|
||||
else:
|
||||
self.enhanced_bsm.action_item.set_state(False)
|
||||
|
||||
content = (f"<h1>{self.enhanced_bsm.title}</h1><br>" +
|
||||
f"<p>{self.enhanced_bsm.description}</p>")
|
||||
|
||||
dlg = ConfirmDialog(content, tr("Enable"), rich=True, callback=confirm_callback)
|
||||
gui_app.push_widget(dlg)
|
||||
|
||||
else:
|
||||
ui_state.params.put_bool("ToyotaEnhancedBsm", False)
|
||||
ui_state.params.put_bool("OnroadCycleRequested", True)
|
||||
|
||||
def update_settings(self):
|
||||
if ui_state.CP is not None:
|
||||
longitudinal = ui_state.CP.openpilotLongitudinalControl
|
||||
@@ -150,6 +188,33 @@ class ToyotaSettings(BrandSettings):
|
||||
if show_desc:
|
||||
self.stop_and_go_hack.show_description(True)
|
||||
|
||||
# Enhanced BSM needs the radar diagnostic address, which is only in the TX allowlist for
|
||||
# TSS2 cars without SecOC, or for TSS-P cars with a smartDSU. Both need openpilot long.
|
||||
sdsu_bsm_supported = (ui_state.CP_SP is not None and
|
||||
bool(ui_state.CP_SP.flags & ToyotaFlagsSP.SMART_DSU))
|
||||
bsm_supported = (not bool(ui_state.CP.flags & ToyotaFlags.SECOC) and
|
||||
(bool(ui_state.CP.flags & ToyotaFlags.TSS2) or sdsu_bsm_supported))
|
||||
bsm_available = bsm_supported and longitudinal and not enforce_stock
|
||||
self.enhanced_bsm.action_item.set_enabled(bsm_available and not ui_state.engaged)
|
||||
|
||||
bsm_desc = tr(DESCRIPTIONS["enhanced_bsm"])
|
||||
if not bsm_supported:
|
||||
self.enhanced_bsm.action_item.set_state(False)
|
||||
bsm_desc = "<b>" + tr(BSM_UNAVAILABLE) + "</b>\n\n" + bsm_desc
|
||||
elif enforce_stock:
|
||||
self.enhanced_bsm.action_item.set_state(False)
|
||||
bsm_desc = "<b>" + tr(BSM_STOCK_LONG_UNAVAILABLE) + "</b>\n\n" + bsm_desc
|
||||
elif not longitudinal:
|
||||
self.enhanced_bsm.action_item.set_state(False)
|
||||
bsm_desc = "<b>" + tr(SNG_HACK_UNAVAILABLE) + "</b>\n\n" + bsm_desc
|
||||
elif ui_state.CP.carFingerprint == CAR.TOYOTA_PRIUS_TSS2:
|
||||
bsm_desc = "<b>" + tr(BSM_REQUIRED) + "</b>\n\n" + bsm_desc
|
||||
|
||||
if self.enhanced_bsm.description != bsm_desc:
|
||||
self.enhanced_bsm.set_description(bsm_desc)
|
||||
if not bsm_available:
|
||||
self.enhanced_bsm.show_description(True)
|
||||
|
||||
tss2 = bool(ui_state.CP.flags & ToyotaFlags.TSS2)
|
||||
if longitudinal and not enforce_stock and tss2:
|
||||
self.tss2_smooth.action_item.set_enabled(not ui_state.engaged)
|
||||
@@ -173,6 +238,12 @@ class ToyotaSettings(BrandSettings):
|
||||
self.stop_and_go_hack.set_description(new_desc)
|
||||
self.stop_and_go_hack.show_description(True)
|
||||
|
||||
self.enhanced_bsm.action_item.set_enabled(False)
|
||||
bsm_desc = "<b>" + tr(ONROAD_ONLY_DESCRIPTION) + "</b>\n\n" + tr(DESCRIPTIONS["enhanced_bsm"])
|
||||
if self.enhanced_bsm.description != bsm_desc:
|
||||
self.enhanced_bsm.set_description(bsm_desc)
|
||||
self.enhanced_bsm.show_description(True)
|
||||
|
||||
self.tss2_smooth.action_item.set_enabled(False)
|
||||
new_desc = "<b>" + tr(ONROAD_ONLY_DESCRIPTION) + "</b>\n\n" + tr(DESCRIPTIONS["tss2_smooth"])
|
||||
if self.tss2_smooth.description != new_desc:
|
||||
|
||||
@@ -72,6 +72,11 @@ class VisualsLayout(Widget):
|
||||
"It is the driver's responsibility to observe their environment and make decisions accordingly."),
|
||||
None,
|
||||
),
|
||||
"TripSummary": (
|
||||
lambda: tr("Trip Summary"),
|
||||
tr("Show a summary of distance and engagement when you shift into park after a drive."),
|
||||
None,
|
||||
),
|
||||
"TrueVEgoUI": (
|
||||
lambda: tr("Speedometer: Always Display True Speed"),
|
||||
tr("For applicable vehicles, always display the true vehicle current speed from wheel speed sensors."),
|
||||
|
||||
@@ -11,6 +11,7 @@ import time
|
||||
from dataclasses import dataclass
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state, ChestnutState
|
||||
from openpilot.sunnypilot.sunnylink.api import UNREGISTERED_SUNNYLINK_DONGLE_ID
|
||||
from openpilot.sunnypilot.system.connect_phone import phone_indicator, read_status
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr_noop
|
||||
|
||||
@@ -23,6 +24,11 @@ HOME_BTN = rl.Rectangle(60, 860, 180, 180)
|
||||
|
||||
CHESTNUT_ICON_WIDTH = 180
|
||||
CHESTNUT_ICON_HEIGHT = 133
|
||||
BT_ICON_SIZE = 30
|
||||
BT_ICON_X = 250 # right of the signal dots, clear of the mic indicator
|
||||
BT_ICON_Y = 195
|
||||
BT_POLL_SECONDS = 1.0
|
||||
BT_WAITING_OPACITY = 0.35
|
||||
|
||||
|
||||
# Color scheme
|
||||
@@ -62,6 +68,19 @@ class SidebarSP:
|
||||
self._chestnut_green_img = gui_app.texture("icons_mici/chestnut_green.png", CHESTNUT_ICON_WIDTH, CHESTNUT_ICON_HEIGHT)
|
||||
self._chestnut_default_img = gui_app.texture("icons_mici/chestnut.png", CHESTNUT_ICON_WIDTH, CHESTNUT_ICON_HEIGHT)
|
||||
self._chestnut_orange_img = gui_app.texture("icons_mici/chestnut_orange.png", CHESTNUT_ICON_WIDTH, CHESTNUT_ICON_HEIGHT)
|
||||
self._bt_img = gui_app.texture("../../sunnypilot/selfdrive/assets/offroad/icon_bluetooth.png", BT_ICON_SIZE, BT_ICON_SIZE)
|
||||
self._bt_state = "hidden"
|
||||
self._bt_polled_at = float("-inf")
|
||||
|
||||
def _draw_bluetooth_indicator(self, rect: rl.Rectangle):
|
||||
now = time.monotonic()
|
||||
if now - self._bt_polled_at >= BT_POLL_SECONDS:
|
||||
self._bt_polled_at = now
|
||||
self._bt_state = phone_indicator(read_status(ui_state.params))
|
||||
if self._bt_state == "hidden":
|
||||
return
|
||||
alpha = 255 if self._bt_state == "connected" else int(255 * BT_WAITING_OPACITY)
|
||||
rl.draw_texture_ex(self._bt_img, rl.Vector2(rect.x + BT_ICON_X, rect.y + BT_ICON_Y), 0.0, 1.0, rl.Color(255, 255, 255, alpha))
|
||||
|
||||
def _update_sunnylink_status(self):
|
||||
if not ui_state.params.get_bool("SunnylinkEnabled"):
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import time
|
||||
import pyray as rl
|
||||
|
||||
from opendbc.car.structs import car
|
||||
|
||||
from openpilot.common.constants import CV
|
||||
from openpilot.selfdrive.ui.onroad.augmented_road_view import BORDER_COLORS
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state, UIStatus
|
||||
from openpilot.system.ui.lib.application import gui_app, FontWeight
|
||||
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
from openpilot.system.ui.widgets import Widget
|
||||
|
||||
AUTO_DISMISS = 20.
|
||||
FADE_IN, FADE_OUT = 0.35, 0.3
|
||||
LAT = (UIStatus.ENGAGED, UIStatus.LAT_ONLY)
|
||||
LONG = (UIStatus.ENGAGED, UIStatus.LONG_ONLY)
|
||||
GEAR = car.CarState.GearShifter
|
||||
FORWARD = (GEAR.drive, GEAR.sport, GEAR.low, GEAR.brake, GEAR.eco, GEAR.manumatic)
|
||||
|
||||
|
||||
class TripTracker:
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
self.segments: list[list] = []
|
||||
self.seconds = 0.
|
||||
self.takeovers = 0
|
||||
self._t = None
|
||||
self._status = None
|
||||
|
||||
def update(self, driving: bool):
|
||||
now = time.monotonic()
|
||||
if not driving:
|
||||
self._t = None
|
||||
self._status = None
|
||||
return
|
||||
dt = 0. if self._t is None else min(now - self._t, 0.5)
|
||||
self._t = now
|
||||
self.seconds += dt
|
||||
if self._status not in (None, UIStatus.DISENGAGED) and ui_state.status == UIStatus.DISENGAGED:
|
||||
self.takeovers += 1
|
||||
self._status = ui_state.status
|
||||
d = max(ui_state.sm["carState"].vEgo, 0.) * dt
|
||||
if d <= 0.:
|
||||
return
|
||||
if self.segments and self.segments[-1][0] == ui_state.status:
|
||||
self.segments[-1][1] += d
|
||||
else:
|
||||
self.segments.append([ui_state.status, d])
|
||||
|
||||
def total(self, statuses=None) -> float:
|
||||
return sum(m for s, m in self.segments if statuses is None or s in statuses)
|
||||
|
||||
|
||||
class TripSummary:
|
||||
def __init__(self):
|
||||
self._trip = TripTracker()
|
||||
self._dialog: TripSummaryDialog | None = None
|
||||
self._gear = None
|
||||
self._drove = False
|
||||
gui_app.add_nav_stack_tick(self._tick)
|
||||
|
||||
def _tick(self):
|
||||
gear = ui_state.sm["carState"].gearShifter if ui_state.started else None
|
||||
self._trip.update(gear not in (None, GEAR.park))
|
||||
self._drove |= gear in FORWARD
|
||||
if gear == self._gear:
|
||||
return
|
||||
self._gear = gear
|
||||
|
||||
if gear not in (None, GEAR.park):
|
||||
self._pop()
|
||||
elif gear == GEAR.park and self._drove and ui_state.trip_summary and not ui_state.is_body and self._trip.total() > 0.:
|
||||
self._dialog = TripSummaryDialog(self._trip, gui_app.get_active_widget(), self._pop)
|
||||
gui_app.push_widget(self._dialog)
|
||||
if gear is None:
|
||||
self._trip.reset()
|
||||
if gear in (None, GEAR.park):
|
||||
self._drove = False
|
||||
|
||||
def _pop(self):
|
||||
if self._dialog is not None and gui_app.get_active_widget() is self._dialog:
|
||||
gui_app.pop_widget()
|
||||
self._dialog = None
|
||||
|
||||
|
||||
def _ease(t: float) -> float:
|
||||
t = min(max(t, 0.), 1.)
|
||||
return 1 - (1 - t) ** 3
|
||||
|
||||
|
||||
def _fade(c, a: float) -> rl.Color:
|
||||
r, g, b, al = c if isinstance(c, tuple) else (c.r, c.g, c.b, c.a)
|
||||
return rl.Color(r, g, b, int(al * a))
|
||||
|
||||
|
||||
class TripSummaryDialog(Widget):
|
||||
def __init__(self, trip: TripTracker, below: Widget | None, on_closed):
|
||||
super().__init__()
|
||||
self._below = below
|
||||
self._on_closed = on_closed
|
||||
self._segments = segments = trip.segments
|
||||
total = sum(m for _, m in segments)
|
||||
|
||||
def pct(statuses):
|
||||
return 100 * sum(m for s, m in segments if s in statuses) / total
|
||||
|
||||
dist = total * (CV.MS_TO_KPH if ui_state.is_metric else CV.MS_TO_MPH) / 3600
|
||||
dist_fmt = "{:.1f}" if dist < 9.95 else "{:.0f}"
|
||||
self._stats = [
|
||||
(dist, dist_fmt, "km" if ui_state.is_metric else "mi", "driven"),
|
||||
(pct(LAT + LONG), "{:.0f}", "%", "engaged"),
|
||||
(pct(LAT), "{:.0f}", "%", "lateral"),
|
||||
(pct(LONG), "{:.0f}", "%", "longitudinal"),
|
||||
]
|
||||
mins = round(trip.seconds / 60)
|
||||
self._details = [
|
||||
(f"{mins // 60}h {mins % 60}" if mins >= 60 else f"{mins}", "min"),
|
||||
(f"{trip.takeovers}", "takeover" if trip.takeovers == 1 else "takeovers"),
|
||||
]
|
||||
self._bold = gui_app.font(FontWeight.BOLD)
|
||||
self._semi = gui_app.font(FontWeight.SEMI_BOLD)
|
||||
self._normal = gui_app.font(FontWeight.NORMAL)
|
||||
self._big = gui_app.big_ui()
|
||||
self._shown_t = rl.get_time()
|
||||
self._closing_t: float | None = None
|
||||
self.set_click_callback(self.close)
|
||||
|
||||
def close(self):
|
||||
if self._closing_t is None:
|
||||
self._closing_t = rl.get_time()
|
||||
|
||||
def _render(self, rect: rl.Rectangle):
|
||||
t = rl.get_time() - self._shown_t
|
||||
if self._closing_t is None and t > AUTO_DISMISS:
|
||||
self.close()
|
||||
out = 0. if self._closing_t is None else (rl.get_time() - self._closing_t) / FADE_OUT
|
||||
if out >= 1.:
|
||||
self._on_closed()
|
||||
return
|
||||
bg = 1 - _ease(out)
|
||||
a = _ease(t / FADE_IN) * bg
|
||||
|
||||
if self._big and self._below is not None and bg < 1.:
|
||||
self._below.render(rect)
|
||||
rl.draw_rectangle_rec(rect, _fade(rl.BLACK, bg))
|
||||
|
||||
k = rect.height / 1080 * (1.0 if self._big else 1.22)
|
||||
pad = 120 * k
|
||||
x, w = rect.x + pad, rect.width - 2 * pad
|
||||
y = rect.y + (rect.height - 850 * k) / 2
|
||||
|
||||
rl.draw_text_ex(self._bold, "trip summary", rl.Vector2(x, y), int(150 * k), 0, _fade(rl.WHITE, a))
|
||||
y += 260 * k
|
||||
|
||||
col_w = w / len(self._stats)
|
||||
for i, (target, fmt, unit, label) in enumerate(self._stats):
|
||||
cx = x + col_w * (i + 0.5)
|
||||
v = measure_text_cached(self._bold, fmt.format(target), int(170 * k))
|
||||
u = measure_text_cached(self._semi, unit, int(80 * k))
|
||||
vx = cx - (v.x + 10 * k + u.x) / 2
|
||||
rl.draw_text_ex(self._bold, fmt.format(target), rl.Vector2(vx, y), int(170 * k), 0, _fade(rl.WHITE, a))
|
||||
rl.draw_text_ex(self._semi, unit, rl.Vector2(vx + v.x + 10 * k, y + 75 * k), int(80 * k), 0, _fade(rl.WHITE, a))
|
||||
lb = measure_text_cached(self._normal, label, int(70 * k))
|
||||
rl.draw_text_ex(self._normal, label, rl.Vector2(cx - lb.x / 2, y + 180 * k), int(70 * k), 0, _fade(rl.Color(200, 200, 200, 255), a))
|
||||
y += 330 * k
|
||||
|
||||
bar = rl.Rectangle(x, y, w, 90 * k)
|
||||
total = sum(m for _, m in self._segments)
|
||||
sx = bar.x
|
||||
for status, m in self._segments:
|
||||
sw = bar.width * m / total
|
||||
rl.draw_rectangle_rec(rl.Rectangle(sx, bar.y, min(sw + 1, bar.x + bar.width - sx), bar.height), _fade(BORDER_COLORS[status], a))
|
||||
sx += sw
|
||||
rl.draw_rectangle_rounded_lines_ex(bar, 1.0, 20, 30 * k, _fade(rl.BLACK, a))
|
||||
|
||||
y += (90 + 70) * k
|
||||
|
||||
size = int(90 * k)
|
||||
parts = []
|
||||
for i, (value, unit) in enumerate(self._details):
|
||||
if i:
|
||||
parts.append((" ", self._normal, None))
|
||||
parts += [(value, self._bold, rl.WHITE), (" " + unit, self._normal, rl.Color(170, 170, 170, 255))]
|
||||
widths = [measure_text_cached(f, t, size).x for t, f, _ in parts]
|
||||
lx = x + (w - sum(widths)) / 2
|
||||
for (text, font, color), tw in zip(parts, widths, strict=True):
|
||||
if color is None:
|
||||
rl.draw_circle(int(lx + tw / 2), int(y + size * 0.6), 12 * k, _fade(rl.Color(110, 110, 110, 255), a))
|
||||
else:
|
||||
rl.draw_text_ex(font, text, rl.Vector2(lx, y), size, 0, _fade(color, a))
|
||||
lx += tw
|
||||
@@ -0,0 +1,86 @@
|
||||
"""
|
||||
Copyright (c) 2021-, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import time
|
||||
|
||||
from openpilot.selfdrive.ui.mici.widgets.button import BigButton, BigParamControl
|
||||
from openpilot.selfdrive.ui.mici.widgets.dialog import BigConfirmationDialog
|
||||
from openpilot.selfdrive.ui.sunnypilot.mici.layouts.connect_phone import start_connect_phone
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from openpilot.sunnypilot.system.ble import grants
|
||||
from openpilot.sunnypilot.system.connect_phone import display_name, write_request
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.widgets.scroller import NavScroller
|
||||
|
||||
POLL_SECONDS = 1.0
|
||||
|
||||
|
||||
def _phone_count(n: int) -> str:
|
||||
return tr("none connected") if n == 0 else tr("{} connected").format(n)
|
||||
|
||||
|
||||
class BluetoothLayoutMici(NavScroller):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self._bluetooth_on = ui_state.params.get_bool("BluetoothAllowed")
|
||||
|
||||
def bluetooth_callback(checked: bool):
|
||||
self._bluetooth_on = checked
|
||||
|
||||
self._bluetooth_toggle = BigParamControl(tr("bluetooth"), "BluetoothAllowed", toggle_callback=bluetooth_callback)
|
||||
|
||||
self._connect_phone_btn = BigButton(tr("connect phone"), display_name(ui_state.params))
|
||||
self._connect_phone_btn.set_click_callback(start_connect_phone)
|
||||
self._connect_phone_btn.set_enabled(lambda: self._bluetooth_on)
|
||||
|
||||
self._phones_page = ConnectedPhonesMici()
|
||||
self._phones_btn = BigButton(tr("phones"), "")
|
||||
self._phones_btn.set_click_callback(lambda: gui_app.push_widget(self._phones_page))
|
||||
self._phones_btn.set_visible(lambda: self._bluetooth_on)
|
||||
self._last_poll = float("-inf")
|
||||
|
||||
self._scroller.add_widgets([self._bluetooth_toggle, self._connect_phone_btn, self._phones_btn])
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
now = time.monotonic()
|
||||
if now - self._last_poll >= POLL_SECONDS:
|
||||
self._last_poll = now
|
||||
self._phones_btn.set_value(_phone_count(len(grants.load(ui_state.params))))
|
||||
|
||||
|
||||
class ConnectedPhonesMici(NavScroller):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._phone_items: list[BigButton] = []
|
||||
self._grants: list[dict] | None = None
|
||||
self._last_poll = float("-inf")
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
now = time.monotonic()
|
||||
if now - self._last_poll < POLL_SECONDS:
|
||||
return
|
||||
self._last_poll = now
|
||||
phones = grants.load(ui_state.params)
|
||||
if phones != self._grants:
|
||||
self._grants = phones
|
||||
for item in self._phone_items:
|
||||
self._scroller._items.remove(item)
|
||||
self._phone_items = [self._phone_item(phone) for phone in phones] or [BigButton(tr("no phones connected yet"), "")]
|
||||
self._scroller.add_widgets(self._phone_items)
|
||||
|
||||
def _phone_item(self, phone: dict) -> BigButton:
|
||||
spki = phone["spki"]
|
||||
item = BigButton(phone["name"], tr("remove"), scroll=True)
|
||||
item.set_click_callback(lambda: self._remove(spki))
|
||||
return item
|
||||
|
||||
def _remove(self, spki: str) -> None:
|
||||
icon = gui_app.texture("icons_mici/settings/network/new/trash.png", 54, 64)
|
||||
gui_app.push_widget(BigConfirmationDialog(tr("slide to remove"), icon, lambda: write_request(ui_state.params, "remove", phone=spki), red=True))
|
||||
@@ -0,0 +1,202 @@
|
||||
"""
|
||||
Copyright (c) 2021-, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import time
|
||||
|
||||
import pyray as rl
|
||||
|
||||
from openpilot.common.qrcode import make_texture
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.selfdrive.ui.mici.widgets.dialog import BigConfirmationCircleButton, BigDialog
|
||||
from openpilot.selfdrive.ui.ui_state import device, ui_state
|
||||
from openpilot.sunnypilot.system.connect_phone import WINDOW_SECONDS, format_code, read_window, write_request
|
||||
from openpilot.system.ui.lib.application import FontWeight, gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.mici_setup import GreyBigButton
|
||||
from openpilot.system.ui.widgets.label import UnifiedLabel
|
||||
from openpilot.system.ui.widgets.nav_widget import NavWidget
|
||||
from openpilot.system.ui.widgets.scroller import NavScroller
|
||||
|
||||
POLL_SECONDS = 0.25
|
||||
START_TIMEOUT = 15 # seconds from open to the first window for this request
|
||||
LOST_SECONDS = 3 # the daemon restarted mid-window and no longer reports our seq
|
||||
INTERACTIVE_TIMEOUT = WINDOW_SECONDS + 10 # the offroad idle timeout would pop the screen mid-window
|
||||
|
||||
|
||||
def _closed_message(reason: str) -> str | None:
|
||||
messages = {
|
||||
"granted": tr("phone connected"),
|
||||
"denied": tr("phone not connected"),
|
||||
"no_answer": tr("allow not tapped in time"),
|
||||
"phone_left": tr("phone disconnected"),
|
||||
"wrong_codes": tr("too many wrong codes"),
|
||||
"limit": tr("8 phones already connected"),
|
||||
"timeout": tr("connect timed out"),
|
||||
"bluetooth_off": tr("turn on bluetooth"),
|
||||
"no_key": tr("device key unavailable"),
|
||||
}
|
||||
return messages.get(reason)
|
||||
|
||||
|
||||
def start_connect_phone() -> None:
|
||||
gui_app.push_widget(ConnectPhoneDialog())
|
||||
|
||||
|
||||
class ConnectPhoneDialog(NavWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._params = ui_state.params
|
||||
self._seq = write_request(self._params, "open")
|
||||
self._opened_at = time.monotonic()
|
||||
self._next_poll = 0.0
|
||||
self._was_open = False
|
||||
self._lost_since: float | None = None
|
||||
self._window: dict | None = None
|
||||
self._closing = False
|
||||
self._check_shown_for: float | None = None
|
||||
self._qr_source = ""
|
||||
self._qr_texture: rl.Texture | None = None
|
||||
|
||||
self._title = UnifiedLabel(tr("connect phone"), font_size=48, font_weight=FontWeight.BOLD,
|
||||
text_color=rl.Color(255, 255, 255, int(255 * 0.9)), line_height=0.8)
|
||||
self._status = UnifiedLabel("", font_size=36, font_weight=FontWeight.ROMAN,
|
||||
text_color=rl.Color(255, 255, 255, int(255 * 0.65)))
|
||||
self._code = UnifiedLabel("", font_size=48, font_weight=FontWeight.BOLD,
|
||||
text_color=rl.Color(255, 255, 255, int(255 * 0.9)))
|
||||
|
||||
self.set_back_callback(self._cancel)
|
||||
|
||||
def show_event(self):
|
||||
super().show_event()
|
||||
device.set_override_interactive_timeout(INTERACTIVE_TIMEOUT)
|
||||
|
||||
def hide_event(self):
|
||||
super().hide_event()
|
||||
device.set_override_interactive_timeout(None)
|
||||
if not self._closing:
|
||||
self._cancel()
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
if self._closing:
|
||||
return
|
||||
now = time.monotonic()
|
||||
if now < self._next_poll:
|
||||
return
|
||||
self._next_poll = now + POLL_SECONDS
|
||||
|
||||
window = read_window(self._params)
|
||||
# the request seq guards against a window left over from an earlier open
|
||||
if window is None or window.get("seq") != self._seq:
|
||||
self._window = None
|
||||
if self._was_open:
|
||||
# a daemon restart writes seq 0 and never reports our window again
|
||||
if self._lost_since is None:
|
||||
self._lost_since = now
|
||||
if now - self._lost_since > LOST_SECONDS:
|
||||
self._finish(None)
|
||||
elif now - self._opened_at > START_TIMEOUT:
|
||||
self._cancel()
|
||||
self._finish(tr("bluetooth did not start"))
|
||||
return
|
||||
self._lost_since = None
|
||||
self._window = window
|
||||
prompt = window.get("prompt") or {}
|
||||
if prompt.get("step") == "allow" and self._check_shown_for != prompt.get("until"):
|
||||
self._check_shown_for = prompt.get("until")
|
||||
gui_app.push_widget(ConnectPhoneCheckDialog(prompt.get("check", ""), self._params))
|
||||
if window.get("state") == "closed":
|
||||
self._finish(_closed_message(window.get("reason", "")))
|
||||
elif window.get("state") == "open":
|
||||
self._was_open = True
|
||||
if not window.get("held") and now >= window["deadline"]:
|
||||
self._finish(_closed_message("timeout"))
|
||||
|
||||
def _cancel(self) -> None:
|
||||
if not self._closing:
|
||||
self._closing = True
|
||||
write_request(self._params, "cancel")
|
||||
|
||||
def _finish(self, message: str | None) -> None:
|
||||
self._closing = True
|
||||
gui_app.pop_widgets_to(self, instant=True)
|
||||
if message is None:
|
||||
self.dismiss(lambda: None)
|
||||
else:
|
||||
self.dismiss(lambda: gui_app.push_widget(BigDialog(message, "")))
|
||||
|
||||
def _render(self, _):
|
||||
window = self._window
|
||||
held = window is not None and window.get("held", False)
|
||||
show_code = window is not None and window.get("state") == "open" and not held
|
||||
|
||||
if show_code:
|
||||
if window["qr"] != self._qr_source:
|
||||
self._load_qr(window["qr"])
|
||||
self._draw_qr()
|
||||
|
||||
label_x = self._rect.x + 8 + self._rect.height + 24 if show_code else self._rect.x + 20
|
||||
max_width = int(self._rect.x + self._rect.width - label_x)
|
||||
y = self._rect.y + 16
|
||||
self._title.set_text(tr("scan or type") if show_code else tr("connect phone"))
|
||||
self._title.set_max_width(max_width)
|
||||
self._title.set_position(label_x, y)
|
||||
self._title.render()
|
||||
y += self._title.get_content_height(max_width) + 16
|
||||
|
||||
if show_code:
|
||||
remaining = max(0, int(window["deadline"] - time.monotonic()))
|
||||
self._code.set_text(format_code(int(window["code"])))
|
||||
self._code.set_max_width(max_width)
|
||||
self._code.set_position(label_x, y)
|
||||
self._code.render()
|
||||
y += self._code.get_content_height(max_width) + 12
|
||||
self._status.set_text(f"{tr('expires in')} {remaining // 60}:{remaining % 60:02d}")
|
||||
elif held:
|
||||
self._status.set_text(tr("connecting phone"))
|
||||
else:
|
||||
self._status.set_text("" if self._closing else tr("starting bluetooth"))
|
||||
self._status._shimmer = not show_code and not self._closing
|
||||
self._status.set_max_width(max_width)
|
||||
self._status.set_position(label_x, y)
|
||||
self._status.render()
|
||||
|
||||
def _load_qr(self, text: str) -> None:
|
||||
self._unload_qr()
|
||||
self._qr_source = text
|
||||
try:
|
||||
self._qr_texture = make_texture(text, inverted=True)
|
||||
except Exception:
|
||||
cloudlog.exception("connect phone QR generation failed")
|
||||
self._qr_texture = None
|
||||
|
||||
def _draw_qr(self) -> None:
|
||||
if self._qr_texture is None:
|
||||
return
|
||||
scale = self._rect.height / self._qr_texture.height
|
||||
rl.draw_texture_ex(self._qr_texture, rl.Vector2(round(self._rect.x + 8), round(self._rect.y)), 0.0, scale, rl.WHITE)
|
||||
|
||||
def _unload_qr(self) -> None:
|
||||
if self._qr_texture and self._qr_texture.id != 0:
|
||||
rl.unload_texture(self._qr_texture)
|
||||
self._qr_texture = None
|
||||
|
||||
def __del__(self):
|
||||
self._unload_qr()
|
||||
|
||||
|
||||
class ConnectPhoneCheckDialog(NavScroller):
|
||||
def __init__(self, check: str, params):
|
||||
super().__init__()
|
||||
self._params = params
|
||||
allow = BigConfirmationCircleButton(tr("allow\nthis phone"), gui_app.texture("icons_mici/setup/driver_monitoring/dm_check.png", 64, 64),
|
||||
lambda: self._answer("allow"))
|
||||
deny = BigConfirmationCircleButton(tr("deny"), gui_app.texture("icons_mici/setup/cancel.png", 64, 64), lambda: self._answer("deny"))
|
||||
self._scroller.add_widgets([GreyBigButton(check, tr("same code on your phone?"), gui_app.texture("icons_mici/setup/green_info.png", 64, 64)),
|
||||
allow, deny])
|
||||
|
||||
def _answer(self, action: str) -> None:
|
||||
self.dismiss(lambda: write_request(self._params, action))
|
||||
@@ -5,19 +5,38 @@ This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import math
|
||||
import time
|
||||
|
||||
import raylib_nb as rl
|
||||
|
||||
from openpilot.selfdrive.ui.mici.layouts.home import MiciHomeLayout
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state, ChestnutState
|
||||
from openpilot.sunnypilot.system.connect_phone import phone_indicator, read_status
|
||||
from openpilot.system.ui.lib.application import FontWeight
|
||||
from openpilot.system.ui.widgets.icon_widget import IconWidget
|
||||
from openpilot.system.ui.widgets.label import UnifiedLabel
|
||||
|
||||
BT_POLL_SECONDS = 1.0
|
||||
BT_WAITING_OPACITY = 0.35
|
||||
|
||||
|
||||
class MiciHomeLayoutSP(MiciHomeLayout):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._openpilot_label = UnifiedLabel("sunnypilot", font_size=88, font_weight=FontWeight.AUDIOWIDE, max_width=480, wrap_text=False)
|
||||
self._bluetooth_icon = IconWidget("../../sunnypilot/selfdrive/assets/offroad/icon_bluetooth.png", (40, 40))
|
||||
self._bluetooth_icon.set_visible(False)
|
||||
self._bt_polled_at = float("-inf")
|
||||
self._status_bar_layout.add_widget(self._bluetooth_icon)
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
now = time.monotonic()
|
||||
if now - self._bt_polled_at >= BT_POLL_SECONDS:
|
||||
self._bt_polled_at = now
|
||||
state = phone_indicator(read_status(ui_state.params))
|
||||
self._bluetooth_icon.set_visible(state != "hidden")
|
||||
self._bluetooth_icon.set_opacity(1.0 if state == "connected" else BT_WAITING_OPACITY)
|
||||
|
||||
def _set_chestnut_visibility(self):
|
||||
usb_connected = ui_state.usb_connected
|
||||
|
||||
@@ -11,6 +11,7 @@ from openpilot.selfdrive.ui.mici.widgets.button import BigCircleButton
|
||||
from openpilot.selfdrive.ui.mici.widgets.dialog import BigConfirmationDialog, BigDialog
|
||||
from openpilot.selfdrive.ui.sunnypilot.mici.layouts.sunnylink import SunnylinkLayoutMici
|
||||
from openpilot.selfdrive.ui.sunnypilot.mici.layouts.models import ModelsLayoutMici
|
||||
from openpilot.selfdrive.ui.sunnypilot.mici.layouts.bluetooth import BluetoothLayoutMici
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from openpilot.system.ui.lib.application import gui_app, FontWeight
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
@@ -50,6 +51,12 @@ class SettingsLayoutSP(OP.SettingsLayout):
|
||||
models_btn = SettingsBigButton(tr("models"), "", gui_app.texture("../../sunnypilot/selfdrive/assets/offroad/icon_models.png", ICON_SIZE, ICON_SIZE))
|
||||
models_btn.set_click_callback(lambda: gui_app.push_widget(models_panel))
|
||||
|
||||
network_btn = self._scroller._items[1]
|
||||
bluetooth_panel = BluetoothLayoutMici()
|
||||
bluetooth_btn = SettingsBigButton(tr("bluetooth"), "",
|
||||
gui_app.texture("../../sunnypilot/selfdrive/assets/offroad/icon_bluetooth.png", ICON_SIZE, ICON_SIZE))
|
||||
bluetooth_btn.set_click_callback(lambda: gui_app.push_widget(bluetooth_panel))
|
||||
|
||||
# onroad: enable button sits at the front (left of toggles)
|
||||
self._enable_offroad_btn_onroad = BigCircleButton(self.icon_offroad_enable, red=True)
|
||||
self._enable_offroad_btn_onroad.set_click_callback(lambda: self._handle_always_offroad(True))
|
||||
@@ -68,6 +75,7 @@ class SettingsLayoutSP(OP.SettingsLayout):
|
||||
|
||||
items.insert(1, models_btn)
|
||||
items.insert(5, sunnylink_btn)
|
||||
items.insert(items.index(network_btn) + 1, bluetooth_btn)
|
||||
|
||||
# front slots (only one ever visible at a time): exit-always-offroad, then enable-onroad
|
||||
items.insert(0, self._enable_offroad_btn_onroad)
|
||||
|
||||
@@ -4,7 +4,6 @@ Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
from collections.abc import Callable
|
||||
from enum import Enum
|
||||
|
||||
from openpilot.cereal import messaging, log, custom
|
||||
@@ -30,13 +29,6 @@ class OnroadTimerStatus(Enum):
|
||||
|
||||
|
||||
class UIStateSP:
|
||||
CP: "car.CarParams | None"
|
||||
has_longitudinal_control: bool
|
||||
chestnut_present: bool
|
||||
chestnut_active: bool | None
|
||||
chestnut_loading: bool
|
||||
is_offroad: Callable[[], bool]
|
||||
|
||||
def __init__(self):
|
||||
self.params = Params()
|
||||
self.CP_SP: custom.CarParamsSP | None = None
|
||||
@@ -56,6 +48,7 @@ class UIStateSP:
|
||||
self.model_runner_tinygrad: bool = False
|
||||
self.active_runner_tinygrad: bool = False
|
||||
self.blindspot: bool = False
|
||||
self.trip_summary: bool = True
|
||||
self.chevron_metrics = None
|
||||
self.custom_interactive_timeout: int = 0
|
||||
self.developer_ui = None
|
||||
@@ -193,6 +186,7 @@ class UIStateSP:
|
||||
self.standstill_timer = self.params.get_bool("StandstillTimer")
|
||||
self.sunnylink_enabled = self.params.get_bool("SunnylinkEnabled")
|
||||
self.torque_bar = self.params.get_bool("TorqueBar")
|
||||
self.trip_summary = self.params.get_bool("TripSummary")
|
||||
self.enforce_torque_control = self.params.get_bool("EnforceTorqueControl")
|
||||
self.custom_torque_params = self.params.get_bool("CustomTorqueParams")
|
||||
self.torque_override_enabled = self.params.get_bool("TorqueParamsOverrideEnabled")
|
||||
@@ -261,7 +255,7 @@ class DeviceSP:
|
||||
def __init__(self):
|
||||
self._blocked_by_screensaver: bool = False
|
||||
|
||||
def _set_awake(self, on: bool, _ui_state):
|
||||
def _set_awake(self, on: bool, _ui_state=None):
|
||||
self._blocked_by_screensaver = False
|
||||
|
||||
if not on and _ui_state.screensaver_enabled:
|
||||
|
||||
@@ -74,7 +74,8 @@ def run_replay(variant: LayoutVariant) -> None:
|
||||
send_fn: Callable | None = None
|
||||
frame = 0
|
||||
# Override raylib timing functions to return deterministic values based on frame count instead of real time
|
||||
vars(rl).update(get_frame_time=lambda: 1.0 / FPS, get_time=lambda: frame / FPS)
|
||||
rl.get_frame_time = lambda: 1.0 / FPS
|
||||
rl.get_time = lambda: frame / FPS
|
||||
|
||||
# Main loop to replay events and render frames
|
||||
with tqdm(total=script[-1][0] + 1, desc="Replaying", unit="frame", disable=bool(os.getenv("CI"))) as pbar:
|
||||
|
||||
@@ -50,7 +50,7 @@ def patch_submaster(message_chunks):
|
||||
sm.recv_frame[service] = sm.frame
|
||||
sm.valid[service] = True
|
||||
sm.frame += 1
|
||||
ui_state.sm.update = mock_update
|
||||
ui_state.sm.update = mock_update # ty: ignore[invalid-assignment] # profiling hook
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -117,7 +117,6 @@ def parse_po(path: str | Path) -> tuple[POEntry | None, list[POEntry]]:
|
||||
|
||||
m = re.match(r'msgstr\[(\d+)]\s+(.*)', stripped)
|
||||
if m:
|
||||
assert cur is not None
|
||||
plural_idx = int(m.group(1))
|
||||
cur.msgstr_plural[plural_idx] = _parse_quoted(m.group(2))
|
||||
cur_field = 'msgstr_plural'
|
||||
@@ -131,7 +130,6 @@ def parse_po(path: str | Path) -> tuple[POEntry | None, list[POEntry]]:
|
||||
continue
|
||||
|
||||
if stripped.startswith('"'):
|
||||
assert cur is not None
|
||||
val = _parse_quoted(stripped)
|
||||
if cur_field == 'msgid':
|
||||
cur.msgid += val
|
||||
@@ -303,7 +301,7 @@ def init_po(pot_path: str | Path, po_path: str | Path, language: str) -> None:
|
||||
_, entries = parse_po(pot_path)
|
||||
plural_forms = PLURAL_FORMS.get(language, 'nplurals=2; plural=(n != 1);')
|
||||
|
||||
nplurals = int(re.findall(r'nplurals=(\d+)', plural_forms)[0])
|
||||
nplurals = int(re.search(r'nplurals=(\d+)', plural_forms).group(1))
|
||||
for e in entries:
|
||||
if e.is_plural:
|
||||
e.msgstr_plural = dict.fromkeys(range(nplurals), '')
|
||||
|
||||
@@ -8,10 +8,10 @@ import numpy as np
|
||||
|
||||
from openpilot.common.filter_simple import FirstOrderFilter
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.sunnypilot.modeld_v2.constants import ModelConstants, Plan
|
||||
from openpilot.sunnypilot.modeld_v2.constants import ModelConstants
|
||||
|
||||
LANE_WIDTH_DEFAULT = 3.6 # m
|
||||
LANE_WIDTH_CLIP = (2.4, 4.5) # m
|
||||
LANE_WIDTH_CLIP = (2.8, 4.5) # m
|
||||
LOOKAHEAD_TIME = 1.5 # s
|
||||
MIN_LOOKAHEAD = 10.0 # m
|
||||
MIN_SPEED = 5.0 # m/s
|
||||
@@ -19,11 +19,6 @@ LINE_STD = (0.2, 0.6)
|
||||
POINT_STD = 0.1
|
||||
YIELD = (0.2, 0.45)
|
||||
X_IDXS = np.array(ModelConstants.X_IDXS)
|
||||
JUMP = 0.5
|
||||
JUMP_TAU = 0.5
|
||||
JUMP_ACCEPT = 3.0
|
||||
WIDEN = 0.4
|
||||
YAW_RATE = Plan.ORIENTATION_RATE.start + 2 # matched .991 correlation to actual car
|
||||
|
||||
|
||||
class Blendful:
|
||||
@@ -41,8 +36,7 @@ class Blendful:
|
||||
self.l_prob = 0.0
|
||||
self.r_prob = 0.0
|
||||
self.model_curvature = 0.0
|
||||
self.ref = None
|
||||
self.jumped = np.zeros(2)
|
||||
self.smooth = 0.0 # smooths the correction target below .53 lat accel
|
||||
self.curvature = 0.0
|
||||
|
||||
def update(self, model_output: dict[str, np.ndarray], v_ego: float, active: bool, model_curvature: float, enabled: bool = True) -> float:
|
||||
@@ -58,8 +52,8 @@ class Blendful:
|
||||
self.usual_offset.initialized = False
|
||||
self.lane_width.initialized = False
|
||||
self.going_around = False
|
||||
self.ref = None
|
||||
target = 0.0 if fading else self._target(model_output, v_ego, model_curvature)
|
||||
target = self.smooth = self.smooth + (target - self.smooth) * DT_MDL / (DT_MDL + np.interp(abs(model_curvature) * v_ego ** 2, [0.18, 0.53], [0.5, 0.0]))
|
||||
build = 0.5 / max(v_ego, 1.0) ** 2 * DT_MDL # jerk over 1 second
|
||||
release = (0.5 if fading else 2.0) / max(v_ego, 1.0) ** 2 * DT_MDL # lets go fast, but past zero it builds like any other pull
|
||||
k = self.curvature
|
||||
@@ -69,10 +63,6 @@ class Blendful:
|
||||
def _target(self, model_output: dict[str, np.ndarray], v_ego: float, model_curvature: float) -> float:
|
||||
lookahead = max(v_ego * LOOKAHEAD_TIME, MIN_LOOKAHEAD)
|
||||
lines = model_output['lane_lines'][0, :, :, 0]
|
||||
plan = model_output['plan'][0]
|
||||
self._jumps(lines[1:3], v_ego, plan[0, YAW_RATE] if plan.shape[-1] > YAW_RATE else model_curvature * v_ego,
|
||||
np.interp(abs(model_curvature) * v_ego ** 2, [0.18, 0.53], [JUMP_TAU, 0.0]), lookahead)
|
||||
held = bool(np.any((self.jumped > 0) & (self.jumped < JUMP_ACCEPT)))
|
||||
stds = model_output['lane_lines_stds'][0, :, :, 0]
|
||||
|
||||
lone_weight = np.interp(abs(model_curvature) * v_ego ** 2, [0.18, 0.53], [0.5, 1.0]) # 0.5 on straights, 1.0 in curves
|
||||
@@ -93,8 +83,6 @@ class Blendful:
|
||||
lane_trust = min(l_prob, r_prob)
|
||||
else:
|
||||
lane_trust = l_prob + r_prob - l_prob * r_prob
|
||||
if held or (l_prob * r_prob > 0.5 and np.interp(lookahead, X_IDXS, lines[2] - lines[1]) > self.lane_width.x + WIDEN):
|
||||
lane_trust = 0.0
|
||||
if lone_weight > 0.5 and lane_trust < self.line_trust:
|
||||
lane_trust = self.line_trust + (lane_trust - self.line_trust) * DT_MDL / (lone_weight - 0.5 + DT_MDL)
|
||||
self.line_trust = lane_trust
|
||||
@@ -108,7 +96,7 @@ class Blendful:
|
||||
win = (X_IDXS >= 0.5 * lookahead) & (X_IDXS <= 1.5 * lookahead)
|
||||
x = X_IDXS[win]
|
||||
half_width = self.lane_width.x / 2
|
||||
if l_prob * r_prob > 0.5 and not held:
|
||||
if l_prob * r_prob > 0.5:
|
||||
width = np.interp(lookahead, X_IDXS, lines[2]) - np.interp(lookahead, X_IDXS, lines[1])
|
||||
self.lane_width.update(float(np.clip(width, *LANE_WIDTH_CLIP)))
|
||||
half_width = np.clip(lines[2, win] - lines[1, win], *LANE_WIDTH_CLIP) / 2
|
||||
@@ -155,14 +143,3 @@ class Blendful:
|
||||
self.trust = lane_trust if lane_trust < self.trust else self.trust + (lane_trust - self.trust) * DT_MDL / (1.5 + DT_MDL)
|
||||
self.dk = dk
|
||||
return float(self.trust * dk)
|
||||
|
||||
def _jumps(self, raw: np.ndarray, v_ego: float, yaw_rate: float, tau: float, lookahead: float) -> None:
|
||||
if self.ref is None:
|
||||
self.ref, self.jumped = raw.copy(), np.zeros(2)
|
||||
return
|
||||
ref = np.array([np.interp(X_IDXS + v_ego * DT_MDL, X_IDXS, line) for line in self.ref]) - yaw_rate * DT_MDL * X_IDXS
|
||||
off = np.abs([np.interp(lookahead, X_IDXS, d) for d in raw - ref]) > JUMP
|
||||
self.jumped = np.where(off & ~off[::-1], self.jumped + DT_MDL, 0.0)
|
||||
self.ref = ref + (raw - ref) * DT_MDL / (DT_MDL + tau)
|
||||
accept = (self.jumped >= JUMP_ACCEPT) | off.all()
|
||||
self.ref[accept] = raw[accept]
|
||||
|
||||
@@ -123,9 +123,7 @@ def get_policy_npy_shapes(input_shapes: dict, is_supercombo: bool = False) -> tu
|
||||
|
||||
|
||||
def host_view(tensor: Tensor) -> np.ndarray: # QCOM -> CPU round trip of tfm takes 5ms longer than host memory view
|
||||
mv = tensor._buffer()._host_mv()
|
||||
assert mv is not None
|
||||
return np.frombuffer(mv, dtype=np.float32).reshape(tensor.shape)
|
||||
return np.frombuffer(tensor._buffer()._host_mv(), dtype=np.float32).reshape(tensor.shape)
|
||||
|
||||
|
||||
def generate_queues_and_npy(input_shapes: dict, frame_skip: int, device: str = Device.DEFAULT,
|
||||
@@ -219,7 +217,6 @@ def make_run_policy(vision_runner, policy_runners: list, features_slice: slice,
|
||||
npy_shapes, npy_sizes = get_policy_npy_shapes(input_shapes, is_supercombo=is_supercombo)
|
||||
|
||||
def run_policy(warped, img_q, big_img_q, feat_q, desire_q=None, packed_npy_inputs=None, **kwargs):
|
||||
assert packed_npy_inputs is not None
|
||||
packed_npy_inputs_dev = packed_npy_inputs.to(Device.DEFAULT)
|
||||
warped_dev = warped.to(Device.DEFAULT)
|
||||
Tensor.realize(packed_npy_inputs_dev, warped_dev)
|
||||
@@ -390,7 +387,7 @@ if __name__ == "__main__":
|
||||
|
||||
args = parser.parse_args()
|
||||
model_w, model_h = args.model_size
|
||||
output_data: dict[Any, Any] = {}
|
||||
output_data = {}
|
||||
|
||||
is_unified_supercombo = False
|
||||
if args.model_type == 'supercombo':
|
||||
|
||||
@@ -7,7 +7,6 @@ See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import argparse
|
||||
import dataclasses
|
||||
import importlib
|
||||
import inspect
|
||||
import itertools
|
||||
import mmap
|
||||
@@ -15,7 +14,6 @@ import os
|
||||
import re
|
||||
import struct
|
||||
import tempfile
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
from openpilot.sunnypilot.modeld_v2.helpers import ALIGNMENT, Blob, PlainJit, flatten, patch_fetch_fw, write_bundle
|
||||
@@ -141,13 +139,11 @@ def _elf(image: bytes, rodata: int, entry: int) -> bytes:
|
||||
|
||||
|
||||
def lower_and_compile(linear):
|
||||
for module in ("tinygrad.codegen.compile", "tinygrad.engine.realize"): # moved to codegen in newer tinygrad
|
||||
try:
|
||||
compile_fn = importlib.import_module(module).lower_and_compile
|
||||
except (ImportError, AttributeError):
|
||||
continue
|
||||
return compile_fn(linear)
|
||||
raise ImportError("tinygrad has no lower_and_compile")
|
||||
try:
|
||||
from tinygrad.codegen.compile import lower_and_compile
|
||||
except ImportError:
|
||||
from tinygrad.engine.realize import lower_and_compile
|
||||
return lower_and_compile(linear)
|
||||
|
||||
|
||||
def submit_kernels(jit) -> tuple:
|
||||
@@ -257,7 +253,7 @@ def main():
|
||||
|
||||
if not os.getenv("MOCKUSB_SOCKET"):
|
||||
plain = PlainJit(*part)
|
||||
replay: dict[str, Any] = {path[0]: Tensor(array, device=device).realize() for path, array, device in frame["inputs"] if len(path) == 1}
|
||||
replay = {path[0]: Tensor(array, device=device).realize() for path, array, device in frame["inputs"] if len(path) == 1}
|
||||
replay["output_buffers"] = {path[1]: Tensor(array, device=device).realize() for path, array, device in frame["inputs"] if len(path) == 2}
|
||||
flatten(plain(**replay))
|
||||
for index, (got, expected) in enumerate(zip([t.numpy() for t in replay["output_buffers"].values()], frame["outputs"], strict=True)):
|
||||
|
||||
@@ -20,7 +20,6 @@ import mmap
|
||||
import os
|
||||
import pickle
|
||||
import struct
|
||||
from typing import Any
|
||||
|
||||
MAGIC = b"SPTGPLN1"
|
||||
ALIGNMENT = 256
|
||||
@@ -335,13 +334,11 @@ class PlainJit(_Jit):
|
||||
_dtype(spec["dtype"])) for slot, spec in inputs.items()}
|
||||
input_uops = tuple(stand_ins.get(slot, next(iter(stand_ins.values()), None)) for slot in range(max(stand_ins, default=-1) + 1))
|
||||
takes_inputs = "input_uops" in inspect.signature(jit.compile_linear).parameters
|
||||
compile_kwargs: dict[str, Any] = {"input_uops": input_uops} if takes_inputs else {}
|
||||
linear = jit.compile_linear(UOp(Ops.LINEAR, src=tuple(calls)), beam=0, cache=False, **compile_kwargs)
|
||||
linear = jit.compile_linear(UOp(Ops.LINEAR, src=tuple(calls)), beam=0, cache=False, **({"input_uops": input_uops} if takes_inputs else {}))
|
||||
|
||||
returned = [Tensor(argument(t)).reshape(tuple(t["shape"])) for t in header["returns"]["tensors"]]
|
||||
ret = {"NoneType": None, "Tensor": returned[0] if returned else None, "tuple": tuple(returned), "list": returned}[header["returns"]["kind"]]
|
||||
captured_args: tuple[Any, ...] = (ret, linear, header["input_names"], []) if takes_inputs else (ret, linear, (), header["input_names"], [], {})
|
||||
captured = jit.CapturedJit(*captured_args)
|
||||
captured = jit.CapturedJit(ret, linear, header["input_names"], []) if takes_inputs else jit.CapturedJit(ret, linear, (), header["input_names"], [], {})
|
||||
super().__init__(captured, header["input_names"], buffers)
|
||||
|
||||
if not verify or not (check := header.get("check")):
|
||||
|
||||
@@ -29,10 +29,6 @@ def input_view(buffer: Buffer, shape: tuple[int, ...], dtype: DType, offset: int
|
||||
|
||||
|
||||
class BaseModelAdapter:
|
||||
frame_copy_size: int
|
||||
numpy_inputs: dict[str, np.ndarray]
|
||||
_vision_input_names: list[str]
|
||||
|
||||
def __init__(self, jits, cam_w, cam_h, model_device, queue_device, warp_device, chestnut=False):
|
||||
self.jits = jits
|
||||
self.DEV = model_device
|
||||
@@ -189,7 +185,7 @@ class NativeTinygradAdapter(BaseModelAdapter):
|
||||
self.outputs = {name: Tensor(np.zeros(shape, dtype=dtype), device=device).realize() for name, (shape, dtype, device) in self.jits['output_specs'].items()}
|
||||
for name, next_name in self.state_pairs.items():
|
||||
state = self.input_queues[name]
|
||||
self.outputs[next_name] = input_view(state._buffer(), self.input_shapes[name][0], state.dtype, 0)
|
||||
self.outputs[next_name] = input_view(state._buffer(), state.shape, state.dtype, 0)
|
||||
|
||||
def copy_frames(self, bufs):
|
||||
for i, key in enumerate(self._vision_input_names):
|
||||
|
||||
@@ -19,14 +19,14 @@ from openpilot.sunnypilot.modeld_v2.helpers import Blob, flatten
|
||||
@contextmanager
|
||||
def record_kernel_linear():
|
||||
import tinygrad.engine.jit as jit
|
||||
import tinygrad.codegen.compile as codegen
|
||||
recorded, hcq_compile, jit_lower = [], codegen.hcq_compile, jit.jit_lower
|
||||
import tinygrad.engine.realize as realize
|
||||
recorded, hcq_compile, compile_linear = [], realize.hcq_compile, jit.compile_linear
|
||||
|
||||
def recording_jit_lower(*args, **kwargs):
|
||||
with mock.patch.object(codegen, "hcq_compile", lambda linear, *a, **k: (linear.src and recorded.append(linear), hcq_compile(linear, *a, **k))[1]):
|
||||
return jit_lower(*args, **kwargs)
|
||||
def recording_compile_linear(*args, **kwargs):
|
||||
with mock.patch.object(realize, "hcq_compile", lambda linear, *a, **k: (linear.src and recorded.append(linear), hcq_compile(linear, *a, **k))[1]):
|
||||
return compile_linear(*args, **kwargs)
|
||||
|
||||
with mock.patch.object(jit, "jit_lower", recording_jit_lower):
|
||||
with mock.patch.object(jit, "compile_linear", recording_compile_linear):
|
||||
yield recorded
|
||||
|
||||
|
||||
@@ -51,18 +51,15 @@ def kernel_signature(ast, elf) -> list:
|
||||
|
||||
|
||||
def serialize_jit(jit, kernel_linear, check: dict | None = None) -> tuple[dict, memoryview]:
|
||||
from tinygrad.device import TinyELF
|
||||
from tinygrad.uop.ops import Ops
|
||||
sink = tempfile.TemporaryFile(dir=".")
|
||||
blob, bases, input_specs = Blob(sink), {}, {}
|
||||
externs = dict(enumerate(jit.captured._externs, len(jit.captured.expected_input_info)))
|
||||
|
||||
def store(array) -> dict:
|
||||
array = np.ascontiguousarray(array)
|
||||
return {"data": blob.add(array.tobytes()), "dtype": array.dtype.str, "shape": list(array.shape)}
|
||||
|
||||
def describe(uop) -> dict:
|
||||
uop = externs.get(uop.arg.slot, uop) if uop.op is Ops.EXTERN else uop
|
||||
if uop.op is Ops.PARAM:
|
||||
input_specs.setdefault(uop.arg.slot, {"dtype": repr(uop.dtype), "numel": int(uop.max_numel()), "device": uop.device})
|
||||
return {"input": uop.arg.slot}
|
||||
@@ -81,8 +78,8 @@ def serialize_jit(jit, kernel_linear, check: dict | None = None) -> tuple[dict,
|
||||
for call in kernel_linear.src:
|
||||
ast, arguments = call.src[0], [describe(argument) for argument in call.src[1:]]
|
||||
if ast.op is Ops.PROGRAM:
|
||||
elf, info = TinyELF.from_program(ast), ast.arg
|
||||
global_size, local_size = info.launch_dims(call)
|
||||
elf, info = ast.to_elf(), ast.arg
|
||||
global_size, local_size = info.launch_dims({})
|
||||
device_target = dataclasses.asdict(dataclasses.replace(elf.target, interface=elf.target.interface.removeprefix("MOCK")))
|
||||
calls.append({"kind": "program", "name": elf.name, "lib": blob.add(bytes(elf.lib)), "target": device_target,
|
||||
"signature": kernel_signature(ast, elf),
|
||||
|
||||
@@ -5,6 +5,7 @@ This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
from openpilot.common.parameterized import parameterized
|
||||
@@ -187,3 +188,63 @@ class Test4DFeaturesBuffer(OpenpilotTestCase):
|
||||
shapes, sizes = get_policy_npy_shapes(input_shapes, is_supercombo=True)
|
||||
assert shapes['prev_feat'] == (1, 512)
|
||||
assert sizes == [8, 2, 2, 512]
|
||||
|
||||
|
||||
class TestStockCompileModeldEquivalence(OpenpilotTestCase):
|
||||
@unittest.skip("upstream removed selfdrive/modeld/compile_modeld.py — no stock implementation to compare")
|
||||
def test_get_policy_npy_shapes_matches_stock(self):
|
||||
from openpilot.selfdrive.modeld.compile_modeld import get_policy_npy_shapes as stock_get_policy_npy_shapes
|
||||
from openpilot.sunnypilot.modeld_v2.compile_modeld import get_policy_npy_shapes as sunny_get_policy_npy_shapes
|
||||
|
||||
stock_input_shapes = {
|
||||
'desire_pulse': (1, 25, 8),
|
||||
'features_buffer': (1, 24, 512), # see below comment
|
||||
'traffic_convention': (1, 2),
|
||||
'action_t': (1, 2),
|
||||
}
|
||||
|
||||
stock_shapes, stock_sizes = stock_get_policy_npy_shapes(stock_input_shapes)
|
||||
sunny_shapes, sunny_sizes = sunny_get_policy_npy_shapes(stock_input_shapes, is_supercombo=True)
|
||||
|
||||
assert sunny_shapes == stock_shapes
|
||||
assert sunny_sizes == stock_sizes
|
||||
assert sunny_shapes['prev_feat'] == (1, 512)
|
||||
|
||||
@unittest.skip("upstream removed selfdrive/modeld/compile_modeld.py — no stock implementation to compare")
|
||||
def test_make_input_queues_full_stock_equivalence(self):
|
||||
from openpilot.selfdrive.modeld.compile_modeld import make_input_queues as stock_make_input_queues
|
||||
from openpilot.sunnypilot.modeld_v2.compile_modeld import make_supercombo_input_queues as sunny_make_supercombo_input_queues
|
||||
input_shapes = {
|
||||
'img': (1, 12, 128, 256),
|
||||
'desire_pulse': (1, 25, 8),
|
||||
'features_buffer': (1, 24, 32, 512),
|
||||
'traffic_convention': (1, 2),
|
||||
'action_t': (1, 2),
|
||||
}
|
||||
frame_skip = 4
|
||||
|
||||
stock_queues, stock_npy, _frame_views = stock_make_input_queues(input_shapes, frame_skip, device='NPY', frame_copy_size=49152)
|
||||
sunny_queues, sunny_npy = sunny_make_supercombo_input_queues(input_shapes, frame_skip, device='NPY')
|
||||
# sunnypilot split pipeline has tfm/big_tfm as queues; packed_npy_inputs size differs (different frame packing)
|
||||
assert set(stock_queues.keys()) <= set(sunny_queues.keys())
|
||||
for key in stock_queues:
|
||||
if key == 'packed_npy_inputs':
|
||||
continue
|
||||
assert sunny_queues[key].shape == stock_queues[key].shape, \
|
||||
f"Queue shape mismatch for {key}: sunny {sunny_queues[key].shape} != stock {stock_queues[key].shape}"
|
||||
assert set(stock_npy.keys()) <= set(sunny_npy.keys())
|
||||
for key in stock_npy:
|
||||
assert sunny_npy[key].shape == stock_npy[key].shape, \
|
||||
f"Numpy array shape mismatch for {key}: sunny {sunny_npy[key].shape} != stock {stock_npy[key].shape}"
|
||||
|
||||
@unittest.skip("upstream removed make_warp_input_queues — warp merged into run_model")
|
||||
def test_make_warp_queues_stock_equivalence(self):
|
||||
from openpilot.selfdrive.modeld.compile_modeld import make_warp_input_queues as stock_make_warp_queues
|
||||
from openpilot.sunnypilot.modeld_v2.compile_modeld import make_warp_queues as sunny_make_warp_queues
|
||||
stock_vision_shapes = {'img': (1, 12, 128, 256)} # for now?
|
||||
stock_queues, stock_npy = stock_make_warp_queues(stock_vision_shapes, frame_skip=4, device='NPY')
|
||||
sunny_queues, sunny_npy = sunny_make_warp_queues(device='NPY')
|
||||
|
||||
assert set(sunny_npy.keys()) == set(stock_npy.keys()) == {'tfm', 'big_tfm'}
|
||||
for key in sunny_npy:
|
||||
assert sunny_npy[key].shape == stock_npy[key].shape == (3, 3)
|
||||
|
||||
@@ -1 +1 @@
|
||||
c9700628ee59e67f78fb603afd815b28eb30f4f2c215b67d307f9703593630cf
|
||||
ec362fdaecff40a02a2bf3eb23882ca8d28cef26175df194798d5e0a67f813b7
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f7df0485754b51731fc60b4cb324d75c7058c0e20c7c979ac84aa5273e29aa83
|
||||
size 5956
|
||||
@@ -126,6 +126,7 @@ def initialize_params(params) -> list[dict[str, Any]]:
|
||||
keys.extend([
|
||||
"ToyotaEnforceStockLongitudinal",
|
||||
"ToyotaStopAndGoHack",
|
||||
"ToyotaEnhancedBsm",
|
||||
"ToyotaTSS2Smooth",
|
||||
])
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ ButtonType = car.CarState.ButtonEvent.Type
|
||||
@parameterized_class(('pcm_cruise', 'pcm_cruise_speed'), [(False, True)])
|
||||
class TestCustomAccIncrements(TestVCruiseHelper):
|
||||
def setup_method(self):
|
||||
super().openpilot_setup_method()
|
||||
TestVCruiseHelper.openpilot_setup_method(self)
|
||||
self.params = Params()
|
||||
self.reset_custom_params()
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
"""
|
||||
Copyright (c) 2021-, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from openpilot.cereal import log
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.sunnypilot import PARAMS_UPDATE_PERIOD
|
||||
|
||||
ACCEL_BOOST_MIN_SPEED = 1.0
|
||||
ACCEL_BOOST_MAX = (0.4, 0.25, 0.1) # aggressive, standard, relaxed, m/s^2
|
||||
ACCEL_BOOST_BUILD, ACCEL_BOOST_RELEASE = 0.2, 1.0 # m/s^3
|
||||
BRAKE_PROB = (0.1, 0.3) # the model's brake press in 4 s: it wants to slow
|
||||
GAS_PROB = (0.6, 0.8) # predicts a human gas press at this hypothesis at about 23%
|
||||
CURVE_LAT_ACCEL = (1.5, 2.5)
|
||||
|
||||
|
||||
def get_boost_max(personality=log.LongitudinalPersonality.standard):
|
||||
if personality == log.LongitudinalPersonality.relaxed:
|
||||
return ACCEL_BOOST_MAX[2]
|
||||
elif personality == log.LongitudinalPersonality.standard:
|
||||
return ACCEL_BOOST_MAX[1]
|
||||
elif personality == log.LongitudinalPersonality.aggressive:
|
||||
return ACCEL_BOOST_MAX[0]
|
||||
else:
|
||||
raise NotImplementedError("Longitudinal personality not supported")
|
||||
|
||||
|
||||
class AccelBoostSP:
|
||||
def __init__(self):
|
||||
self.params = Params()
|
||||
self.frame = -1
|
||||
self.enabled = False
|
||||
self.boost = 0.0
|
||||
self.total_boost = 0.0
|
||||
|
||||
def update_params(self):
|
||||
self.frame += 1
|
||||
if self.frame % int(PARAMS_UPDATE_PERIOD / DT_MDL) != 0:
|
||||
return False
|
||||
enabled = self.params.get_bool("AccelBoostSP")
|
||||
if enabled == self.enabled:
|
||||
return False
|
||||
self.enabled = enabled
|
||||
self.boost = self.total_boost = 0.0
|
||||
return True
|
||||
|
||||
def reset(self):
|
||||
self.boost = self.total_boost = 0.0
|
||||
|
||||
def update(self, sm, output_a_target_e2e, curve_offset):
|
||||
model = sm['modelV2']
|
||||
brake_probs = model.meta.disengagePredictions.brakePressProbs
|
||||
gas_probs = model.meta.disengagePredictions.gasPressProbs
|
||||
if not sm['selfdriveState'].enabled or len(brake_probs) < 2 or len(gas_probs) < 2:
|
||||
self.boost = self.total_boost = 0.0
|
||||
return output_a_target_e2e
|
||||
|
||||
want = max(float(np.interp(brake_probs[1], BRAKE_PROB, [1.0, 0.0])), float(np.interp(gas_probs[1], GAS_PROB, [0.0, 1.0])))
|
||||
want = 0.0 if model.action.shouldStop else want
|
||||
want *= float(np.interp(abs(model.action.desiredCurvature) * sm['carState'].vEgo ** 2, CURVE_LAT_ACCEL, [1.0, 0.0]))
|
||||
target = want * get_boost_max(sm['selfdriveState'].personality)
|
||||
self.boost = float(np.clip(target, self.boost - ACCEL_BOOST_RELEASE * DT_MDL, self.boost + ACCEL_BOOST_BUILD * DT_MDL))
|
||||
speed_scale = np.interp(sm['carState'].vEgo, [ACCEL_BOOST_MIN_SPEED, 2 * ACCEL_BOOST_MIN_SPEED], [0.0, 1.0])
|
||||
self.total_boost = self.boost * speed_scale * np.interp(output_a_target_e2e, [-0.7, -0.2, 5.0], [0.0, 1.0, 1.0], right=0.0)
|
||||
return output_a_target_e2e + self.total_boost
|
||||
@@ -7,8 +7,6 @@ See the LICENSE.md file in the root directory for more details.
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
from openpilot.cereal import log
|
||||
|
||||
from openpilot.common.pid import PIDController
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N
|
||||
from openpilot.selfdrive.modeld.constants import ModelConstants
|
||||
@@ -64,7 +62,7 @@ class LatControlTorqueExtBase:
|
||||
|
||||
self._ff = 0.0
|
||||
self._pid = PIDController(KP, KI)
|
||||
self._pid_log = log.ControlsState.LateralTorqueState.new_message()
|
||||
self._pid_log = None
|
||||
self._setpoint = 0.0
|
||||
self._measurement = 0.0
|
||||
self._roll_compensation = 0.0
|
||||
@@ -121,7 +119,7 @@ class LatControlTorqueExtBase:
|
||||
actual_curvature_rate = -VM.calc_curvature(math.radians(CS.steeringRateDeg), CS.vEgo, 0.0)
|
||||
self.actual_lateral_jerk = actual_curvature_rate * CS.vEgo ** 2
|
||||
|
||||
if self.model_valid and self.model_v2 is not None:
|
||||
if self.model_valid:
|
||||
# prepare "look-ahead" desired lateral jerk
|
||||
lookahead = np.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)
|
||||
|
||||
@@ -34,7 +34,7 @@ class LatControlTorqueJerkAware(LatControlTorqueExtBase):
|
||||
LatControlInputs(self._measurement, roll_compensation, CS.vEgo, CS.aEgo), self.torque_params, gravity_adjusted=False
|
||||
)
|
||||
|
||||
self._pid_log.error = float(torque_from_setpoint - torque_from_measurement)
|
||||
self._pid_log.error = float(torque_from_setpoint - torque_from_measurement) # ty: ignore[invalid-assignment]
|
||||
self._ff = self.torque_from_lateral_accel_in_torque_space(
|
||||
LatControlInputs(gravity_adjusted_lateral_accel, roll_compensation, CS.vEgo, CS.aEgo), self.torque_params, gravity_adjusted=True
|
||||
)
|
||||
|
||||
@@ -9,7 +9,9 @@ from openpilot.cereal import messaging, custom
|
||||
from opendbc.car import structs
|
||||
from openpilot.common.constants import CV
|
||||
from openpilot.selfdrive.car.cruise import V_CRUISE_MAX
|
||||
from openpilot.selfdrive.controls.lib.accel_boost import AccelBoost
|
||||
from openpilot.selfdrive.controls.lib.curve_speed import CurveSpeed
|
||||
from openpilot.sunnypilot.selfdrive.controls.lib.accel_boost import AccelBoostSP
|
||||
from openpilot.sunnypilot.selfdrive.controls.lib.e2e_alerts_helper import E2EAlertsHelper
|
||||
from openpilot.sunnypilot.selfdrive.controls.lib.smart_cruise_control.smart_cruise_control import SmartCruiseControl
|
||||
from openpilot.sunnypilot.selfdrive.controls.lib.speed_limit.speed_limit_assist import SpeedLimitAssist
|
||||
@@ -29,8 +31,6 @@ class NoCurveSpeed:
|
||||
|
||||
|
||||
class LongitudinalPlannerSP:
|
||||
dt: float
|
||||
|
||||
def __init__(self, CP: structs.CarParams, CP_SP: structs.CarParamsSP, mpc):
|
||||
self.events_sp = EventsSP()
|
||||
self.resolver = SpeedLimitResolver()
|
||||
@@ -40,6 +40,7 @@ class LongitudinalPlannerSP:
|
||||
self.generation = int(model_bundle.generation) if (model_bundle := get_active_bundle()) else None
|
||||
self.source = LongitudinalPlanSource.cruise
|
||||
self.e2e_alerts_helper = E2EAlertsHelper()
|
||||
self.accel_boost_sp = AccelBoostSP()
|
||||
self.openpilot_longitudinal = CP.openpilotLongitudinalControl
|
||||
|
||||
self.output_v_target = 0.
|
||||
@@ -82,6 +83,8 @@ class LongitudinalPlannerSP:
|
||||
self.curve_speed = NoCurveSpeed() if scc_curves else CurveSpeed(self.dt)
|
||||
|
||||
def update(self, sm: messaging.SubMaster) -> None:
|
||||
if self.accel_boost_sp.update_params():
|
||||
self.accel_boost = self.accel_boost_sp if self.accel_boost_sp.enabled and self.openpilot_longitudinal else AccelBoost()
|
||||
self._update_curve_speed()
|
||||
|
||||
self.events_sp.clear()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user