# Next Session: HectorSLAM Drive Test

## Status
HectorSLAM fully implemented, deployed, calibrated, and verified on Pi 5 (session 61).
12 commits on main. Lidar 352+ pts/scan. IMU heading tracking. Map rendering as PNG.
All endpoints live: `/pose`, `/map`, `/slam/reset`, `/health` (slam_healthy=true).

## What Was Done (Session 61)
- Implemented full HectorSLAM: ImuReader, OccupancyGrid, MultiResGrid, Gauss-Newton scan matching, SlamDaemon, ray casting
- Server: wired into main.py lifespan, added /map /pose /slam/reset endpoints
- Annie: map+pose added to VLM navigation prompt (graceful degradation)
- Calibrated: `LIDAR_FORWARD_OFFSET_DEG=0.0`, `LIDAR_CCW=True` (both verified)
- Fixed 3 live bugs: PID 00c0→0005, MIN_TRAVEL guard (displacement always 0), lidar serial buffer flush
- 213 turbopi-server tests + 111 annie-voice tests passing

## What Needs Doing

### 1. Drive Test with SLAM Tracking
The car drove briefly (49 scans, tracked to x=-2.15m y=-2.09m) but lidar was flaky at the time. Now lidar is fixed (buffer flush). Need a clean drive test:

```bash
# Reset SLAM first
TOKEN="8cX80yIBws1PfBjFuvPz0k9egPSZD0LvS02oUD6ijfg"
ssh pi "curl -s -X POST -H 'Authorization: Bearer $TOKEN' http://localhost:8080/slam/reset"

# Monitor pose while driving from Telegram
ssh pi "curl -s -H 'Authorization: Bearer $TOKEN' http://localhost:8080/pose"

# Download map
ssh pi "curl -s -H 'Authorization: Bearer $TOKEN' http://localhost:8080/map" > /tmp/map.png
```

Drive the car around the room via Telegram controls. Check:
- scan_count growing continuously
- x_m/y_m tracking movement (not stuck at 0)
- heading_deg reflecting turns
- Map PNG showing room walls filling in

### 2. Annie Navigation E2E (needs Titan)
Start Annie + Telegram bot + vLLM on Titan:
```bash
ssh titan "sudo systemctl start annie-voice telegram-bot"
# Also need vLLM with Gemma 4
```
Then message Annie: "explore this room"

Check Annie logs for nav cycles:
```bash
ssh titan "journalctl -u annie-voice -f | grep -i nav"
```
Verify the VLM prompt includes SLAM POSITION and MAP text.

### 3. Known Issues
- **Car drove left into walls** — happened during Telegram manual control, not Annie. Unclear if navigation logic issue. Monitor during Annie-driven exploration.
- **Lidar USB stability** — buffer flush fix deployed. If points drop again, restart service (should auto-recover now).
- **IMU drift** — ~4°/min on MPU-6050. Scan matcher should correct. Monitor heading accuracy over 5+ minutes.

## Key Files
- `services/turbopi-server/slam.py` — all SLAM logic (624 lines)
- `services/turbopi-server/imu.py` — ImuReader (140 lines)
- `services/turbopi-server/main.py` — endpoints + daemon wiring
- `services/annie-voice/robot_tools.py` — map/pose in VLM prompt

## Git State
Main at `a38ebb1`. Clean working tree. Pi deployed and running.
