mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-11-30 05:33:45 +08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bb375af6c | |||
| cf310d6b61 | |||
| ab3e898ae9 | |||
| 70b6488f98 | |||
| d985060268 | |||
| 50af5c62ed | |||
| 101b7edd70 | |||
| 2b7b311075 | |||
| c26d148439 | |||
| 9e9b6934e3 | |||
| 23c2990b28 | |||
| 67278eab5f | |||
| bc4be1a4e0 | |||
| 2a889583c8 | |||
| c65567b8ed | |||
| 7effd51092 | |||
| d21a917610 | |||
| 8417ae9a4a | |||
| 072db14995 | |||
| 98845b8525 | |||
| fe592c79a7 | |||
| 5d1497a841 | |||
| 9b961acc2b | |||
| 07ece9b3fd |
@@ -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
|
||||
@@ -77,8 +77,9 @@ jobs:
|
||||
build_small_model:
|
||||
needs: resolve
|
||||
if: ${{ inputs.target == 'small' }}
|
||||
runs-on: ubuntu-24.04-arm
|
||||
runs-on: [self-hosted, tici]
|
||||
env:
|
||||
MODELS_DIR: openpilot/selfdrive/modeld/models
|
||||
COMPILER: tinygrad_repo/examples/openpilot
|
||||
SMALL_ONNX: openpilot/selfdrive/modeld/models/driving_supercombo.onnx
|
||||
SMALL_PKL: openpilot/selfdrive/modeld/models/driving_tinygrad.pkl
|
||||
@@ -90,28 +91,37 @@ jobs:
|
||||
- name: Pull small ONNX via LFS
|
||||
run: ./lfs.py pull --exclude='' # ponytail: pulls every LFS file (lfs.py has no include filter); HF egress is free
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Set up the qcom mock
|
||||
uses: ./.github/workflows/setup-qcom-mock
|
||||
with:
|
||||
hf_token: ${{ secrets.HF_TOKEN }}
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
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
|
||||
uv sync --frozen
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Disable powersave
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
|
||||
- name: Compile small model from ONNX
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
TG_FLAGS="DEV=MOCK+QCOM HCQ_RUNTIME_DEV=CPU:LLVM:arm64,cortex-a75,fp-armv8,sha2,lse,neon,crc,aes IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
TG_FLAGS="DEV=QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
env ${TG_FLAGS} python3 ${{ github.workspace }}/${{ env.COMPILER }}/compile_onnx.py \
|
||||
${{ github.workspace }}/${{ env.SMALL_ONNX }} \
|
||||
${{ github.workspace }}/${{ env.SMALL_PKL }} \
|
||||
--out-of-band --benchmark-runs 0
|
||||
--out-of-band --benchmark-runs 1
|
||||
|
||||
- name: Prepare output
|
||||
env:
|
||||
MODEL_NAME: ${{ needs.resolve.outputs.safe_model_name }}
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH=${{ github.workspace }}
|
||||
MODELS_DIR="${{ github.workspace }}/openpilot/selfdrive/modeld/models"
|
||||
OUTPUT_DIR="${{ github.workspace }}/small_output"
|
||||
@@ -143,11 +153,19 @@ jobs:
|
||||
name: artifact-name-${{ needs.resolve.outputs.safe_model_name }}
|
||||
path: ${{ github.workspace }}/small_output/artifact_name.txt
|
||||
|
||||
- name: Re-enable powersave
|
||||
if: always()
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
build_big_model:
|
||||
needs: resolve
|
||||
if: ${{ inputs.target == 'big' }}
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: [self-hosted, chestnut]
|
||||
env:
|
||||
MODELS_DIR: openpilot/selfdrive/modeld/models
|
||||
COMPILER: tinygrad_repo/examples/openpilot
|
||||
BIG_PKL: openpilot/selfdrive/modeld/models/big_driving_tinygrad.pkl
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -157,21 +175,70 @@ jobs:
|
||||
- name: Pull big PKL via LFS
|
||||
run: ./lfs.py pull --exclude='' # ponytail: pulls every LFS file (lfs.py has no include filter); HF egress is free
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
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
|
||||
uv sync --frozen
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Install LLVM 20 and ROCm comgr for the amd mock
|
||||
uses: ./.github/workflows/setup-amd-mock
|
||||
with:
|
||||
emu_cache: big-warp
|
||||
- name: Disable powersave
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
|
||||
- uses: ./.github/workflows/big-warp
|
||||
- name: Wait for chestnut PCIe link
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
python3 -c "
|
||||
import time
|
||||
from openpilot.sunnypilot.modeld_v2.compile_modeld import chestnut_link_up
|
||||
for i in range(10):
|
||||
if chestnut_link_up():
|
||||
print(f'PCIe link up after {i+1} attempt(s)')
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError('Chestnut PCIe link not ready after 10 attempts')
|
||||
"
|
||||
|
||||
- name: Compile big warp
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${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 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"
|
||||
env ${CHESTNUT_TG_FLAGS} python3 "${COMPILER}/compile_warp.py" \
|
||||
--frame ${CAM_W},${CAM_H},${STRIDE_INFO} \
|
||||
--warp-to ${MODEL_SIZE} \
|
||||
--layout yuv420 \
|
||||
--frames 2 \
|
||||
--output "${WARP_PKL}"
|
||||
done
|
||||
|
||||
- name: Prepare output
|
||||
env:
|
||||
MODEL_NAME: ${{ needs.resolve.outputs.safe_model_name }}
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH=${{ github.workspace }}
|
||||
MODELS_DIR="${{ github.workspace }}/openpilot/selfdrive/modeld/models"
|
||||
OUTPUT_DIR="${{ github.workspace }}/big_output"
|
||||
@@ -205,6 +272,12 @@ jobs:
|
||||
name: artifact-name-${{ needs.resolve.outputs.safe_model_name }}
|
||||
path: ${{ github.workspace }}/big_output/artifact_name.txt
|
||||
|
||||
- name: Re-enable powersave
|
||||
if: always()
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
upload_defaults:
|
||||
needs: [ resolve, build_small_model, build_big_model, build_dm_model ]
|
||||
if: |
|
||||
@@ -332,7 +405,7 @@ jobs:
|
||||
build_dm_model:
|
||||
needs: resolve
|
||||
if: ${{ inputs.target == 'dm' }}
|
||||
runs-on: ubuntu-24.04-arm
|
||||
runs-on: [self-hosted, tici]
|
||||
env:
|
||||
DM_ONNX: openpilot/selfdrive/modeld/models/dmonitoring_model.onnx
|
||||
DM_PKL: openpilot/selfdrive/modeld/models/dmonitoring_model_tinygrad.pkl
|
||||
@@ -344,32 +417,40 @@ jobs:
|
||||
- name: Pull DM ONNX via LFS
|
||||
run: ./lfs.py pull --exclude='' # ponytail: pulls every LFS file (lfs.py has no include filter); HF egress is free
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
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
|
||||
uv sync --frozen
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Set up the qcom mock
|
||||
uses: ./.github/workflows/setup-qcom-mock
|
||||
with:
|
||||
hf_token: ${{ secrets.HF_TOKEN }}
|
||||
- name: Disable powersave
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
|
||||
- name: Compile DM model
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
|
||||
TG_FLAGS="DEV=MOCK+QCOM HCQ_RUNTIME_DEV=CPU:LLVM:arm64,cortex-a75,fp-armv8,sha2,lse,neon,crc,aes IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
TG_FLAGS="DEV=QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
|
||||
env ${TG_FLAGS} python3 \
|
||||
taskset -c 7 env ${TG_FLAGS} python3 \
|
||||
${{ github.workspace }}/tinygrad_repo/examples/openpilot/compile_onnx.py \
|
||||
${{ github.workspace }}/${{ env.DM_ONNX }} \
|
||||
${{ github.workspace }}/${{ env.DM_PKL }} \
|
||||
--out-of-band --benchmark-runs 0
|
||||
--out-of-band --benchmark-runs 1
|
||||
|
||||
- name: Compile DM warp
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
|
||||
TG_FLAGS="DEV=MOCK+QCOM HCQ_RUNTIME_DEV=CPU:LLVM:arm64,cortex-a75,fp-armv8,sha2,lse,neon,crc,aes IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
TG_FLAGS="DEV=QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1"
|
||||
COMPILER="${{ github.workspace }}/tinygrad_repo/examples/openpilot"
|
||||
MODELS_DIR="${{ github.workspace }}/openpilot/selfdrive/modeld/models"
|
||||
DM_SIZE=$(python3 -c "from openpilot.common.transformations.model import DM_INPUT_SIZE as s; print(f'{s[0]}x{s[1]}')")
|
||||
@@ -384,13 +465,12 @@ jobs:
|
||||
print(f'{s},{y},{u},{sz}')
|
||||
" $CAM_W $CAM_H)
|
||||
WARP_PKL="${MODELS_DIR}/dm_warp_${res}_tinygrad.pkl"
|
||||
env ${TG_FLAGS} python3 "${COMPILER}/compile_warp.py" \
|
||||
taskset -c 7 env ${TG_FLAGS} python3 "${COMPILER}/compile_warp.py" \
|
||||
--frame ${CAM_W},${CAM_H},${STRIDE_INFO} \
|
||||
--warp-to ${DM_SIZE} \
|
||||
--layout luma \
|
||||
--border-fill 16 \
|
||||
--transform-device NPY \
|
||||
--benchmark-runs 0 \
|
||||
--output "${WARP_PKL}"
|
||||
done
|
||||
|
||||
@@ -405,3 +485,9 @@ jobs:
|
||||
with:
|
||||
name: dm-model-${{ github.run_number }}
|
||||
path: dm_output/
|
||||
|
||||
- name: Re-enable powersave
|
||||
if: always()
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -3,87 +3,58 @@ name: Compile warp for sunnypilot modeld
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
WARP_DIR: openpilot/sunnypilot/modeld_v2/models
|
||||
|
||||
jobs:
|
||||
compile_warps:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- target: qcom
|
||||
runs-on: ubuntu-24.04-arm
|
||||
prefix: driving_warp
|
||||
flags: DEV=MOCK+QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1
|
||||
args: --split-frames
|
||||
- target: chestnut
|
||||
runs-on: ubuntu-24.04
|
||||
prefix: big_driving_warp
|
||||
flags: DEV=MOCKUSB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 CHECK_OOB=0 TC_OPT=2 TC_MIN_GLOBALS=32
|
||||
args: ''
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
runs-on: [self-hosted, chestnut]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
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
|
||||
uv sync --frozen
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Set up the qcom mock
|
||||
if: matrix.target == 'qcom'
|
||||
uses: ./.github/workflows/setup-qcom-mock
|
||||
with:
|
||||
hf_token: ${{ secrets.HF_TOKEN }}
|
||||
|
||||
- name: Install LLVM 20 and ROCm comgr for the amd mock
|
||||
if: matrix.target == 'chestnut'
|
||||
uses: ./.github/workflows/setup-amd-mock
|
||||
with:
|
||||
emu_cache: warp
|
||||
|
||||
- name: Install the amd mock build dependencies
|
||||
if: matrix.target == 'chestnut'
|
||||
run: python3 -m pip install -q numpy zstandard
|
||||
- name: Disable powersave
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
|
||||
- name: Compile Warp Kernels
|
||||
run: |
|
||||
export PYTHONPATH="${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
mkdir -p "$WARP_DIR"
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}"
|
||||
mkdir -p openpilot/sunnypilot/modeld_v2/models/
|
||||
MODEL_SIZE=$(python3 -c "from openpilot.common.transformations.model import MEDMODEL_INPUT_SIZE as s; print(f'{s[0]}x{s[1]}')")
|
||||
CAMERA_RES=$(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}')")
|
||||
echo "Model size: $MODEL_SIZE"
|
||||
echo "Camera resolutions: $CAMERA_RES"
|
||||
|
||||
for res in $CAMERA_RES; do
|
||||
FRAME_PARAM=$(python3 -c "from openpilot.system.camerad.cameras.nv12_info import get_nv12_info; w, h = map(int, '${res}'.split('x')); stride, y_h, uv_h, _ = get_nv12_info(w, h); print(f'{w},{h},{stride},{y_h},{uv_h},{stride * (y_h + uv_h)}')")
|
||||
WARP_PKL="$WARP_DIR/${{ matrix.prefix }}_${res}_tinygrad.pkl"
|
||||
echo "Compiling $WARP_PKL"
|
||||
env ${{ matrix.flags }} python3 openpilot/sunnypilot/modeld_v2/compile_warp.py \
|
||||
--frame ${FRAME_PARAM} --warp-to ${MODEL_SIZE} ${{ matrix.args }} --output "${WARP_PKL}"
|
||||
|
||||
WARP_PKL="openpilot/sunnypilot/modeld_v2/models/driving_warp_${res}_tinygrad.pkl"
|
||||
echo "Compiling $WARP_PKL on QCOM"
|
||||
taskset -c 7 env DEV=QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 JIT_BATCH_SIZE=0 OPENPILOT_HACKS=1 python3 openpilot/sunnypilot/modeld_v2/compile_warp.py \
|
||||
--frame ${FRAME_PARAM} --warp-to ${MODEL_SIZE} --split-frames --output "${WARP_PKL}"
|
||||
|
||||
BIG_WARP_PKL="openpilot/sunnypilot/modeld_v2/models/big_driving_warp_${res}_tinygrad.pkl"
|
||||
echo "Compiling $BIG_WARP_PKL on AMD"
|
||||
taskset -c 7 env DEV=USB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 JIT_BATCH_SIZE=0 GMMU=0 TC_OPT=2 TC_MIN_GLOBALS=32 python3 openpilot/sunnypilot/modeld_v2/compile_warp.py \
|
||||
--frame ${FRAME_PARAM} --warp-to ${MODEL_SIZE} --output "${BIG_WARP_PKL}"
|
||||
done
|
||||
|
||||
- name: Replay their check frames on the mock and require the result bit for bit
|
||||
env:
|
||||
DEV: ${{ matrix.target == 'chestnut' && 'MOCKUSB+AMD' || 'MOCK+QCOM' }}
|
||||
PYTHONPATH: ${{ github.workspace }}/tinygrad_repo:${{ github.workspace }}
|
||||
run: python3 -m openpilot.sunnypilot.modeld_v2.mock_parity check "$WARP_DIR"/${{ matrix.prefix }}_*_tinygrad.pkl
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: warps-${{ matrix.target }}
|
||||
path: ${{ env.WARP_DIR }}/${{ matrix.prefix }}_*_tinygrad.pkl
|
||||
if-no-files-found: error
|
||||
|
||||
create_pr:
|
||||
needs: compile_warps
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: warps-*
|
||||
path: ${{ env.WARP_DIR }}
|
||||
merge-multiple: true
|
||||
- name: Re-enable powersave
|
||||
if: always()
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
name: Set up tinygrad's qcom mock
|
||||
description: The a630 compiler, checked against what an a630 compiled, and the kernels earlier builds compiled
|
||||
inputs:
|
||||
hf_token:
|
||||
description: Records a passed compiler check on HF so the next build skips it
|
||||
default: ''
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Install the qcom mock build dependencies
|
||||
id: deps
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install -q numpy zstandard tinymesa==25.2.7.2
|
||||
if [ "$RUNNER_ARCH" = ARM64 ]; then # the qcomcl rootfs's compiler loads in this python, no qemu
|
||||
sudo apt-get -qq update && sudo apt-get -qq install -y --no-install-recommends aria2
|
||||
FS=$(PYTHONPATH="$GITHUB_WORKSPACE/tinygrad_repo" python3 -c "from tinygrad.helpers import fetch; print(fetch('https://git.tinygrad.win/tinygrad/images/releases/download/v2/qcomcl.tar.gz', extract=True))")
|
||||
echo "LLVM_QCOM_PATH=$FS/usr/lib/libllvm-qcom.so" >> "$GITHUB_ENV"
|
||||
echo "compiler=native-$(sha256sum "$FS/usr/lib/libllvm-qcom.so" | cut -c1-16)" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
sudo apt-get -qq update && sudo apt-get -qq install -y --no-install-recommends qemu-user-static aria2
|
||||
echo "compiler=qemu-$(dpkg-query -W -f='${Version}' qemu-user-static)" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Compiler check passed before with all of it identical?
|
||||
id: compiler
|
||||
shell: bash
|
||||
env:
|
||||
KEY: qcom-compiler-parity-${{ steps.deps.outputs.compiler }}-${{ hashFiles('tinygrad_repo/test/device/qcom/compiler_parity.py', 'tinygrad_repo/test/mockgpu/qcom/a630_compiled.pkl.xz', 'tinygrad_repo/tinygrad/runtime/support/compiler_qcom.py') }}
|
||||
run: |
|
||||
MARKER="ci/qcom-compiler-parity/$(printf '%s' "$KEY" | tr -c 'A-Za-z0-9._-' '_').txt"
|
||||
CODE=$(curl -s -o /dev/null -w '%{http_code}' -I -L "https://huggingface.co/datasets/sunnypilot/sunnypilot_models_v1/resolve/main/$MARKER")
|
||||
echo "$MARKER: HTTP $CODE"
|
||||
{ echo "key=$KEY"; echo "marker=$MARKER"; echo "passed=$([ "$CODE" = 200 ] && echo true || echo false)"; } >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check the off-device qcom compiler builds the a630's bytes
|
||||
if: steps.compiler.outputs.passed != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
# every kernel an a630 has compiled must compile to the same bytes here before a model is built here
|
||||
TG="$GITHUB_WORKSPACE/tinygrad_repo"
|
||||
PYTHONPATH="$TG" python3 "$TG/test/device/qcom/compiler_parity.py" check "$TG/test/mockgpu/qcom/a630_compiled.pkl.xz"
|
||||
|
||||
- name: Remember the compiler check passed
|
||||
if: steps.compiler.outputs.passed != 'true' && inputs.hf_token != ''
|
||||
shell: bash
|
||||
env:
|
||||
HF_TOKEN: ${{ inputs.hf_token }}
|
||||
KEY: ${{ steps.compiler.outputs.key }}
|
||||
MARKER: ${{ steps.compiler.outputs.marker }}
|
||||
run: |
|
||||
python3 -m pip install -q --upgrade "huggingface_hub>=0.34"
|
||||
printf '%s\n%s\n' "$KEY" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > "$RUNNER_TEMP/marker.txt"
|
||||
hf upload --repo-type dataset sunnypilot/sunnypilot_models_v1 "$RUNNER_TEMP/marker.txt" "$MARKER" \
|
||||
--commit-message "qcom compiler parity passed: $KEY" || echo "::warning::could not record the pass, the next build checks again"
|
||||
|
||||
- name: Kernels compiled by earlier builds
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/tinygrad/cache.db
|
||||
key: qcom-kernels-${{ steps.compiler.outputs.key }}-${{ github.run_id }}
|
||||
restore-keys: qcom-kernels-${{ steps.compiler.outputs.key }}-
|
||||
@@ -1,7 +1,9 @@
|
||||
name: Build Model from Upstream
|
||||
|
||||
env:
|
||||
BUILD_DIR: "/data/openpilot"
|
||||
OUTPUT_DIR: ${{ github.workspace }}/output
|
||||
SCONS_CACHE_DIR: ${{ github.workspace }}/release/ci/scons_cache
|
||||
UPSTREAM_REPO: "commaai/openpilot"
|
||||
TINYGRAD_PATH: ${{ github.workspace }}/tinygrad_repo
|
||||
MODELS_DIR: ${{ github.workspace }}/openpilot/selfdrive/modeld/models
|
||||
@@ -38,6 +40,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
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
upstream_branch:
|
||||
@@ -67,6 +74,11 @@ on:
|
||||
- qcom
|
||||
- chestnut
|
||||
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
|
||||
|
||||
|
||||
run-name: Build model [${{ inputs.custom_name || inputs.upstream_branch }}] from ref [${{ inputs.upstream_branch }}]
|
||||
@@ -174,36 +186,114 @@ jobs:
|
||||
if-no-files-found: error
|
||||
|
||||
build_model:
|
||||
runs-on: ${{ inputs.target_hardware == 'chestnut' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
|
||||
runs-on: ${{ inputs.on_device && fromJSON(inputs.target_hardware == 'chestnut' && '["self-hosted","chestnut"]' || '["self-hosted","tici"]') || inputs.target_hardware == 'chestnut' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
|
||||
needs: get_model
|
||||
env:
|
||||
MODEL_NAME: ${{ inputs.custom_name || inputs.upstream_branch }} (${{ needs.get_model.outputs.model_date }})
|
||||
REF: ${{ inputs.upstream_branch }}
|
||||
MOCK_BUILD: ${{ !inputs.on_device }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
- name: Set up the hosted mock build
|
||||
if: env.MOCK_BUILD == 'true'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install LLVM 20 and ROCm comgr for the amd mock
|
||||
if: inputs.target_hardware == 'chestnut'
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware == 'chestnut'
|
||||
uses: ./.github/workflows/setup-amd-mock
|
||||
with:
|
||||
emu_cache: build
|
||||
|
||||
- name: Install the amd mock build dependencies
|
||||
if: inputs.target_hardware == 'chestnut'
|
||||
run: python3 -m pip install -q numpy zstandard
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware == 'chestnut'
|
||||
run: |
|
||||
python3 -m pip install -q numpy zstandard
|
||||
|
||||
- name: Set up the qcom mock
|
||||
if: inputs.target_hardware != 'chestnut'
|
||||
uses: ./.github/workflows/setup-qcom-mock
|
||||
- name: Install the qcom mock build dependencies
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware != 'chestnut'
|
||||
id: qcom_deps
|
||||
run: |
|
||||
python3 -m pip install -q numpy zstandard tinymesa==25.2.7.2
|
||||
if [ "$RUNNER_ARCH" = ARM64 ]; then # the qcomcl rootfs's compiler loads in this python, no qemu
|
||||
sudo apt-get -qq update && sudo apt-get -qq install -y --no-install-recommends aria2
|
||||
FS=$(PYTHONPATH="$TINYGRAD_PATH" python3 -c "from tinygrad.helpers import fetch; print(fetch('https://git.tinygrad.win/tinygrad/images/releases/download/v2/qcomcl.tar.gz', extract=True))")
|
||||
echo "LLVM_QCOM_PATH=$FS/usr/lib/libllvm-qcom.so" >> "$GITHUB_ENV"
|
||||
echo "compiler=native-$(sha256sum "$FS/usr/lib/libllvm-qcom.so" | cut -c1-16)" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
sudo apt-get -qq update && sudo apt-get -qq install -y --no-install-recommends qemu-user-static aria2
|
||||
echo "compiler=qemu-$(dpkg-query -W -f='${Version}' qemu-user-static)" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Compiler check passed before with all of it identical?
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware != 'chestnut'
|
||||
id: qcom_compiler
|
||||
env:
|
||||
KEY: qcom-compiler-parity-${{ steps.qcom_deps.outputs.compiler }}-${{ hashFiles('tinygrad_repo/test/device/qcom/compiler_parity.py', 'tinygrad_repo/test/mockgpu/qcom/a630_compiled.pkl.xz', 'tinygrad_repo/tinygrad/runtime/support/compiler_qcom.py') }}
|
||||
run: |
|
||||
MARKER="ci/qcom-compiler-parity/$(printf '%s' "$KEY" | tr -c 'A-Za-z0-9._-' '_').txt"
|
||||
CODE=$(curl -s -o /dev/null -w '%{http_code}' -I -L "https://huggingface.co/datasets/sunnypilot/sunnypilot_models_v1/resolve/main/$MARKER")
|
||||
echo "$MARKER: HTTP $CODE"
|
||||
{ echo "key=$KEY"; echo "marker=$MARKER"; echo "passed=$([ "$CODE" = 200 ] && echo true || echo false)"; } >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check the off-device qcom compiler builds the a630's bytes
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware != 'chestnut' && steps.qcom_compiler.outputs.passed != 'true'
|
||||
run: |
|
||||
# every kernel an a630 has compiled must compile to the same bytes here before a model is built here
|
||||
PYTHONPATH="$TINYGRAD_PATH" python3 "$TINYGRAD_PATH/test/device/qcom/compiler_parity.py" check "$TINYGRAD_PATH/test/mockgpu/qcom/a630_compiled.pkl.xz"
|
||||
|
||||
- name: Remember the compiler check passed
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware != 'chestnut' && steps.qcom_compiler.outputs.passed != 'true'
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
KEY: ${{ steps.qcom_compiler.outputs.key }}
|
||||
MARKER: ${{ steps.qcom_compiler.outputs.marker }}
|
||||
run: |
|
||||
python3 -m pip install -q --upgrade "huggingface_hub>=0.34"
|
||||
printf '%s\n%s\n' "$KEY" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > "$RUNNER_TEMP/marker.txt"
|
||||
hf upload --repo-type dataset sunnypilot/sunnypilot_models_v1 "$RUNNER_TEMP/marker.txt" "$MARKER" \
|
||||
--commit-message "qcom compiler parity passed: $KEY" || echo "::warning::could not record the pass, the next build checks again"
|
||||
|
||||
- name: Kernels compiled by earlier builds
|
||||
if: env.MOCK_BUILD == 'true' && inputs.target_hardware != 'chestnut'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
hf_token: ${{ secrets.HF_TOKEN }}
|
||||
path: ~/.cache/tinygrad/cache.db
|
||||
key: qcom-kernels-${{ steps.qcom_compiler.outputs.key }}-${{ github.run_id }}
|
||||
restore-keys: qcom-kernels-${{ steps.qcom_compiler.outputs.key }}-
|
||||
|
||||
- name: Set environment variables
|
||||
if: env.MOCK_BUILD != 'true'
|
||||
id: set-env
|
||||
run: |
|
||||
# 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
|
||||
uv sync --frozen
|
||||
printenv >> $GITHUB_ENV
|
||||
|
||||
- name: Setup build environment
|
||||
if: env.MOCK_BUILD != 'true'
|
||||
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: ${{ steps.set-env.outputs.version }}"
|
||||
echo "UV_PROJECT_ENVIRONMENT: ${UV_PROJECT_ENVIRONMENT}"
|
||||
echo "VIRTUAL_ENV: ${VIRTUAL_ENV}"
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --disable
|
||||
rm -rf ${{ env.MODELS_DIR }}/*.onnx*
|
||||
|
||||
- name: Download model artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -213,18 +303,28 @@ jobs:
|
||||
|
||||
- name: Build Model
|
||||
run: |
|
||||
export CHECK_OOB=0 GMMU=0 # as test/mockgpu runs the amd mock
|
||||
if [ "$MOCK_BUILD" = "true" ]; then
|
||||
TASKSET=""
|
||||
export CHECK_OOB=0 GMMU=0 # as test/mockgpu runs the amd mock
|
||||
else
|
||||
source /etc/profile
|
||||
export UV_PROJECT_ENVIRONMENT=${HOME}/venv
|
||||
export VIRTUAL_ENV=$UV_PROJECT_ENVIRONMENT
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
TASKSET="taskset -c 7"
|
||||
fi
|
||||
export PYTHONPATH="${PYTHONPATH}:${{ env.TINYGRAD_PATH }}:${{ github.workspace }}"
|
||||
|
||||
COMPILE_MODELD="${{ github.workspace }}/openpilot/sunnypilot/modeld_v2/compile_modeld.py"
|
||||
MODEL_SIZE=$(python3 -c "from openpilot.common.transformations.model import MEDMODEL_INPUT_SIZE as s; print(f'{s[0]}x{s[1]}')")
|
||||
CAMERA_RES=$(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}')")
|
||||
|
||||
TG_FLAGS_QCOM="DEV=MOCK+QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 OPENPILOT_HACKS=1"
|
||||
MOCK=$([ "$MOCK_BUILD" = "true" ] && echo MOCK || true)
|
||||
TG_FLAGS_QCOM="DEV=${MOCK:+MOCK+}QCOM IMAGE=1 FLOAT16=1 NOLOCALS=1 OPENPILOT_HACKS=1"
|
||||
if [ "${{ inputs.target_hardware }}" == "chestnut" ]; then
|
||||
echo "CHESTNUT build"
|
||||
export CHESTNUT=1
|
||||
TG_FLAGS="DEBUG=1 DEV=MOCKUSB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 GMMU=0 TC_OPT=2 TC_MIN_GLOBALS=32"
|
||||
TG_FLAGS="DEBUG=1 DEV=${MOCK}USB+AMD:LLVM FRAME_DEV=CPU FLOAT16=1 GMMU=0 TC_OPT=2 TC_MIN_GLOBALS=32"
|
||||
OUTPUT_PKL="${{ env.MODELS_DIR }}/big_driving_tinygrad.pkl"
|
||||
else
|
||||
echo "QCOM build"
|
||||
@@ -239,15 +339,17 @@ jobs:
|
||||
echo "Converting commaai's precompiled model with tinygrad $TG_SHA"
|
||||
UPSTREAM_TG="${{ runner.temp }}/upstream_tinygrad"
|
||||
rm -rf "$UPSTREAM_TG" && git init -q "$UPSTREAM_TG" && git -C "$UPSTREAM_TG" fetch -q --depth 1 "$TG_URL" "$TG_SHA" && git -C "$UPSTREAM_TG" checkout -q FETCH_HEAD
|
||||
ON_MOCK=""
|
||||
if [ "$MOCK_BUILD" = "true" ]; then ON_MOCK="env PYTHONPATH=$TINYGRAD_PATH python3 $TINYGRAD_PATH/test/mockgpu/usb_server.py"; fi
|
||||
CONVERTED="${{ runner.temp }}/big_driving_tinygrad_plain.pkl"
|
||||
env PYTHONPATH="$TINYGRAD_PATH" python3 "$TINYGRAD_PATH/test/mockgpu/usb_server.py" env DEV=USB+AMD PYTHONPATH="$UPSTREAM_TG:${{ github.workspace }}" python3 openpilot/sunnypilot/modeld_v2/convert_upstream_pkl.py \
|
||||
$ON_MOCK env DEV=USB+AMD PYTHONPATH="$UPSTREAM_TG:${{ github.workspace }}" $TASKSET python3 openpilot/sunnypilot/modeld_v2/convert_upstream_pkl.py \
|
||||
"${{ env.MODELS_DIR }}/big_driving_tinygrad.pkl" "$CONVERTED"
|
||||
mv "$CONVERTED" "$OUTPUT_PKL"
|
||||
elif NEW_ARCH_ONNX=$(find "${{ env.MODELS_DIR }}" -maxdepth 1 -name "${{ inputs.target_hardware == 'chestnut' && 'big_' || '' }}*driving*.onnx" -print -quit) &&
|
||||
[ -n "$NEW_ARCH_ONNX" ] && grep -qa new_img "$NEW_ARCH_ONNX"; then # the new architecture: one ONNX taking the warped frames as new_img
|
||||
echo "Compiling new architecture ONNX: $NEW_ARCH_ONNX"
|
||||
env ${TG_FLAGS} python3 openpilot/sunnypilot/modeld_v2/compile_modeld_v2.py \
|
||||
"$NEW_ARCH_ONNX" "$OUTPUT_PKL" --device-input "*" --benchmark-runs 0
|
||||
env ${TG_FLAGS} $TASKSET python3 openpilot/sunnypilot/modeld_v2/compile_modeld_v2.py \
|
||||
"$NEW_ARCH_ONNX" "$OUTPUT_PKL" --device-input "*" --benchmark-runs $([ "$MOCK_BUILD" = "true" ] && echo 0 || echo 1)
|
||||
else
|
||||
echo "Detected onnx architecture. Routing to native compile_modeld.py."
|
||||
# Detect model type and build compile args
|
||||
@@ -296,7 +398,7 @@ jobs:
|
||||
|
||||
if [ -n "$MODEL_TYPE" ]; then
|
||||
echo "Detected: $MODEL_TYPE -> $OUTPUT_PKL"
|
||||
env ${TG_FLAGS} python3 "$COMPILE_MODELD" \
|
||||
env ${TG_FLAGS} $TASKSET python3 "$COMPILE_MODELD" \
|
||||
--model-type $MODEL_TYPE \
|
||||
--model-size $MODEL_SIZE \
|
||||
--camera-resolutions $CAMERA_RES \
|
||||
@@ -306,6 +408,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Replay its check frame on the mock and require the result bit for bit
|
||||
if: env.MOCK_BUILD == 'true'
|
||||
env:
|
||||
DEV: ${{ inputs.target_hardware == 'chestnut' && 'MOCKUSB+AMD' || 'MOCK+QCOM' }}
|
||||
PYTHONPATH: ${{ env.TINYGRAD_PATH }}:${{ github.workspace }}
|
||||
@@ -322,6 +425,7 @@ jobs:
|
||||
--include='/${{ inputs.target_hardware == 'chestnut' && 'big_' || '' }}driving_tinygrad.pkl' \
|
||||
--exclude='*' \
|
||||
--delete-excluded \
|
||||
$([ "$MOCK_BUILD" = "true" ] || echo --chown=comma:comma) \
|
||||
${{ env.MODELS_DIR }}/ ${{ env.OUTPUT_DIR }}/
|
||||
|
||||
python3 "${{ github.workspace }}/release/ci/model_generator.py" \
|
||||
@@ -348,3 +452,9 @@ jobs:
|
||||
with:
|
||||
name: artifact-name-${{ inputs.custom_name || inputs.upstream_branch }}
|
||||
path: ${{ env.OUTPUT_DIR }}/artifact_name.txt
|
||||
|
||||
- name: Re-enable powersave
|
||||
if: always() && env.MOCK_BUILD != 'true'
|
||||
run: |
|
||||
source ${UV_PROJECT_ENVIRONMENT}/bin/activate
|
||||
PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/ ${{ github.workspace }}/scripts/manage-powersave.py --enable
|
||||
|
||||
@@ -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
|
||||
@@ -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-2fac79a"
|
||||
fi
|
||||
|
||||
export STAGING_ROOT="/data/safe_staging"
|
||||
|
||||
+1
-1
Submodule msgq_repo updated: 5ae2281f6f...845ef590d8
+1
-1
Submodule opendbc_repo updated: 07fb3ab9bc...eebeba9584
@@ -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-549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10.img.xz",
|
||||
"hash": "549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10",
|
||||
"hash_raw": "549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10",
|
||||
"size": 47855616,
|
||||
"sparse": false,
|
||||
"full_check": true,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "3519123cc1ec417e56ed2bdd449094e6e6e38ecb610ea4452dd44d5bdce5604c"
|
||||
"ondevice_hash": "7d0a8ec435d9840fa010b2661fd3588993b756e6d09501b934573d3c89896b3f"
|
||||
},
|
||||
{
|
||||
"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-a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016.img.xz",
|
||||
"hash": "1b4a360c5bd0ba30c50dbcf7d6a180b602fe7ff20989aab1d4252661fa28be6e",
|
||||
"hash_raw": "a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016",
|
||||
"size": 2147483648,
|
||||
"sparse": true,
|
||||
"full_check": false,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "b2fc71b9071ddb0664a7e3a837df8d57ee36a2befabd8f044eb8be8d73ee66b7",
|
||||
"ondevice_hash": "5bbe888093d4b5468fe2707723bc519f0334dbc9f236281602811af4534ff7c6",
|
||||
"alt": {
|
||||
"hash": "ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-ec939431c59751372e34d669fce1b08494b391019534b5d7f690b87991ea159e.img",
|
||||
"hash": "a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016.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-549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10.img.xz",
|
||||
"hash": "549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10",
|
||||
"hash_raw": "549c739c15904d887619440f21c5df8849b8b545d5a9eab118f967a40856cc10",
|
||||
"size": 47855616,
|
||||
"sparse": false,
|
||||
"full_check": true,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "daefa6f897bdcc277e50dbf562fd63e57d50d9fc7a599f2d171208a490e725d9"
|
||||
"ondevice_hash": "7d0a8ec435d9840fa010b2661fd3588993b756e6d09501b934573d3c89896b3f"
|
||||
},
|
||||
{
|
||||
"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-a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016.img.xz",
|
||||
"hash": "1b4a360c5bd0ba30c50dbcf7d6a180b602fe7ff20989aab1d4252661fa28be6e",
|
||||
"hash_raw": "a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016",
|
||||
"size": 2147483648,
|
||||
"sparse": true,
|
||||
"full_check": false,
|
||||
"has_ab": true,
|
||||
"ondevice_hash": "18666ca3b529304f5e7a8fc2e3c9dce715b55941e3965a7af43c613f8e18cfce",
|
||||
"ondevice_hash": "5bbe888093d4b5468fe2707723bc519f0334dbc9f236281602811af4534ff7c6",
|
||||
"alt": {
|
||||
"hash": "2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d",
|
||||
"url": "https://commadist.azureedge.net/agnosupdate/system-2e1ca22762e66898aae384fcc21f488cb015c020b6b588862a64fc8128f0ad1d.img",
|
||||
"size": 4718592000
|
||||
"hash": "a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016",
|
||||
"url": "https://huggingface.co/sunnypilot/agnos-ci/resolve/main/pr-20/system-a228d9f809d80ac733c6c86b3bf0428cc8455c03ce4b8718610978413a3e7016.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}},
|
||||
@@ -231,6 +234,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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -28,8 +28,6 @@ class DesireHelper:
|
||||
self.alc = AutoLaneChangeController(self)
|
||||
self.lane_turn_controller = LaneTurnController(self)
|
||||
self.lane_turn_direction = TurnDirection.none
|
||||
self.turn_frames = 0
|
||||
self.turn_repulse = 98
|
||||
|
||||
@staticmethod
|
||||
def get_lane_change_direction(CS):
|
||||
@@ -97,10 +95,8 @@ class DesireHelper:
|
||||
self.prev_one_blinker = one_blinker and lateral_active
|
||||
|
||||
if self.lane_turn_direction != TurnDirection.none:
|
||||
self.turn_frames += 1
|
||||
self.desire = TURN_DESIRES[self.lane_turn_direction] if self.turn_frames % self.turn_repulse else log.Desire.none
|
||||
self.desire = TURN_DESIRES[self.lane_turn_direction]
|
||||
else:
|
||||
self.turn_frames = 0
|
||||
self.desire = log.Desire.none
|
||||
if self.lane_change_state == LaneChangeState.laneChangeStarting:
|
||||
if self.lane_change_direction == LaneChangeDirection.left:
|
||||
|
||||
@@ -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: ...
|
||||
@@ -7,13 +7,13 @@ from opendbc.car.interfaces import ACCEL_MIN, ACCEL_MAX
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
# WARNING: imports outside of constants will not trigger a rebuild
|
||||
from openpilot.selfdrive.modeld.constants import index_function, ModelConstants
|
||||
from openpilot.selfdrive.modeld.constants import index_function
|
||||
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
|
||||
|
||||
@@ -56,12 +56,6 @@ COMFORT_BRAKE = 2.5
|
||||
STOP_DISTANCE = 6.0
|
||||
MIN_X_LEAD_FACTOR = 0.5
|
||||
|
||||
# model/radar fusion
|
||||
RADAR_RESIDUAL_DECAY_T = 2.0
|
||||
RADAR_RESIDUAL_W = np.exp(-T_IDXS / RADAR_RESIDUAL_DECAY_T)
|
||||
CLIP_MODEL_LEAD_ACCEL = 2.0
|
||||
LEAD_FALLBACK_RANGE = [2.5, 3.5]
|
||||
|
||||
def get_jerk_factor(personality=log.LongitudinalPersonality.standard):
|
||||
if personality==log.LongitudinalPersonality.relaxed:
|
||||
return 1.0
|
||||
@@ -81,8 +75,8 @@ def get_T_FOLLOW(personality=log.LongitudinalPersonality.standard):
|
||||
else:
|
||||
raise NotImplementedError("Longitudinal personality not supported")
|
||||
|
||||
def get_stopped_equivalence_factor(v_lead, brake=COMFORT_BRAKE):
|
||||
return (v_lead**2) / (2 * brake)
|
||||
def get_stopped_equivalence_factor(v_lead):
|
||||
return (v_lead**2) / (2 * COMFORT_BRAKE)
|
||||
|
||||
def get_safe_obstacle_distance(v_ego, t_follow):
|
||||
return (v_ego**2) / (2 * COMFORT_BRAKE) + t_follow * v_ego + STOP_DISTANCE
|
||||
@@ -203,7 +197,7 @@ def gen_long_ocp():
|
||||
|
||||
# More iterations take too much time and less lead to inaccurate convergence in
|
||||
# some situations. Ideally we would run just 1 iteration to ensure fixed runtime.
|
||||
ocp.solver_options.qp_solver_iter_max = 20
|
||||
ocp.solver_options.qp_solver_iter_max = 10
|
||||
ocp.solver_options.qp_tol = 1e-3
|
||||
|
||||
# set prediction horizon
|
||||
@@ -280,26 +274,26 @@ class LongitudinalMpc:
|
||||
self.solver.set(i, 'x', self.x0)
|
||||
|
||||
@staticmethod
|
||||
def integrate_lead(x_lead, v_lead, a_lead_traj):
|
||||
def extrapolate_lead(x_lead, v_lead, a_lead, a_lead_tau):
|
||||
a_lead_traj = a_lead * np.exp(-a_lead_tau * (T_IDXS**2)/2.)
|
||||
v_lead_traj = np.clip(v_lead + np.cumsum(T_DIFFS * a_lead_traj), 0.0, 1e8)
|
||||
x_lead_traj = x_lead + np.cumsum(T_DIFFS * v_lead_traj)
|
||||
return np.column_stack((x_lead_traj, v_lead_traj))
|
||||
lead_xv = np.column_stack((x_lead_traj, v_lead_traj))
|
||||
return lead_xv
|
||||
|
||||
def process_lead(self, model_lead, radar_lead):
|
||||
def process_lead(self, lead):
|
||||
v_ego = self.x0[1]
|
||||
if radar_lead is not None and radar_lead.present:
|
||||
x_lead = radar_lead.dRel
|
||||
v_lead = radar_lead.vLead
|
||||
a_lead = radar_lead.aLeadK
|
||||
a_lead_tau = radar_lead.aLeadTau
|
||||
model_prob = radar_lead.modelProb
|
||||
if lead is not None and lead.present:
|
||||
x_lead = lead.dRel
|
||||
v_lead = lead.vLead
|
||||
a_lead = lead.aLeadK
|
||||
a_lead_tau = lead.aLeadTau
|
||||
else:
|
||||
# Fake a fast lead car, so mpc can keep running in the same mode
|
||||
x_lead = 50.0
|
||||
v_lead = v_ego + 10.0
|
||||
a_lead = 0.0
|
||||
a_lead_tau = _LEAD_ACCEL_TAU
|
||||
model_prob = 0.0
|
||||
|
||||
# MPC will not converge if immediate crash is expected
|
||||
# Clip lead distance to what is still possible to brake for
|
||||
@@ -307,34 +301,14 @@ class LongitudinalMpc:
|
||||
x_lead = np.clip(x_lead, min_x_lead, 1e8)
|
||||
v_lead = np.clip(v_lead, 0.0, 1e8)
|
||||
a_lead = np.clip(a_lead, -10., 5.)
|
||||
lead_xv = self.extrapolate_lead(x_lead, v_lead, a_lead, a_lead_tau)
|
||||
return lead_xv
|
||||
|
||||
# radar only lead traj estimate
|
||||
a_radar = a_lead * np.exp(-a_lead_tau * (T_IDXS**2) / 2.)
|
||||
radar_xv = self.integrate_lead(x_lead, v_lead, a_radar)
|
||||
|
||||
if model_lead is not None and model_prob > 0.5:
|
||||
a_model = np.interp(T_IDXS, ModelConstants.LEAD_T_IDXS, np.clip(model_lead.a, -10., CLIP_MODEL_LEAD_ACCEL))
|
||||
a_lead_traj = np.clip(a_model + (a_lead - a_model[0]) * RADAR_RESIDUAL_W, -10., np.maximum(a_radar, CLIP_MODEL_LEAD_ACCEL))
|
||||
lead_xv = self.integrate_lead(x_lead, v_lead, a_lead_traj)
|
||||
|
||||
# smoothly fall back to the more pessimistic radar trajectory when radar requires hard braking
|
||||
x_obs_radar = radar_xv[:, 0] + get_stopped_equivalence_factor(radar_xv[:, 1], brake=-ACCEL_MIN)
|
||||
a_req = v_ego**2 / (2. * max(np.min(x_obs_radar) - STOP_DISTANCE, 0.5))
|
||||
w = np.interp(a_req, LEAD_FALLBACK_RANGE, [0.0, 1.0])
|
||||
if w > 0.0:
|
||||
x_obs_fused_comfort = lead_xv[:, 0] + get_stopped_equivalence_factor(lead_xv[:, 1])
|
||||
x_obs_radar_comfort = radar_xv[:, 0] + get_stopped_equivalence_factor(radar_xv[:, 1])
|
||||
pessimistic = np.where((x_obs_radar_comfort < x_obs_fused_comfort)[:, None], radar_xv, lead_xv)
|
||||
lead_xv = (1.0 - w) * lead_xv + w * pessimistic
|
||||
return lead_xv
|
||||
|
||||
return radar_xv
|
||||
|
||||
def update(self, modelV2, radarstate, personality=log.LongitudinalPersonality.standard):
|
||||
def update(self, radarstate, personality=log.LongitudinalPersonality.standard):
|
||||
t_follow = get_T_FOLLOW(personality)
|
||||
|
||||
lead_xv_0 = self.process_lead(modelV2.leadsV3[0] if modelV2 is not None else None, radarstate.leadOne)
|
||||
lead_xv_1 = self.process_lead(modelV2.leadsV3[1] if modelV2 is not None else None, radarstate.leadTwo)
|
||||
lead_xv_0 = self.process_lead(radarstate.leadOne)
|
||||
lead_xv_1 = self.process_lead(radarstate.leadTwo)
|
||||
|
||||
# To estimate a safe distance from a moving lead, we calculate how much stopping
|
||||
# distance that lead needs as a minimum. We can add that to the current distance
|
||||
|
||||
@@ -90,10 +90,9 @@ class LongitudinalPlanner(LongitudinalPlannerSP):
|
||||
self.mpc.set_weights(prev_accel_constraint, personality=personality)
|
||||
if self.CP.openpilotLongitudinalControl:
|
||||
self.mpc.set_cur_state(self.v_desired_filter.x, self.output_a_target)
|
||||
self.mpc.update(sm['modelV2'], sm['radarState'], personality=personality)
|
||||
else:
|
||||
self.mpc.set_cur_state(v_ego, sm['carState'].aEgo)
|
||||
self.mpc.update(None, sm['radarState'], personality=personality)
|
||||
self.mpc.update(sm['radarState'], personality=personality)
|
||||
|
||||
self.v_desired_trajectory = np.interp(CONTROL_N_T_IDX, T_IDXS_MPC, self.mpc.v_solution)
|
||||
self.a_desired_trajectory = np.interp(CONTROL_N_T_IDX, T_IDXS_MPC, self.mpc.a_solution)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -52,13 +52,7 @@ std::vector<std::string> PandaSafety::fetchCarParams() {
|
||||
if (!params_.getBool("ControlsReady")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string car_params = params_.get("CarParams");
|
||||
std::string car_params_sp = params_.get("CarParamsSP");
|
||||
if (car_params.empty() || car_params_sp.empty()) {
|
||||
return {};
|
||||
}
|
||||
return {car_params, car_params_sp};
|
||||
return {params_.get("CarParams"), params_.get("CarParamsSP")};
|
||||
}
|
||||
|
||||
// TODO-SP: Use structs instead of vector
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -8,10 +8,7 @@ from openpilot.common.constants import CV
|
||||
from openpilot.common.realtime import DT_MDL
|
||||
from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState
|
||||
from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner
|
||||
from openpilot.selfdrive.controls.radard import KalmanParams, RADAR_TO_CAMERA, Track
|
||||
from openpilot.selfdrive.modeld.constants import ModelConstants
|
||||
|
||||
LEAD_STEPS = (np.asarray(ModelConstants.LEAD_T_IDXS) / DT_MDL).astype(int)
|
||||
from openpilot.selfdrive.controls.radard import _LEAD_ACCEL_TAU
|
||||
|
||||
|
||||
class Maneuver:
|
||||
@@ -35,10 +32,8 @@ class Maneuver:
|
||||
# perception
|
||||
self.lead_relevancy = kwargs.get("lead_relevancy", False)
|
||||
self.only_lead2 = kwargs.get("only_lead2", False)
|
||||
self.only_radar = kwargs.get("only_radar", False)
|
||||
only_radar = kwargs.get("only_radar", False)
|
||||
prob_lead_values = kwargs.get("prob_lead_values", [1.0] * len(breakpoints))
|
||||
model_v_lead_values = kwargs.get("model_speed_lead_values", None)
|
||||
model_breakpoints = kwargs.get("model_breakpoints", breakpoints)
|
||||
|
||||
# ego state, to be simulated
|
||||
n_steps = round(duration / DT_MDL)
|
||||
@@ -49,50 +44,29 @@ class Maneuver:
|
||||
self.v_ego[0] = initial_v_ego
|
||||
|
||||
# lead state, known in advance
|
||||
# extend so we can populate fake model predicted traj
|
||||
lead_t = np.arange(n_steps + LEAD_STEPS[-1] + 1) * DT_MDL
|
||||
self.v_lead = np.interp(lead_t, breakpoints, v_lead_values)
|
||||
self.v_lead = np.interp(self.t, breakpoints, v_lead_values)
|
||||
self.a_lead = np.diff(self.v_lead, prepend=0.0) / DT_MDL
|
||||
self.x_lead = np.cumsum(np.r_[initial_x_lead, self.v_lead[:-1] * DT_MDL])
|
||||
if model_v_lead_values is not None:
|
||||
self.model_v_lead = np.interp(lead_t, model_breakpoints, model_v_lead_values)
|
||||
self.model_a_lead = np.diff(self.model_v_lead, prepend=self.model_v_lead[0]) / DT_MDL
|
||||
self.model_x_lead = np.cumsum(np.r_[initial_x_lead, self.model_v_lead[:-1] * DT_MDL])
|
||||
else:
|
||||
self.model_v_lead = self.v_lead
|
||||
self.model_a_lead = self.a_lead
|
||||
self.model_x_lead = self.x_lead
|
||||
self.prob_lead = np.zeros_like(self.t) if self.only_radar else np.interp(self.t, breakpoints, prob_lead_values)
|
||||
self.lead_present = np.logical_and(self.lead_relevancy, np.logical_or(self.only_radar, self.prob_lead > 0.5))
|
||||
self.prob_lead = np.interp(self.t, breakpoints, prob_lead_values)
|
||||
self.lead_present = np.logical_and(self.lead_relevancy, np.logical_or(only_radar, self.prob_lead > 0.5))
|
||||
self.v_cruise = np.interp(self.t, breakpoints, v_cruise_values)
|
||||
|
||||
def _make_messages(self, i):
|
||||
v_ego = float(self.v_ego[i])
|
||||
v_lead = float(self.v_lead[i])
|
||||
prob = float(self.prob_lead[i]) if self.lead_relevancy else 0.0
|
||||
d_rel = max(0., float(self.x_lead[i] - self.x_ego[i])) if self.lead_relevancy else 200.
|
||||
v_rel = v_lead - v_ego if self.lead_relevancy else 0.
|
||||
self.track.update(d_rel, 0.0, v_rel, v_lead)
|
||||
lead = log.RadarState.LeadData(**(self.track.get_RadarState(prob) | {'present': bool(self.lead_present[i])}))
|
||||
lead = log.RadarState.LeadData(
|
||||
dRel=max(0., float(self.x_lead[i] - self.x_ego[i])) if self.lead_relevancy else 200.,
|
||||
vRel=v_lead - v_ego if self.lead_relevancy else 0.,
|
||||
vLead=v_lead, vLeadK=v_lead, aLeadK=float(self.a_lead[i]), aLeadTau=_LEAD_ACCEL_TAU,
|
||||
present=bool(self.lead_present[i]), modelProb=prob, radar=True,
|
||||
)
|
||||
radar = log.RadarState(leadTwo=lead)
|
||||
if not self.only_lead2:
|
||||
radar.leadOne = lead
|
||||
|
||||
model = log.ModelDataV2()
|
||||
future = i + LEAD_STEPS
|
||||
camera_x = self.x_ego[i] - RADAR_TO_CAMERA
|
||||
future_x = (self.x_lead[i] + (self.model_x_lead[future] - self.model_x_lead[i]) - camera_x).tolist()
|
||||
future_v = self.model_v_lead[future].tolist()
|
||||
future_a = self.model_a_lead[future].tolist()
|
||||
for j, model_lead in enumerate(model.init('leadsV3', len(ModelConstants.LEAD_T_OFFSETS))):
|
||||
model_lead.prob = 0.0 if self.only_lead2 and j != 1 else prob
|
||||
model_lead.probTime = ModelConstants.LEAD_T_OFFSETS[j]
|
||||
model_lead.t = ModelConstants.LEAD_T_IDXS
|
||||
model_lead.x = future_x
|
||||
model_lead.v = future_v
|
||||
model_lead.a = future_a
|
||||
|
||||
# Model requests more acceleration so the lead policy must handle slowdowns.
|
||||
model = log.ModelDataV2()
|
||||
model.action.desiredAcceleration = float(self.a_ego[i] + 0.5)
|
||||
return {
|
||||
'radarState': radar,
|
||||
@@ -123,12 +97,10 @@ class Maneuver:
|
||||
CP = CarInterface.get_non_essential_params(CAR.HONDA_CIVIC)
|
||||
CP_SP = CarInterface.get_non_essential_params_sp(CP, CAR.HONDA_CIVIC)
|
||||
self.planner = LongitudinalPlanner(CP, CP_SP, init_v=self.v_ego[0])
|
||||
self.track = Track(0, float(self.v_lead[0]), KalmanParams(DT_MDL))
|
||||
for i in range(len(self.t) - 1):
|
||||
self._step(i)
|
||||
|
||||
x_lead, v_lead = self.x_lead[:len(self.t)], self.v_lead[:len(self.t)]
|
||||
d_rel = x_lead - self.x_ego
|
||||
d_rel = self.x_lead - self.x_ego
|
||||
|
||||
valid = True
|
||||
if np.any(d_rel[self.lead_present] < 0.4):
|
||||
@@ -137,7 +109,7 @@ class Maneuver:
|
||||
|
||||
if self.ensure_start and self.lead_relevancy:
|
||||
not_starting_since = None
|
||||
not_starting = (v_lead > self.v_ego) & (self.a_ego < 1e-3)
|
||||
not_starting = (self.v_lead > self.v_ego) & (self.a_ego < 1e-3)
|
||||
for now, waiting in zip(self.t, not_starting, strict=True):
|
||||
if not waiting:
|
||||
not_starting_since = None
|
||||
@@ -153,5 +125,5 @@ class Maneuver:
|
||||
valid = False
|
||||
|
||||
print('maneuver end', valid)
|
||||
logs = np.column_stack((self.t, self.x_ego, x_lead, self.v_ego, v_lead, self.a_ego, d_rel))
|
||||
logs = np.column_stack((self.t, self.x_ego, self.x_lead, self.v_ego, self.v_lead, self.a_ego, d_rel))
|
||||
return valid, logs
|
||||
|
||||
@@ -2,7 +2,6 @@ from openpilot.common.test import OpenpilotTestCase
|
||||
from openpilot.common.parameterized import parameterized
|
||||
|
||||
from openpilot.selfdrive.controls.lib.longitudinal_mpc_lib.long_mpc import STOP_DISTANCE
|
||||
from openpilot.selfdrive.selfdrived.selfdrived import LONGITUDINAL_PERSONALITY_MAP
|
||||
from openpilot.selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver
|
||||
|
||||
|
||||
@@ -142,134 +141,9 @@ def create_maneuvers(kwargs):
|
||||
return maneuvers
|
||||
|
||||
|
||||
def create_approach_stopped_adv_maneuvers(kwargs):
|
||||
return [
|
||||
Maneuver(
|
||||
f"approaching stopped lead that doesn't go ({v0:g}m/s from {d0:g}m), "
|
||||
+ ("radar only" if model_a is None else f"model wrongly predicts +{model_a:g}m/s^2"),
|
||||
duration=duration,
|
||||
initial_speed=v0,
|
||||
lead_relevancy=True,
|
||||
initial_distance_lead=d0,
|
||||
speed_lead_values=[0., 0.],
|
||||
breakpoints=[0., duration],
|
||||
model_speed_lead_values=None if model_a is None else [0., model_a * (duration + 15.)],
|
||||
model_breakpoints=[0., duration + 15.],
|
||||
only_radar=model_a is None,
|
||||
**kwargs,
|
||||
)
|
||||
for v0, d0, duration in ((30., 200., 25.), (15., 70., 20.), (8., 25., 18.))
|
||||
for model_a in (None, 1., 2., 4.)
|
||||
]
|
||||
|
||||
|
||||
def create_stopped_adv_maneuvers(kwargs):
|
||||
return [
|
||||
Maneuver(
|
||||
f"stopped behind a lead that doesn't go ({d0:g}m), "
|
||||
+ ("radar only" if model_a is None else f"model wrongly predicts +{model_a:g}m/s^2"),
|
||||
duration=20.,
|
||||
initial_speed=0.,
|
||||
lead_relevancy=True,
|
||||
initial_distance_lead=d0,
|
||||
speed_lead_values=[0., 0.],
|
||||
breakpoints=[0., 20.],
|
||||
model_speed_lead_values=None if model_a is None else [0., model_a * 35.],
|
||||
model_breakpoints=[0., 35.],
|
||||
only_radar=model_a is None,
|
||||
**kwargs,
|
||||
)
|
||||
for d0 in (STOP_DISTANCE, 4.)
|
||||
for model_a in (None, 1., 2., 4.)
|
||||
]
|
||||
|
||||
|
||||
def create_hard_braking_adv_maneuvers(kwargs):
|
||||
return [
|
||||
Maneuver(
|
||||
f"steady following ({v0:g}m/s) then lead brakes hard (-{decel:g}m/s^2), "
|
||||
+ ("radar only" if model_a is None else f"model wrongly predicts {model_a:+g}m/s^2"),
|
||||
duration=15. + v0 / decel + 10.,
|
||||
initial_speed=v0,
|
||||
cruise_values=[v0, v0, v0],
|
||||
lead_relevancy=True,
|
||||
initial_distance_lead=d0,
|
||||
speed_lead_values=[v0, v0, 0.],
|
||||
breakpoints=[0., 15., 15. + v0 / decel],
|
||||
model_speed_lead_values=None if model_a is None else [v0, v0, v0 + model_a * (v0 / decel + 25.)],
|
||||
model_breakpoints=[0., 15., 15. + v0 / decel + 25.],
|
||||
only_radar=model_a is None,
|
||||
**kwargs,
|
||||
)
|
||||
for v0, d0 in ((10., 20.), (20., 35.), (30., 50.))
|
||||
for decel in (2., 3., 3.5)
|
||||
for model_a in (None, 0., 2.)
|
||||
]
|
||||
|
||||
|
||||
def create_approach_slower_adv_maneuvers(kwargs):
|
||||
return [
|
||||
Maneuver(
|
||||
f"approaching slower lead ({v0:g}m/s to {v_lead:g}m/s from {d0:g}m), "
|
||||
+ ("radar only" if model_a is None else f"model wrongly predicts +{model_a:g}m/s^2"),
|
||||
duration=40.,
|
||||
initial_speed=v0,
|
||||
cruise_values=[v0, v0],
|
||||
lead_relevancy=True,
|
||||
initial_distance_lead=d0,
|
||||
speed_lead_values=[v_lead, v_lead],
|
||||
breakpoints=[0., 40.],
|
||||
model_speed_lead_values=None if model_a is None else [v_lead, v_lead + model_a * 55.],
|
||||
model_breakpoints=[0., 55.],
|
||||
only_radar=model_a is None,
|
||||
**kwargs,
|
||||
)
|
||||
for v0, v_lead, d0 in ((30., 15., 100.), (25., 10., 80.), (20., 10., 60.))
|
||||
for model_a in (None, 1., 2., 4.)
|
||||
]
|
||||
|
||||
|
||||
def create_cutin_adv_maneuvers(kwargs):
|
||||
return [
|
||||
Maneuver(
|
||||
f"slower cut-in ({v0:g}m/s to {v_lead:g}m/s at {d0:g}m), "
|
||||
+ ("radar only" if model_a is None else f"model wrongly predicts +{model_a:g}m/s^2"),
|
||||
duration=40.,
|
||||
initial_speed=v0,
|
||||
cruise_values=[v0, v0],
|
||||
lead_relevancy=True,
|
||||
initial_distance_lead=d0,
|
||||
speed_lead_values=[v_lead, v_lead],
|
||||
breakpoints=[0., 40.],
|
||||
model_speed_lead_values=None if model_a is None else [v_lead, v_lead + model_a * 55.],
|
||||
model_breakpoints=[0., 55.],
|
||||
only_radar=model_a is None,
|
||||
**kwargs,
|
||||
)
|
||||
for v0, v_lead, d0 in ((10., 5., 12.), (20., 15., 21.), (30., 25., 30.))
|
||||
for model_a in (None, 1., 2., 4.)
|
||||
]
|
||||
|
||||
|
||||
def create_adv_maneuvers(kwargs):
|
||||
return (
|
||||
create_approach_stopped_adv_maneuvers(kwargs)
|
||||
+ create_stopped_adv_maneuvers(kwargs)
|
||||
+ create_hard_braking_adv_maneuvers(kwargs)
|
||||
+ create_approach_slower_adv_maneuvers(kwargs)
|
||||
+ create_cutin_adv_maneuvers(kwargs)
|
||||
)
|
||||
|
||||
|
||||
class TestLongitudinalControl(OpenpilotTestCase):
|
||||
@parameterized.expand([m for force_decel in (True, False) for m in create_maneuvers({"force_decel": force_decel})],
|
||||
ids=lambda m: f"{m.title}_force_decel_{m.force_decel}")
|
||||
def test_maneuver(self, maneuver):
|
||||
valid, _ = maneuver.evaluate()
|
||||
assert valid
|
||||
|
||||
@parameterized.expand([m for p in LONGITUDINAL_PERSONALITY_MAP for m in create_adv_maneuvers({"personality": p})],
|
||||
ids=lambda m: f"{m.title}_personality_{LONGITUDINAL_PERSONALITY_MAP[m.personality]}")
|
||||
def test_adv_maneuver(self, maneuver):
|
||||
valid, _ = maneuver.evaluate()
|
||||
assert valid
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -35,10 +35,9 @@ class MainLayout(Widget):
|
||||
# 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 +62,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 +106,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
|
||||
|
||||
@@ -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 raylib_nb 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,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,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 raylib_nb 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
|
||||
@@ -261,7 +253,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,8 +8,6 @@ import numpy as np
|
||||
|
||||
from openpilot.common.transformations.camera import DEVICE_CAMERAS
|
||||
|
||||
MAX_CAMERA_OFFSET = 0.35 # m, the settings' range
|
||||
|
||||
|
||||
class CameraOffsetHelper:
|
||||
def __init__(self):
|
||||
@@ -36,13 +34,6 @@ class CameraOffsetHelper:
|
||||
def set_offset(self, offset):
|
||||
self.camera_offset = offset
|
||||
|
||||
def load_offset(self, params):
|
||||
offset = params.get("CameraOffset", return_default=True)
|
||||
if offset is None or not np.isfinite(offset) or abs(offset) > MAX_CAMERA_OFFSET + 1e-6: # older sunnypilot stored whole centimeters
|
||||
offset = 0.0
|
||||
params.put("CameraOffset", offset)
|
||||
self.set_offset(offset)
|
||||
|
||||
def update(self, model_transform_main, model_transform_extra, sm, main_wide_camera):
|
||||
self.actual_camera_offset = (0.9 * self.actual_camera_offset) + (0.1 * self.camera_offset)
|
||||
dc = DEVICE_CAMERAS[(str(sm['deviceState'].deviceType), str(sm['narrowRoadCameraState'].sensor))]
|
||||
|
||||
@@ -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)
|
||||
@@ -373,7 +370,38 @@ def _compile_warp_resolution_worker(cam_w, cam_h, model_w, model_h, benchmark_ru
|
||||
write_bundle(result_path, {(cam_w, cam_h): compiled_jit}, {'device': Device.DEFAULT})
|
||||
|
||||
|
||||
def chestnut_link_up() -> bool:
|
||||
# asm enumerates on USB-C alone, gpu is only usable once pcie link is up (upstream dropped flash.link_up in #39195)
|
||||
import ctypes
|
||||
import fcntl
|
||||
from openpilot.system.hardware.chestnut.flash import USBDEVFS_CONTROL, Ctrl, find_chestnut, open_device
|
||||
try:
|
||||
path, _, _ = find_chestnut()
|
||||
if path is None:
|
||||
return False
|
||||
fd = open_device(path)
|
||||
except (OSError, RuntimeError):
|
||||
return False
|
||||
try:
|
||||
fcntl.ioctl(fd, USBDEVFS_CONTROL, Ctrl(0x40, 0xF3, 1, 0, 0, 2000, None))
|
||||
buf = (ctypes.c_ubyte * 1)()
|
||||
fcntl.ioctl(fd, USBDEVFS_CONTROL, Ctrl(0xC0, 0xE4, 0xB450, 0, 1, 1000, ctypes.cast(buf, ctypes.c_void_p)))
|
||||
return buf[0] == 0x78 # LTSSM L0
|
||||
except OSError:
|
||||
return False
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if ('USB' in os.getenv('DEV', '') or os.getenv('CHESTNUT')) and not os.getenv('DEV', '').startswith('MOCK'):
|
||||
for _ in range(10):
|
||||
if chestnut_link_up():
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError("Chestnut not ready, skipping big model build")
|
||||
|
||||
parser = argparse.ArgumentParser(description="Compile combined JIT pkl for sunnypilot modeld_v2")
|
||||
parser.add_argument('--model-type', choices=MODEL_TYPES, required=True)
|
||||
parser.add_argument('--model-size', type=_parse_size, required=True, help='model input WxH')
|
||||
@@ -390,7 +418,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':
|
||||
|
||||
@@ -17,7 +17,6 @@ def main():
|
||||
parser.add_argument("--frame", required=True, help="width,height,stride,y_height,uv_height,buffer_size")
|
||||
parser.add_argument("--warp-to", required=True, help="model input WxH")
|
||||
parser.add_argument("--output", required=True)
|
||||
parser.add_argument("--light", action="store_true")
|
||||
parser.add_argument("--split-frames", action="store_true", help="one input per camera (frame, big_frame), bound to the camera buffers by pointer")
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -25,20 +24,18 @@ def main():
|
||||
from tinygrad import Device, Tensor, TinyJit
|
||||
frame = parse_frame(args.frame)
|
||||
warp = make_frame_prepare(frame, *parse_size(args.warp_to))
|
||||
n = 1 if args.light else 2
|
||||
cams = list(range(n))
|
||||
rng = np.random.default_rng(42)
|
||||
frames = rng.integers(0, 256, (2, frame.size), dtype=np.uint8)
|
||||
m_inv = Tensor((rng.standard_normal((n, 3, 3)) * 8).astype(np.float32), device=Device.DEFAULT).realize()
|
||||
m_inv = Tensor((rng.standard_normal((2, 3, 3)) * 8).astype(np.float32), device=Device.DEFAULT).realize()
|
||||
if args.split_frames:
|
||||
names = [("frame", "big_frame")[c] for c in cams]
|
||||
run = TinyJit(lambda M_inv, **f: Tensor.stack(*(warp(f[nm], M_inv[i]) for i, nm in enumerate(names))), prune=True)
|
||||
inputs = {nm: Tensor(frames[c], device=Device.DEFAULT).realize() for nm, c in zip(names, cams, strict=True)} | {"M_inv": m_inv}
|
||||
specs = {nm: ((frame.size,), "|u1", Device.DEFAULT) for nm in names} | {"M_inv": ((n, 3, 3), "<f4", Device.DEFAULT)} # noqa: C420
|
||||
run = TinyJit(lambda frame, big_frame, M_inv: Tensor.stack(warp(frame, M_inv[0]), warp(big_frame, M_inv[1])), prune=True)
|
||||
inputs = {"frame": Tensor(frames[0], device=Device.DEFAULT).realize(), "big_frame": Tensor(frames[1], device=Device.DEFAULT).realize(), "M_inv": m_inv}
|
||||
specs = {"frame": ((frame.size,), "|u1", Device.DEFAULT), "big_frame": ((frame.size,), "|u1", Device.DEFAULT),
|
||||
"M_inv": ((2, 3, 3), "<f4", Device.DEFAULT)}
|
||||
else:
|
||||
run = TinyJit(lambda input_frame, M_inv: Tensor.stack(*(warp(input_frame[c], M_inv[i]) for i, c in enumerate(cams))), prune=True)
|
||||
run = TinyJit(lambda input_frame, M_inv: Tensor.stack(*(warp(input_frame[i], M_inv[i]) for i in range(2))), prune=True)
|
||||
inputs = {"input_frame": Tensor(frames, device=Device.DEFAULT).realize(), "M_inv": m_inv}
|
||||
specs = {"input_frame": ((2, frame.size), "|u1", Device.DEFAULT), "M_inv": ((n, 3, 3), "<f4", Device.DEFAULT)}
|
||||
specs = {"input_frame": ((2, frame.size), "|u1", Device.DEFAULT), "M_inv": ((2, 3, 3), "<f4", Device.DEFAULT)}
|
||||
with record_kernel_linear() as recorded:
|
||||
run(**inputs)
|
||||
run(**inputs)
|
||||
|
||||
@@ -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
|
||||
@@ -140,21 +138,6 @@ def _elf(image: bytes, rodata: int, entry: int) -> bytes:
|
||||
return b"\x7fELF\x02\x01\x01" + bytes(9) + header + data + b"".join(headers)
|
||||
|
||||
|
||||
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")
|
||||
|
||||
|
||||
def submit_kernels(jit) -> tuple:
|
||||
info = jit.captured._linear.src[0].without_after.arg
|
||||
return (info.hcq if hasattr(info, "hcq") else info.aux).kernels
|
||||
|
||||
|
||||
def convert(jit, kwargs: dict, frame: dict, target) -> tuple[dict, memoryview]:
|
||||
import tinygrad.runtime.autogen.am.pm4_nv as pm4
|
||||
import tinygrad.runtime.autogen.amd_gpu as amd_gpu
|
||||
@@ -163,9 +146,7 @@ def convert(jit, kwargs: dict, frame: dict, target) -> tuple[dict, memoryview]:
|
||||
from tinygrad.helpers import unwrap
|
||||
from tinygrad.uop.ops import Ops
|
||||
submit = jit.captured._linear.src[0].without_after
|
||||
kernels, topo = submit_kernels(jit), list(jit.captured._linear.toposort(enter_calls=True))
|
||||
externs = dict(enumerate(getattr(jit.captured, "_externs", ()), len(_prepare_jit_inputs((), kwargs)[0])))
|
||||
buffer = lambda b: _buffer(externs.get(b.arg.slot, b) if b.op.name == "EXTERN" else b) # noqa: E731
|
||||
kernels, topo = submit.arg.aux.kernels, list(jit.captured._linear.toposort(enter_calls=True))
|
||||
allocs = {str(name): u for u in topo if u.op is Ops.ALLOC and (name := getattr(u, "tag", None) or u.arg.name) is not None}
|
||||
(commands, patched), kernargs = _patched(allocs["cmdbuf_compute_0"], topo), allocs["kernargs_compute_0"]
|
||||
argument_words, pokes = _patched(kernargs, topo)[1], _input_pokes(submit, kernargs)
|
||||
@@ -221,12 +202,12 @@ def convert(jit, kwargs: dict, frame: dict, target) -> tuple[dict, memoryview]:
|
||||
needs_init |= {args[i]["buffer"] for i in ins if "buffer" in args[i] and args[i]["buffer"] not in written}
|
||||
written |= {args[i]["buffer"] for i in outs if "buffer" in args[i]}
|
||||
|
||||
assert all(buffer(b) is not None for b, i in buffers.items() if i in needs_init), "a kernel reads a scratch before any kernel writes it"
|
||||
assert all(_buffer(b) is not None for b, i in buffers.items() if i in needs_init), "a kernel reads a scratch before any kernel writes it"
|
||||
names = list(jit.captured.expected_names)
|
||||
inputs = [{"slot": slot, "name": names[slot] if slot < len(names) else None, "dtype": repr(u.dtype), "numel": int(u.max_numel()), "device": u.device}
|
||||
for slot, u in enumerate(_prepare_jit_inputs((), kwargs)[0])]
|
||||
header = {"input_names": names, "calls": calls, "returns": {"kind": "NoneType", "tensors": []}, "inputs": inputs,
|
||||
"buffers": [{"nbytes": bb.nbytes if (bb := buffer(b)) else b.max_numel() * b.dtype.itemsize, "device": bb.device if bb else b.device, "dtype": u8}
|
||||
"buffers": [{"nbytes": bb.nbytes if (bb := _buffer(b)) else b.max_numel() * b.dtype.itemsize, "device": bb.device if bb else b.device, "dtype": u8}
|
||||
| ({"init": blob.add(bb.ensure_allocated().as_memoryview())} if i in needs_init else {}) for b, i in buffers.items()],
|
||||
"check": {"inputs": [[path, store(array), device] for path, array, device in frame["inputs"]],
|
||||
"outputs": [store(array) for array in frame["outputs"]], "output_container": frame["output_container"]}}
|
||||
@@ -244,6 +225,7 @@ def main():
|
||||
patch_fetch_fw()
|
||||
from examples.openpilot.helpers import allocate_inputs, load_pickle
|
||||
from tinygrad import Device, Tensor
|
||||
from tinygrad.engine.realize import lower_and_compile
|
||||
artifact = load_pickle(args.pkl, out_of_band=True)
|
||||
artifact["run"].captured._linear = lower_and_compile(artifact["run"].captured._linear)
|
||||
rng = np.random.default_rng(7)
|
||||
@@ -257,7 +239,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)):
|
||||
|
||||
@@ -21,13 +21,6 @@ def pack_layout(shapes: dict[str, tuple], frame_size: int) -> tuple[dict[str, in
|
||||
offsets[name], offset = offset, offset + -(-math.prod(shape) * 4 // 128) * 128
|
||||
return offsets | {"frames": offset}, offset + 2 * frame_size
|
||||
|
||||
EXTRA_WARPS = {"light_img": "light_tfm"}
|
||||
SPLIT_FRAMES = ("big_frame", "frame")
|
||||
|
||||
def host_shapes(input_shapes: dict[str, tuple], states) -> dict[str, tuple]:
|
||||
shapes = {name: shape for name, shape in input_shapes.items() if name not in states and name != "new_img" and name not in EXTRA_WARPS}
|
||||
return shapes | {tfm: (1, 3, 3) for img, tfm in EXTRA_WARPS.items() if img in input_shapes}
|
||||
|
||||
|
||||
class _Blobs: # the model's and the warp's blobs as one address space, for a part whose ranges span both files
|
||||
def __init__(self, *blobs):
|
||||
@@ -39,47 +32,31 @@ class _Blobs: # the model's and the warp's blobs as one address space, for a pa
|
||||
|
||||
|
||||
def fused_with_warp(cam_w: int, cam_h: int, chestnut: bool): # load_model's extend: a native model runs upload, warp and model as one submit
|
||||
models, big = f"{BASEDIR}/openpilot/sunnypilot/modeld_v2/models", 'big_' if chestnut else ''
|
||||
return partial(frame_part, f"{models}/{big}driving_warp_{cam_w}x{cam_h}_tinygrad.pkl",
|
||||
light_warp_path=f"{models}/{big}driving_lightwarp_{cam_w}x{cam_h}_tinygrad.pkl")
|
||||
return partial(frame_part, f"{BASEDIR}/openpilot/sunnypilot/modeld_v2/models/{'big_' if chestnut else ''}driving_warp_{cam_w}x{cam_h}_tinygrad.pkl")
|
||||
|
||||
|
||||
def frame_part(warp_path: str, parts: dict, extras: dict, light_warp_path: str = "") -> dict:
|
||||
def frame_part(warp_path: str, parts: dict, extras: dict) -> dict:
|
||||
if "input_specs" not in extras: # a legacy model warps in its own parts
|
||||
return {}
|
||||
(model, model_blob), (warp, warp_blob) = parts["run"], read_parts(warp_path)[0]["run"]
|
||||
states = sorted(name for name in extras["input_specs"] if f"next_{name}" in extras["metadata"]["output_shapes"])
|
||||
host = host_shapes({name: shape for name, (shape, _, _) in extras["input_specs"].items()}, states)
|
||||
paths = {"light_img": light_warp_path}
|
||||
extra = [(img, tfm, *read_parts(paths[img])[0]["run"]) for img, tfm in EXTRA_WARPS.items() if img in extras["input_specs"]]
|
||||
split = any(s["name"] in SPLIT_FRAMES for s in warp["inputs"])
|
||||
assert all(any(s["name"] in SPLIT_FRAMES for s in part["inputs"]) == split for _, _, part, _ in extra), "camera and extra warps must share a frame layout"
|
||||
offsets, packed = pack_layout(host, 0 if split else next(s["numel"] for s in warp["inputs"] if s["name"] == "input_frame") // 2)
|
||||
shift = len(model_blob)
|
||||
buf_base, blob_base = [len(model["buffers"]) + len(warp["buffers"])], [len(model_blob) + len(warp_blob)]
|
||||
for _, _, part, blob in extra:
|
||||
buf_base.append(buf_base[-1] + len(part["buffers"]))
|
||||
blob_base.append(blob_base[-1] + len(blob))
|
||||
upload, u8 = buf_base[-1], repr(_dtype("dtypes.uint8"))
|
||||
extra_at = {img: (part, buf_base[i], blob_base[i], tfm) for i, (img, tfm, part, _) in enumerate(extra)}
|
||||
host = {name: shape for name, (shape, _, _) in extras["input_specs"].items() if name not in states and name != "new_img"}
|
||||
frame_specs = {s["name"]: s for s in warp["inputs"] if s["name"] in SPLIT_FRAMES}
|
||||
offsets, packed = pack_layout(host, 0 if frame_specs else next(s["numel"] for s in warp["inputs"] if s["name"] == "input_frame") // 2)
|
||||
shift, upload, u8 = len(model_blob), len(model["buffers"]) + len(warp["buffers"]), repr(_dtype("dtypes.uint8"))
|
||||
|
||||
def view(name: str, nbytes: int, dtype: str) -> dict:
|
||||
return {"buffer": upload, "offset": offsets[name], "nbytes": nbytes, "dtype": dtype}
|
||||
outputs = sorted(s["slot"] for s in model["inputs"] if s["name"] is None)
|
||||
frame_specs = {s["name"]: s for _, _, part, _ in [(None, None, warp, None), *extra] for s in part["inputs"] if s["name"] in SPLIT_FRAMES}
|
||||
names = sorted(["host", *states, *frame_specs])
|
||||
slots = {s["slot"]: names.index(s["name"]) for s in model["inputs"] if s["name"] in states} | \
|
||||
{slot: len(names) + i for i, slot in enumerate(outputs)}
|
||||
def warped(part: dict, base: int) -> dict:
|
||||
returned = part["returns"]["tensors"][0]
|
||||
return {k: v for k, v in returned.items() if k != "shape"} | {"buffer": returned["buffer"] + base}
|
||||
returned = warp["returns"]["tensors"][0]
|
||||
model_inputs = {s["slot"]: {"input": slots[s["slot"]]} if s["slot"] in slots else
|
||||
warped(warp, len(model["buffers"])) if s["name"] == "new_img" else
|
||||
warped(extra_at[s["name"]][0], extra_at[s["name"]][1]) if s["name"] in extra_at else
|
||||
{k: v for k, v in returned.items() if k != "shape"} | {"buffer": returned["buffer"] + len(model["buffers"])} if s["name"] == "new_img" else
|
||||
view(s["name"], s["numel"] * _dtype(s["dtype"]).itemsize, s["dtype"]) for s in model["inputs"]}
|
||||
def warp_inputs(part: dict, tfm: str) -> dict:
|
||||
return {s["slot"]: {"input": names.index(s["name"])} if s["name"] in frame_specs else
|
||||
view("frames" if s["name"] == "input_frame" else tfm, s["numel"] * _dtype(s["dtype"]).itemsize, s["dtype"]) for s in part["inputs"]}
|
||||
warp_inputs = {s["slot"]: {"input": names.index(s["name"])} if s["name"] in frame_specs else
|
||||
view("frames" if s["name"] == "input_frame" else "tfm", s["numel"] * _dtype(s["dtype"]).itemsize, s["dtype"]) for s in warp["inputs"]}
|
||||
|
||||
def remap(calls: list, inputs: dict, buffers: int, lib: int) -> list:
|
||||
return [call | ({"lib": [call["lib"][0] + lib, call["lib"][1] + lib]} if "lib" in call else {}) |
|
||||
@@ -88,11 +65,8 @@ def frame_part(warp_path: str, parts: dict, extras: dict, light_warp_path: str =
|
||||
"inputs": [{"slot": names.index("host"), "name": "host", "dtype": u8, "numel": packed, "device": "NPY"}] +
|
||||
[s | {"slot": slots[s["slot"]]} for s in model["inputs"] if s["slot"] in slots] +
|
||||
[s | {"slot": names.index(name)} for name, s in frame_specs.items()],
|
||||
"buffers": model["buffers"] + [b | ({"init": [b["init"][0] + d, b["init"][1] + d]} if "init" in b else {})
|
||||
for part, d in ((warp, shift), *((p, bb) for p, _, bb, _ in extra_at.values())) for b in part["buffers"]] +
|
||||
"buffers": model["buffers"] + [b | ({"init": [b["init"][0] + shift, b["init"][1] + shift]} if "init" in b else {}) for b in warp["buffers"]] +
|
||||
[{"nbytes": packed, "device": model["inputs"][0]["device"], "dtype": u8}],
|
||||
"calls": [{"kind": "copy", "args": [{"buffer": upload, "offset": 0, "nbytes": packed, "dtype": u8}, {"input": names.index("host")}]}] +
|
||||
remap(warp["calls"], warp_inputs(warp, "tfm"), len(model["buffers"]), shift) +
|
||||
[c for p, b0, bb, tfm in extra_at.values() for c in remap(p["calls"], warp_inputs(p, tfm), b0, bb)] +
|
||||
remap(model["calls"], model_inputs, 0, 0)}
|
||||
return {"run": (header, _Blobs(model_blob, warp_blob, *(blob for *_, blob in extra)))}
|
||||
remap(warp["calls"], warp_inputs, len(model["buffers"]), shift) + remap(model["calls"], model_inputs, 0, 0)}
|
||||
return {"run": (header, _Blobs(model_blob, warp_blob))} # replaces the model's run: one set of buffers, no separate warp
|
||||
|
||||
@@ -5,7 +5,6 @@ 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 inspect
|
||||
import bisect
|
||||
import builtins
|
||||
import contextlib
|
||||
@@ -20,7 +19,6 @@ import mmap
|
||||
import os
|
||||
import pickle
|
||||
import struct
|
||||
from typing import Any
|
||||
|
||||
MAGIC = b"SPTGPLN1"
|
||||
ALIGNMENT = 256
|
||||
@@ -334,15 +332,11 @@ class PlainJit(_Jit):
|
||||
stand_ins = {slot: UOp.from_buffer(Buffer(_device(spec["device"], device_map), spec["numel"] * _dtype(spec["dtype"]).itemsize).ensure_allocated(),
|
||||
_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, input_uops=input_uops, cache=False)
|
||||
|
||||
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)
|
||||
super().__init__(captured, header["input_names"], buffers)
|
||||
super().__init__(jit.CapturedJit(ret, linear, header["input_names"], []), header["input_names"], buffers)
|
||||
|
||||
if not verify or not (check := header.get("check")):
|
||||
return
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
"""
|
||||
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.common.transformations.camera import get_view_frame_from_calib_frame, view_frame_from_device_frame
|
||||
from openpilot.common.transformations.orientation import rot_from_euler
|
||||
|
||||
LIGHT_INPUT_SIZE = (512, 256)
|
||||
light_intrinsics = np.array([
|
||||
[1000.0, 0.0, 256.0],
|
||||
[0.0, 1000.0, 200.0],
|
||||
[0.0, 0.0, 1.0]])
|
||||
calib_from_light = np.linalg.inv((light_intrinsics @ get_view_frame_from_calib_frame(0, 0, 0, 0))[:, :3])
|
||||
|
||||
|
||||
def get_light_warp_matrix(device_from_calib_euler: np.ndarray, intrinsics: np.ndarray) -> np.ndarray:
|
||||
camera_from_calib = intrinsics @ view_frame_from_device_frame @ rot_from_euler(device_from_calib_euler)
|
||||
return (camera_from_calib @ calib_from_light).astype(np.float32)
|
||||
@@ -11,7 +11,7 @@ import pickle
|
||||
import numpy as np
|
||||
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.sunnypilot.modeld_v2.frame_fusion import host_shapes, pack_layout, SPLIT_FRAMES
|
||||
from openpilot.sunnypilot.modeld_v2.frame_fusion import pack_layout, SPLIT_FRAMES
|
||||
from openpilot.sunnypilot.modeld_v2.helpers import load_model
|
||||
from openpilot.sunnypilot.modeld_v2.compile_modeld import (POLICY_INPUTS, derive_frame_skip,
|
||||
make_split_input_queues, make_supercombo_input_queues)
|
||||
@@ -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
|
||||
@@ -178,7 +174,7 @@ class NativeTinygradAdapter(BaseModelAdapter):
|
||||
|
||||
self.input_queues = {name: Tensor(np.zeros(shape, dtype=dtype), device=self.model_device).realize()
|
||||
for name, (shape, dtype) in self.input_shapes.items() if name in self.state_pairs}
|
||||
shapes = host_shapes({name: shape for name, (shape, _) in self.input_shapes.items()}, self.state_pairs)
|
||||
shapes = {name: shape for name, (shape, _) in self.input_shapes.items() if name not in self.state_pairs and name != 'new_img'}
|
||||
offsets, packed = pack_layout(shapes, 0 if self.split else self.warp_frame_size)
|
||||
self.packed_input = np.zeros(packed, dtype=np.uint8)
|
||||
self.host = Tensor(self.packed_input, device='NPY')
|
||||
@@ -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):
|
||||
|
||||
@@ -44,7 +44,6 @@ from openpilot.sunnypilot.modeld_v2.blendful import Blendful
|
||||
from openpilot.sunnypilot.modeld_v2.constants import ModelConstants, Plan
|
||||
from openpilot.sunnypilot.modeld_v2.meta_helper import load_meta_constants
|
||||
from openpilot.sunnypilot.modeld_v2.camera_offset_helper import CameraOffsetHelper
|
||||
from openpilot.sunnypilot.modeld_v2.light_frame import get_light_warp_matrix
|
||||
from openpilot.sunnypilot.livedelay.helpers import get_lat_delay
|
||||
from openpilot.sunnypilot.modeld_v2.modeld_base import ModelStateBase
|
||||
from openpilot.sunnypilot.modeld_v2.helpers import load_model
|
||||
@@ -172,7 +171,7 @@ class ModelState(ModelStateBase):
|
||||
np.where(inputs[desire_key] - self.prev_desire > .99, inputs[desire_key], 0)
|
||||
self.prev_desire[:] = inputs[desire_key]
|
||||
|
||||
for key in ('traffic_convention', 'lateral_control_params', 'action_t', 'speed_limit'):
|
||||
for key in ('traffic_convention', 'lateral_control_params', 'action_t'):
|
||||
if key in self.numpy_inputs and key in inputs:
|
||||
self.numpy_inputs[key][:] = inputs[key]
|
||||
|
||||
@@ -180,8 +179,6 @@ class ModelState(ModelStateBase):
|
||||
for i, key in enumerate(self._vision_input_names):
|
||||
if key in transforms:
|
||||
self.numpy_inputs['tfm'][i] = transforms[key].reshape(3, 3)
|
||||
if 'light_tfm' in self.numpy_inputs and 'light' in transforms:
|
||||
self.numpy_inputs['light_tfm'][0] = transforms['light'].reshape(3, 3)
|
||||
else:
|
||||
self.numpy_inputs['tfm'][:, :] = transforms[self._road_key].reshape(3, 3)
|
||||
self.numpy_inputs['big_tfm'][:, :] = transforms[self._wide_key].reshape(3, 3)
|
||||
@@ -356,7 +353,6 @@ def main(demo=False):
|
||||
|
||||
model_transform_main = np.zeros((3, 3), dtype=np.float32)
|
||||
model_transform_extra = np.zeros((3, 3), dtype=np.float32)
|
||||
model_transform_light = np.zeros((3, 3), dtype=np.float32)
|
||||
live_calib_seen = False
|
||||
buf_main, buf_extra = None, None
|
||||
meta_main = FrameMeta()
|
||||
@@ -375,9 +371,6 @@ def main(demo=False):
|
||||
prev_action = log.ModelDataV2.Action()
|
||||
|
||||
DH = DesireHelper()
|
||||
desire_frames = [q.shape[0] for m in (model, small_model) if m is not None for name, q in m.adapter.input_queues.items() if 'desire' in name]
|
||||
if desire_frames:
|
||||
DH.turn_repulse = min(desire_frames) - 2
|
||||
meta_constants = load_meta_constants()
|
||||
RELC = RoadEdgeLaneChangeController()
|
||||
blendful = Blendful()
|
||||
@@ -424,7 +417,7 @@ def main(demo=False):
|
||||
if sm.frame % 60 == 0:
|
||||
model.lat_delay = get_lat_delay(params, sm["lateralDelay"].lateralDelay)
|
||||
model.PLANPLUS_CONTROL = params.get("PlanplusControl", return_default=True)
|
||||
camera_offset_helper.load_offset(params)
|
||||
camera_offset_helper.set_offset(params.get("CameraOffset", return_default=True))
|
||||
blendful_enabled = params.get_bool("Blendful")
|
||||
lat_delay = model.lat_delay + model.LAT_SMOOTH_SECONDS
|
||||
if sm.updated["extrinsicsCalibration"] and sm.seen['narrowRoadCameraState'] and sm.seen['deviceState']:
|
||||
@@ -434,7 +427,6 @@ def main(demo=False):
|
||||
model_transform_main = get_warp_matrix(device_from_calib_euler, main_intrinsics, False).astype(np.float32)
|
||||
model_transform_extra = get_warp_matrix(device_from_calib_euler, dc.wide_road.intrinsics, True).astype(np.float32)
|
||||
model_transform_main, model_transform_extra = camera_offset_helper.update(model_transform_main, model_transform_extra, sm, main_wide_camera)
|
||||
model_transform_light = get_light_warp_matrix(device_from_calib_euler, main_intrinsics)
|
||||
live_calib_seen = True
|
||||
|
||||
traffic_convention = np.zeros(2)
|
||||
@@ -456,7 +448,6 @@ def main(demo=False):
|
||||
|
||||
bufs = {name: buf_extra if 'big' in name else buf_main for name in model.vision_input_names}
|
||||
transforms = {name: model_transform_extra if 'big' in name else model_transform_main for name in model.vision_input_names}
|
||||
transforms['light'] = model_transform_light
|
||||
|
||||
frame_delay = DT_MDL # compensate for time passed since the frame was captured: current_time - timestamp_eof is 50ms on average
|
||||
action_delay = DT_MDL / 2 # middle of the interval between model output (current state) and next frame (expected state)
|
||||
@@ -474,9 +465,6 @@ def main(demo=False):
|
||||
if 'action_t' in model.numpy_inputs:
|
||||
inputs['action_t'] = np.array([lat_action_t, long_action_t], dtype=np.float32)
|
||||
|
||||
if 'speed_limit' in model.numpy_inputs:
|
||||
inputs['speed_limit'] = np.zeros(1, dtype=np.float32)
|
||||
|
||||
mt1 = time.perf_counter()
|
||||
try:
|
||||
send_chestnut = (chestnut_state is not None and
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1baac6f02902df5689e9e275633c122a9955b7c57de2681e0137e1724c1f32dd
|
||||
size 3463278
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0478837491c584b2212e31a91c494a908b8fb048205700f05a02a13ee7fc9b90
|
||||
size 7690094
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user