# Next Session: Nav Streaming — Followup Tuning + ArUco Homing

## What Was Done (Session 81)

All 4 items from the streaming nav tuning plan implemented, deployed, and E2E verified:

1. **Close-range over-rotation fix** — centering nudge counter (8 turns → forward/backward nudge). Commit `635f04b`.
2. **Stall detection grace period** — skip stall check until first cycle completes. Commit `635f04b`.
3. **Panda systemd unit** — `config/systemd/panda-nav.service`, user scope, enabled + linger. Stop.sh/start.sh updated.
4. **Pipeline VLM** — fire-and-forget forward, sequential turns, race-safe shutdown. Commit `635f04b`.

### Hotfixes shipped during E2E (3 additional commits)
- `b46a2c5` — removed 120s timeout cap, fixed logging (basicConfig), default max_cycles 200→500
- `9128e1d` — sonar stop 25→10cm, medium-close 40→20cm (robot was stopping before VLM saw LARGE)
- `dac14e6` — rate floor 0.1→0.5s (pipeline was hammering llama-server at 5-8 req/s, causing crash)

### E2E Results
- **Run 1**: 65 cycles, approaching, TIMEOUT (Annie's 100s cap killed active nav)
- **Run 2**: llama-server crashed from pipeline overload → search_exhausted
- **Run 3**: **GOAL_REACHED at cycle 180**, VLM 120.5ms avg, full Telegram chain verified

### Key Finding: Gemma 4 E2B LARGE Threshold
VLM says CENTER MEDIUM for ~24 consecutive cycles before finally CENTER LARGE. The ball must fill most of the frame. This is why sonar at 25cm was fatal — robot stopped before getting close enough.

## What's Left

### 1. Centering Nudge E2E (untested)
The over-rotation fix (8-turn centering nudge) was never triggered in E2E because the robot approached cleanly. To test:
- Place ball off to the side at close range (~30cm, LEFT or RIGHT position)
- Robot should center 8 times, then nudge forward (or backward if lidar blocked)
- Verify counter reset works after approaching/searching interruptions

### 2. Pipeline Speedup Validation
Logs show ~500ms/cycle (VLM 120ms + 0.5s floor) vs ~2.5s before. The pipeline overlaps driving with VLM but the 0.5s rate floor limits the benefit. Consider:
- Is 0.5s the right floor? Could try 0.3s if llama-server handles it
- Monitor llama-server GPU memory during sustained nav sessions

### 3. Systemd Robustness
- Verify panda-nav survives Panda reboot (linger is enabled)
- Verify `./stop.sh panda` stops panda-nav via systemd
- Verify `./start.sh panda-nav` detects systemd and reads static token

### 4. ArUco Homing (long-pending)
Plan at `~/.claude/plans/whimsical-sparking-squid.md`. Uses DICT_6X6_50 id=23, /imu deployed. The `/drive/turn` accumulated delta approach from session 76 is the correct rotation primitive.

## Deployment State

| Machine | Service | State |
|---------|---------|-------|
| Pi (192.168.68.61) | turbopi-server | **POWERED OFF** (guests visiting) |
| Panda (192.168.68.57) | panda-nav (systemd) | Stopped (will auto-start on Pi availability) |
| Titan (192.168.68.52) | Annie + Telegram | Running with NAV_TOKEN |

### Tokens (static, in env files)
- **NAV_TOKEN**: `-6R6rn06b2igzNgWzqso5Emi-619JufBgim0ZnD29lE` (Panda `~/.her-os/panda-nav.env` + Annie `.env`)
- **PI_AUTH_TOKEN**: `8cX80yIBws1PfBjFuvPz0k9egPSZD0LvS02oUD6ijfg` (Panda env file)
- Annie needs `export PANDA_NAV_TOKEN=...` before `./start.sh annie` (or run `./start.sh panda-nav` first which exports it)

## Start Command

```bash
# 1. Power on Pi, wait for turbopi-server to come up
ssh panda "curl -sf http://192.168.68.61:8080/health"

# 2. Start panda-nav (systemd will auto-read env file)
ssh panda "systemctl --user start panda-nav.service"

# 3. Verify chain
ssh panda "curl -sf http://localhost:11436/health"  # streaming_enabled: true
ssh titan "curl -sf -H 'X-Nav-Token: -6R6rn06b2igzNgWzqso5Emi-619JufBgim0ZnD29lE' http://192.168.68.57:11436/v1/nav/status"

# 4. Test via Telegram: "find the red ball"
```
