# Next Session: Lidar Navigation Tuning & E2E Verification

## What Was Done (Session 44)

Lidar-reactive navigation V2 fully implemented and deployed:
- **LidarDaemon** (lidar.py): pyrplidar monkey-patch, double-buffer, 12-sector binning, stall detection
- **Safety fusion**: Hailo YOLO detections fused with lidar distances (replaces bbox heuristic)
- **Nav brain**: VLM prompt includes 360-degree sector summary + car dimensions (20×25×25cm)
- **Thresholds tuned**: blocked < 15cm, near < 25cm (from car edge: ~5cm and ~15cm)
- **Lidar directions VERIFIED**: left/right matches physical reality
- **10-cycle nav loops working**: VLM detects walls, turns away, finds open space, drives forward
- **190 tests pass** (57 lidar + 44 safety + 12 frame + 77 robot)

## What's Left

### 1. Live E2E Navigation Test (PRIORITY)
The car physically moves (lidar distances change between cycles) but needs a proper test:
- Place car in open area (not under furniture)
- Turn on battery (USB-C)
- Trigger: "Annie, explore the room" via Telegram
- Watch car navigate around dining table legs without hitting them
- Verify ESTOP triggers if car gets within 30cm of a detected obstacle (YOLO + lidar fusion)
- Record a run (video) for debugging

### 2. Calibrate LIDAR_FORWARD_OFFSET_DEG
Currently 0.0 — may have small misalignment with camera. Procedure:
1. Place a large object directly in front of camera center
2. Read lidar scan — find sector with minimum distance
3. If it's not sector 0 (Forward), compute offset
4. Set `LIDAR_FORWARD_OFFSET_DEG` in Pi systemd env override

### 3. Test Obstacle Avoidance Scenarios
- [ ] Car approaching wall head-on → should ESTOP at 30cm (lidar distance)
- [ ] Car navigating between table legs → should fit through (20cm car vs ~30cm gap)
- [ ] Car finding and driving toward open doorway
- [ ] Lidar USB disconnected during navigation → graceful degradation to bbox distance
- [ ] Pi throttling under sustained navigation → verify throttled stays 0x0

### 4. Navigation Behavior Tuning
If the car moves but makes poor choices:
- **Too cautious / only rotates**: Lower blocked/near thresholds further, or make VLM prompt more aggressive
- **Drives into things**: ESTOP threshold (30cm) may need increasing for this car's braking distance
- **Left/right feels wrong**: Check `LIDAR_FORWARD_OFFSET_DEG` — a 180° offset would swap all directions
- **Cycles too short**: Increase drive duration from 1.0s to 1.5s for more ground covered per cycle
- **VLM picks bad actions**: Check what image the VLM sees + review the nav prompt

### 5. Physical Constraints (verified Session 44)
- **Strafe DOES NOT WORK** — battery weight too heavy for lateral mecanum movement
- **Micro movements fail** — need speed ≥ 40 to overcome inertia
- **Min duration 1.0s** — sub-second moves don't result in meaningful displacement
- **Battery via USB-C** — `Board.get_battery()` returns None, always shows 0V

## Hardware State

| Component | Status |
|-----------|--------|
| Pi 5 | Running, SSH @ 192.168.68.61 |
| turbopi-server | systemd active, port 8080 |
| LidarDaemon | healthy, scanning |
| HailoSafetyDaemon | healthy, 30 FPS YOLO |
| Lidar directions | VERIFIED correct |
| RPLIDAR C1 | /dev/lidar (udev symlink) |
| Motor battery | USB-C connected |
| Annie (Titan) | Running, port 7860 |
| API token | Pi override matches Titan .env |

## Start Command

1. Ensure battery is plugged in (USB-C)
2. Verify: `curl http://192.168.68.61:8080/health` → lidar_healthy=true, safety_daemon_healthy=true
3. Place car in open area away from furniture legs
4. Test via Telegram: "Annie, explore the room with the car"
5. Watch and note behavior for tuning
