#!/usr/bin/env bash # Visualize / evaluate a TorchScript JIT navigation policy (e.g. the official # upstream B2W baseline ``nav_policy_new.pt``) in the IsaacLab pure-maze env. # # Examples: # # GUI viewer, 4 envs, paper-style classic maze # PLAY_CLASSIC_MAZE=1 PLAY_DIFFICULTY="0.8,1.0" \ # ./scripts/play_b2w_jit.sh --jit-policy assets/baselines/b2w_nav_policy_new.pt # # # Headless stats run (no GUI) # PLAY_CLASSIC_MAZE=1 PLAY_DIFFICULTY="0.8,1.0" \ # ./scripts/play_b2w_jit.sh \ # --jit-policy assets/baselines/b2w_nav_policy_new.pt \ # --headless --envs 32 --steps 2000 set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" # ---- defaults (GUI-friendly) ---- TASK="Isaac-Nav-PPO-B2W-Play-v0" JIT_HOST="" NUM_ENVS=4 STEPS=100000 # huge so the viewer just keeps running until user closes it SEED=42 HEADLESS=0 usage() { cat <= ~1.5) PLAY_CLASSIC_MAZE=1 paper-style uniform walls EOF exit 0 } while [[ $# -gt 0 ]]; do case "$1" in --jit-policy) JIT_HOST="$2"; shift 2 ;; --task) TASK="$2"; shift 2 ;; --envs) NUM_ENVS="$2"; shift 2 ;; --steps) STEPS="$2"; shift 2 ;; --seed) SEED="$2"; shift 2 ;; --headless) HEADLESS=1; shift ;; -h|--help) usage ;; *) echo "[error] Unknown arg: $1" >&2; usage ;; esac done [[ -z "$JIT_HOST" ]] && { echo "[error] --jit-policy is required." >&2; exit 1; } if [[ "$JIT_HOST" != /* ]]; then JIT_HOST="$REPO_ROOT/$JIT_HOST"; fi [[ -f "$JIT_HOST" ]] || { echo "[error] JIT file not found: $JIT_HOST" >&2; exit 1; } JIT_CTR="/workspace/baseline_policy.pt" # ---- GUI plumbing (same as play_go2.sh) ---- EXTRA_DOCKER_ARGS=() HEADLESS_FLAG="" if [[ "$HEADLESS" == "0" ]]; then xhost +local:root >/dev/null 2>&1 || xhost +local:docker >/dev/null 2>&1 || true EXTRA_DOCKER_ARGS+=(-e "DISPLAY=${DISPLAY:-:1}" -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v "$HOME/.Xauthority:/root/.Xauthority:ro") else HEADLESS_FLAG="--headless" fi cat <