--- name: pi description: Interact with the raspberry pi sandbox - capture images, analyze scenes, transfer files, run commands. Use when working with the pi, camera, or servos. user_invocable: true arg_hint: "capture | analyze | look | send | get | exec " --- # /pi Raspberry Pi 3B+ sandbox toolkit. The pi is at 10.0.0.11 (user: pi). SSH key auth is set up - use regular ssh/scp/rsync via Bash, no need for ssh-mcp. ## connection ```bash PI="pi@10.0.0.11" ssh $PI '' scp $PI: scp $PI: rsync -avz $PI:/ / ``` ## hardware - USB camera at /dev/video0 - Pan servo: GPIO 17, Tilt servo: GPIO 18, Trigger: GPIO 27 - Servos NOT currently wired up - pigpiod must be started before servo use: `sudo systemctl start pigpiod` ## commands ### /pi capture [width] [height] Take a photo and save locally. ```bash ssh pi@10.0.0.11 'python3 ~/pi-sandbox/tools/capture.py 640 480' | base64 -d > ~/pi-sandbox/latest.jpg ``` Or for full resolution, capture on pi then scp: ```bash ssh pi@10.0.0.11 'python3 -c " import cv2 cap = cv2.VideoCapture(0) cap.set(3, 640); cap.set(4, 480) _, f = cap.read() cap.release() cv2.imwrite(\"/tmp/cap.jpg\", f) "' scp pi@10.0.0.11:/tmp/cap.jpg ~/pi-sandbox/latest.jpg ``` Then use Read tool on ~/pi-sandbox/latest.jpg to view it. ### /pi analyze Quick scene analysis - brightness, contrast, edge density, saturation. ```bash ssh pi@10.0.0.11 'python3 ~/pi-sandbox/tools/analyze.py 640' ``` ### /pi look Capture + analyze + view. Combines capture and analyze. ### /pi send Send a file TO the pi: ```bash scp pi@10.0.0.11: ``` Or for directories: ```bash rsync -avz / pi@10.0.0.11:/ ``` ### /pi get [local_dest] Get a file FROM the pi: ```bash scp pi@10.0.0.11: ``` ### /pi exec Run something on the pi: ```bash ssh pi@10.0.0.11 '' ``` ## helper scripts on pi - `~/pi-sandbox/tools/capture.py [w] [h]` - capture photo, output base64 - `~/pi-sandbox/tools/analyze.py [w]` - capture + opencv stats (text output) - `~/pi-sandbox/sentry.py` - motion detection, saves to ~/pi-sandbox/captures/ ## constraints - camera runs ~4fps at 640x480 on the pi 3b+ - opencv 3.2 (uses 3-value findContours return) - tflite-runtime 2.5.0 available ## project files - pi: `~/pi-sandbox/` - main workspace - pi: `~/pi-sandbox/tools/` - helper scripts - pi: `~/pi-sandbox/captures/` - motion detection captures - pi: `~/cat-deterrent/` - old cat deterrent code (has detector.py, servo.py) - local: `~/pi-sandbox/` - local workspace + received files