#!/bin/bash # ============================================================================ # start_saqr.sh — boot launcher for the Saqr / G1 bridge. # ============================================================================ # # What it does: # 1. Sources miniconda and activates the target env (default: marcus). # 2. cd to the project root (parent of this scripts/ dir). # 3. Execs `python -m saqr.robot.bridge` with the production flags. # # The bridge will: # - init the G1 arm + audio + LowState DDS clients # - announce "Saqr is running. Press R2 plus X to start." via TtsMaker # - sit idle until R2+X is pressed # # Designed to be run by systemd at boot — see saqr-bridge.service. # Can also be run manually: scripts/start_saqr.sh # ============================================================================ set -u HERE="$(cd "$(dirname "$0")" && pwd)" SAQR_DIR="${SAQR_DIR:-$(cd "$HERE/.." && pwd)}" CONDA_ROOT="${CONDA_ROOT:-$HOME/miniconda3}" CONDA_ENV="${CONDA_ENV:-marcus}" DDS_IFACE="${DDS_IFACE:-eth0}" SAQR_SOURCE="${SAQR_SOURCE:-realsense}" STREAM_PORT="${STREAM_PORT:-8080}" if [ ! -d "$SAQR_DIR" ]; then echo "[start_saqr] FATAL: SAQR_DIR not found: $SAQR_DIR" >&2 exit 1 fi if [ ! -d "$SAQR_DIR/saqr" ]; then echo "[start_saqr] FATAL: saqr/ package not found in $SAQR_DIR" >&2 exit 1 fi if [ ! -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]; then echo "[start_saqr] FATAL: conda not found at $CONDA_ROOT" >&2 exit 1 fi # shellcheck disable=SC1091 source "$CONDA_ROOT/etc/profile.d/conda.sh" conda activate "$CONDA_ENV" || { echo "[start_saqr] FATAL: failed to activate conda env: $CONDA_ENV" >&2 exit 1 } cd "$SAQR_DIR" || { echo "[start_saqr] FATAL: cd $SAQR_DIR failed" >&2 exit 1 } echo "[start_saqr] env=$CONDA_ENV cwd=$PWD iface=$DDS_IFACE source=$SAQR_SOURCE stream=$STREAM_PORT" echo "[start_saqr] launching bridge..." exec python3 -m saqr.robot.bridge \ --iface "$DDS_IFACE" \ --source "$SAQR_SOURCE" \ --headless \ -- --stream "$STREAM_PORT"