mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-20 00:32:11 +08:00
nav
This commit is contained in:
@@ -27,18 +27,20 @@ env_var_truthy() {
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./onroad [jobs] (--c3 | --c4 | --raybig | --all | --replay-only) [--prefix name] <route-or-replay-args...>
|
||||
./onroad [jobs] (--c3 | --c4 | --raybig | --all | --replay-only) [-nav] [--prefix name] <route-or-replay-args...>
|
||||
|
||||
Examples:
|
||||
./onroad --c3 f08912a233c1584f/2022-08-11--18-02-41/1
|
||||
./onroad --c4 f08912a233c1584f/2022-08-11--18-02-41/1 --start 30
|
||||
./onroad --all f08912a233c1584f/2022-08-11--18-02-41/1
|
||||
./onroad --c3 <route>
|
||||
./onroad --c4 <route> --start 30
|
||||
./onroad --c4 -nav <route>
|
||||
./onroad --all <route>
|
||||
./onroad --replay-only --demo --no-vipc --no-loop
|
||||
|
||||
Notes:
|
||||
- This is host/dev only. It uses the isolated host worktree and does not touch the device path.
|
||||
- A private comma connect route still requires tools/lib/auth.py before replay can download it.
|
||||
- Use multiple UI flags together if you want more than one desktop UI at once.
|
||||
- -nav injects a fake navigation demo stream and blocks replay from publishing navInstruction/navRoute.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -53,7 +55,9 @@ REPLAY_ARGS=()
|
||||
UI_TARGETS=()
|
||||
LEGACY_UI_SELECTION=""
|
||||
REPLAY_ONLY=0
|
||||
NAV_DEMO=0
|
||||
REPLAY_PID=""
|
||||
NAV_PID=""
|
||||
UI_PIDS=()
|
||||
|
||||
parse_args() {
|
||||
@@ -83,6 +87,10 @@ parse_args() {
|
||||
REPLAY_ONLY=1
|
||||
shift
|
||||
;;
|
||||
-nav|--nav)
|
||||
NAV_DEMO=1
|
||||
shift
|
||||
;;
|
||||
--ui)
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Missing value for --ui" >&2
|
||||
@@ -194,6 +202,9 @@ cleanup() {
|
||||
if [[ -n "${REPLAY_PID}" ]]; then
|
||||
kill "${REPLAY_PID}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [[ -n "${NAV_PID}" ]]; then
|
||||
kill "${NAV_PID}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
for pid in "${UI_PIDS[@]-}"; do
|
||||
if [[ -n "${pid}" ]]; then
|
||||
@@ -203,6 +214,9 @@ cleanup() {
|
||||
if [[ -n "${REPLAY_PID}" ]]; then
|
||||
wait "${REPLAY_PID}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [[ -n "${NAV_PID}" ]]; then
|
||||
wait "${NAV_PID}" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [[ -n "${OPENPILOT_PREFIX:-}" && "${OPENPILOT_PREFIX}" == desktop-onroad-* ]]; then
|
||||
echo "Cleaning up temporary prefix environment (${OPENPILOT_PREFIX})..."
|
||||
@@ -214,6 +228,68 @@ cleanup() {
|
||||
exit "${exit_code}"
|
||||
}
|
||||
|
||||
append_blocked_service_names() {
|
||||
local existing="$1"
|
||||
local required="$2"
|
||||
local combined="${existing}"
|
||||
|
||||
if [[ -n "${combined}" ]]; then
|
||||
combined+=",${required}"
|
||||
else
|
||||
combined="${required}"
|
||||
fi
|
||||
|
||||
local deduped=()
|
||||
local seen=","
|
||||
local part=""
|
||||
local parts=()
|
||||
IFS=',' read -r -a parts <<< "${combined}"
|
||||
for part in "${parts[@]-}"; do
|
||||
part="${part// /}"
|
||||
if [[ -z "${part}" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${seen}" != *",${part},"* ]]; then
|
||||
deduped+=("${part}")
|
||||
seen+="${part},"
|
||||
fi
|
||||
done
|
||||
|
||||
local joined=""
|
||||
for part in "${deduped[@]-}"; do
|
||||
if [[ -n "${joined}" ]]; then
|
||||
joined+=","
|
||||
fi
|
||||
joined+="${part}"
|
||||
done
|
||||
|
||||
printf '%s' "${joined}"
|
||||
}
|
||||
|
||||
ensure_nav_demo_replay_blocklist() {
|
||||
local nav_services="navInstruction,navRoute"
|
||||
local idx=0
|
||||
|
||||
for ((idx=0; idx<${#REPLAY_ARGS[@]}; idx++)); do
|
||||
case "${REPLAY_ARGS[$idx]}" in
|
||||
-b|--block)
|
||||
if (( idx + 1 >= ${#REPLAY_ARGS[@]} )); then
|
||||
echo "Missing value for ${REPLAY_ARGS[$idx]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
REPLAY_ARGS[$((idx + 1))]="$(append_blocked_service_names "${REPLAY_ARGS[$((idx + 1))]}" "${nav_services}")"
|
||||
return
|
||||
;;
|
||||
--block=*)
|
||||
REPLAY_ARGS[$idx]="--block=$(append_blocked_service_names "${REPLAY_ARGS[$idx]#*=}" "${nav_services}")"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
REPLAY_ARGS=(-b "${nav_services}" "${REPLAY_ARGS[@]}")
|
||||
}
|
||||
|
||||
prepare_env() {
|
||||
source .venv/bin/activate
|
||||
|
||||
@@ -238,6 +314,7 @@ prepare_env() {
|
||||
export SP_C4_FAKE_WIFI=0
|
||||
export SP_RAYBIG_FAKE_WIFI=0
|
||||
export SP_ALLOW_DESKTOP_FAKE_WIFI=0
|
||||
export SP_ONROAD_NAV_DEMO="${NAV_DEMO}"
|
||||
|
||||
if [[ "$(uname -s)" == "Darwin" ]] || env_var_truthy "${ZMQ:-0}"; then
|
||||
export OPENPILOT_ZMQ_NAMESPACE="${PREFIX_ARG:-${OPENPILOT_ZMQ_NAMESPACE:-desktop-onroad-$$}}"
|
||||
@@ -250,6 +327,8 @@ prepare_env() {
|
||||
|
||||
seed_params() {
|
||||
"${ROOT_DIR}/.venv/bin/python3" - <<'PY'
|
||||
import os
|
||||
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.system.version import terms_version, training_version
|
||||
|
||||
@@ -260,6 +339,8 @@ params.put_bool("OpenpilotEnabledToggle", True)
|
||||
params.put_bool("IsDriverViewEnabled", False)
|
||||
params.put_bool("ForceOnroad", False)
|
||||
params.put_bool("ForceOffroad", False)
|
||||
if os.getenv("SP_ONROAD_NAV_DEMO", "").lower() in {"1", "true", "yes", "on"}:
|
||||
params.put_bool("NavigationUI", True)
|
||||
PY
|
||||
}
|
||||
|
||||
@@ -302,6 +383,18 @@ launch_replay() {
|
||||
fi
|
||||
}
|
||||
|
||||
launch_nav_demo() {
|
||||
echo "Starting fake nav demo publisher..."
|
||||
"${ROOT_DIR}/.venv/bin/python3" "${ROOT_DIR}/tools/replay/fake_nav_demo.py" &
|
||||
NAV_PID=$!
|
||||
|
||||
sleep 0.5
|
||||
if ! kill -0 "${NAV_PID}" >/dev/null 2>&1; then
|
||||
wait "${NAV_PID}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
launch_c3_ui() {
|
||||
local os_ext="linux"
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
@@ -339,6 +432,10 @@ else
|
||||
dedupe_ui_targets
|
||||
fi
|
||||
|
||||
if [[ "${NAV_DEMO}" == "1" ]]; then
|
||||
ensure_nav_demo_replay_blocklist
|
||||
fi
|
||||
|
||||
if [[ ${#REPLAY_ARGS[@]} -eq 0 ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
@@ -378,6 +475,10 @@ seed_starpilot_theme
|
||||
echo "Starting replay: ${REPLAY_ARGS[*]}"
|
||||
launch_replay
|
||||
|
||||
if [[ "${NAV_DEMO}" == "1" ]]; then
|
||||
launch_nav_demo
|
||||
fi
|
||||
|
||||
if [[ ${#UI_TARGETS[@]} -eq 0 ]]; then
|
||||
echo "Replay is running without UI windows. Press Ctrl-C to stop."
|
||||
wait "${REPLAY_PID}"
|
||||
|
||||
Reference in New Issue
Block a user