# Next Session: Robot Car — Telegram E2E Test + Polish

## What

Complete the final verification: Telegram → Annie → Pi → car moves. All code is deployed and working individually — just need to test the full chain. Then fix sensor issues and polish.

## Status From Last Session

**Everything deployed and hardware-verified:**
- Pi 5: turbopi-server running as systemd (auto-starts on boot)
- Titan: Annie running with 4 robot tools loaded (`drive_robot`, `robot_photo`, `robot_look`, `robot_status`)
- `.env` on Titan has `ROBOT_ENABLED=true`, `ROBOT_API_TOKEN`, `ROBOT_BASE_URL=http://192.168.68.61:8080`
- Hardware verified: forward/backward/spin_left/spin_right/camera/ESTOP all correct
- Camera calibrated: PAN_CENTER=1500, TILT_CENTER=1500, ch1=tilt, ch2=pan
- Rotation: 360° in 5s at speed 40 (~72°/s)
- Power: 3x SupTronics X-UPS1 (12x 18650, ~140 Wh, 9A max). 12V OFF on all, AL_ON off (button power)

**NOT YET TESTED:**
- Telegram → Annie → Pi E2E (the full chain)

## Step 1: Verify Pi + Annie Running

```bash
ssh pi 'curl -s localhost:8080/health'
ssh titan 'grep -i "robot" /tmp/annie-voice.log | tail -3'
```

If Annie not running: `bash start.sh`

## Step 2: Telegram E2E Test

From Telegram, send Annie these messages and verify:

1. **"Annie, drive the car forward"** → car should move forward ~1s
2. **"Annie, what can the car see?"** → should get camera description
3. **"Annie, spin the car left"** → car rotates counter-clockwise
4. **"Annie, stop the car"** → should confirm stopped
5. **"Annie, check the car status"** → should show uptime, battery, distance

## Step 3: Fix Known Issues

### Sonar always reads 99999
- Check I2C bus: `ssh pi 'i2cdetect -y 1'`
- Sonar should appear at address 0x77
- If not detected: wiring issue (SDA/SCL connections)

### Battery voltage returns 0 (None from SDK)
- `Board.get_battery()` returns None — may need UART initialization time
- Try: `ssh pi 'python3 -c "import sys; sys.path.insert(0, \"/home/pi/TurboPi\"); from HiwonderSDK.ros_robot_controller_sdk import Board; b = Board(); import time; time.sleep(1); print(b.get_battery())"'`
- If still None: check if battery monitoring is connected to STM32

### Throttle warning (0x50000)
- Pi 5 reports under-voltage on USB power bank
- Check: `ssh pi 'vcgencmd get_throttled'`
- If still showing: power bank output may be <5A. Consider direct 5V/5A supply.

## Step 4: Forward Direction Check

The forward/backward direction mapping assumes the car's front matches the SDK's direction=90°. If the car drives backward when told to go forward, swap the direction values:

```python
# In services/turbopi-server/main.py ACTION_MAP
"forward":  (SPEED_SCALE, 270, 0),  # was 90
"backward": (SPEED_SCALE, 90, 0),   # was 270
```

## Key Files

| File | Purpose |
|------|---------|
| `services/turbopi-server/main.py` | Pi FastAPI server (auth, ESTOP, motors, camera) |
| `services/annie-voice/robot_tools.py` | Annie HTTP client (4 tool handlers) |
| `services/annie-voice/tool_schemas.py` | Pydantic models (DriveRobotInput, etc.) |
| `services/annie-voice/text_llm.py` | ToolSpec entries + ROBOT_ENABLED gating |
| `docs/RESEARCH-ANNIE-ROBOT-CAR.md` | Architecture + calibration + power supply |
| `docs/RESOURCE-REGISTRY.md` | Pi 5 section + X-UPS1 specs |

## Token

`ROBOT_API_TOKEN=8cX80yIBws1PfBjFuvPz0k9egPSZD0LvS02oUD6ijfg`
