Port complete CAN-aware risk pipeline to C++

This commit is contained in:
zmv
2026-09-23 19:51:56 +08:00
parent 0f609612a6
commit e1e7fbe2fb
81 changed files with 27329 additions and 6381 deletions
+15 -23
View File
@@ -1,26 +1,18 @@
#!/usr/bin/env bash
# Refresh the standalone runtime after compiling on the target Orin.
# Assemble the C++ runtime; no Python interpreter is used for packaging or execution.
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
python3 - "$root" <<'PY'
from pathlib import Path
import hashlib,shutil,sys
root=Path(sys.argv[1]);package=root/'orin'
library=root/'build/libvision_native.so'
if not library.is_file():raise SystemExit('Run scripts/build.sh on Orin first.')
# Replace generated Python directories so removed modules cannot survive packaging.
for name in ('pipeline','annotations'):
target=package/name
if target.exists():shutil.rmtree(target)
shutil.copytree(root/name,target,ignore=shutil.ignore_patterns('__pycache__','*.pyc'))
(package/'build').mkdir(exist_ok=True)
shutil.copy2(library,package/'build/libvision_native.so')
shutil.copy2(root/'run_camera.py',package/'run_camera.py')
shutil.copy2(root/'scripts/initialize_camera.sh',package/'scripts/initialize_camera_impl.sh')
for name in ('lib/libusbcanfd.so','lib/libusb-1.0.so','models/engines/yolo11s.engine','models/engines/rtmw_l_384.engine','bin/drivers/max9295.ko','bin/drivers/max9296.ko','bin/drivers/sgx-yuv-gmsl2.ko'):
if not (package/name).is_file():raise SystemExit('Missing packaged dependency: '+name)
ignored={'__pycache__','outputs','logs'}
files=sorted(p for p in package.rglob('*') if p.is_file() and not p.is_symlink() and p.name!='SHA256SUMS' and not ignored.intersection(p.relative_to(package).parts))
(package/'SHA256SUMS').write_text(''.join(hashlib.sha256(p.read_bytes()).hexdigest()+' '+p.relative_to(package).as_posix()+'\n' for p in files))
print('Package ready:',package/'run.sh')
PY
package="$root/orin"
[[ -x "$root/build/camera_risk" ]] || { echo 'Compile on Orin with scripts/build.sh first.' >&2; exit 1; }
mkdir -p "$package/build" "$package/config" "$package/annotations" "$package/scripts"
cp -p "$root/build/camera_risk" "$package/build/"
cp -p "$root/annotations/"*.json "$package/annotations/"
# Source and standalone configurations differ only in the engine directory.
sed 's|../orin/models/engines|../models/engines|' "$root/config/camera.json" > "$package/config/camera.json"
cp -p "$root/scripts/initialize_camera.sh" "$package/scripts/initialize_camera_impl.sh"
(
cd "$package"
find . -type f ! -path './outputs/*' ! -path './logs/*' ! -name SHA256SUMS -print0 |
sort -z | xargs -0 sha256sum > SHA256SUMS
)
echo "C++ runtime ready: $package/build/camera_risk"