Skip to content

Latest commit

 

History

History
172 lines (118 loc) · 2.91 KB

File metadata and controls

172 lines (118 loc) · 2.91 KB

🚀 Complete Pi Setup - Quick Guide

Run these commands on your Raspberry Pi


Step 1: Create Virtual Environment

Raspberry Pi OS requires using a virtual environment:

cd ~/EDTH2025/Erewhon

# Create virtual environment
python3 -m venv venv

# Activate it
source venv/bin/activate

# Upgrade pip
pip install --upgrade pip

Step 2: Install Dependencies

Install in two steps (different package sources):

# Step 2a: Install PyTorch from pytorch.org
pip install -r requirements_pi_pytorch.txt --index-url https://download.pytorch.org/whl/cpu

# Step 2b: Install other packages from piwheels/PyPI
pip install -r requirements_pi_others.txt

What this installs:

  • PyTorch (CPU version for ARM)
  • torchvision
  • numpy, opencv-python, pyserial
  • draccus (LeRobot config system)
  • huggingface-hub (model loading)

Time: ~5-10 minutes


Step 3: Setup Environment Variables

# Add to .bashrc for permanent setup
cat >> ~/.bashrc << 'EOF'

# ACT Inference Environment
export PYTHONPATH=~/EDTH2025/Erewhon/src/policies/ACT/lerobot/src:$PYTHONPATH
alias act-env='cd ~/EDTH2025/Erewhon && source venv/bin/activate'
EOF

# Reload
source ~/.bashrc

# Activate environment
act-env

Now you can always run act-env to activate the inference environment!


Step 4: Test Model Loading

cd ~/EDTH2025/Erewhon
./test_pi_model.sh

Expected output:

✅ Model loaded successfully!
Quantization mode: static

Step 5: Benchmark Performance

# Make sure venv is activated
act-env

cd ~/EDTH2025/Erewhon/src/robots/rover

python src/inference/act_inference_quantized.py \
    --checkpoint models/best_model_static_quantized.pth \
    --benchmark \
    --iterations 1000

Expected results:

  • Mean latency: 25-35 ms
  • P95 latency: <50 ms
  • Throughput: 25-35 FPS
  • Control rate: 25-30 Hz ✅

Step 6: Test with Camera

python src/inference/act_inference_quantized.py \
    --checkpoint models/best_model_static_quantized.pth \
    --camera_id 0

Press 'q' to quit.


Step 7: Deploy to RC Car! 🚗

python src/inference/act_inference_quantized.py \
    --checkpoint models/best_model_static_quantized.pth \
    --camera_id 0 \
    --arduino_port /dev/ttyUSB0 \
    --control_freq 30

Troubleshooting

ImportError: No module named 'draccus'

pip3 install draccus huggingface-hub

Permission denied: camera

sudo usermod -a -G video $USER
# Log out and back in

Permission denied: Arduino

sudo usermod -a -G dialout $USER  
# Log out and back in

Can't find camera

ls /dev/video*
# Try different camera_id if multiple cameras

Can't find Arduino

ls /dev/ttyUSB* /dev/ttyACM*
# Use the port that appears

Quick Reference

All commands assume you're in ~/EDTH2025/Erewhon/src/robots/rover

See PI_COMMANDS.md for more detailed commands.