|
há 23 horas atrás | |
---|---|---|
.. | ||
README.md | há 23 horas atrás | |
camera_aim_calibration.md | há 23 horas atrás | |
octv2_server.py | há 23 horas atrás | |
requirements.txt | há 1 dia atrás | |
setup_mouth_detection.md | há 1 dia atrás | |
wide_mouth_detection_guide.md | há 1 dia atrás |
Enhanced system with ESP32 motor control and automatic mouth detection.
iOS App ←→ Raspberry Pi ←→ ESP32 ←→ Stepper Motors
↓ ↓ ↓
Video Stream AI Vision Hardware Control
# Copy files to Pi
scp -r raspberry_pi_server/ pi@your-pi-ip:~/octv2/
# SSH into Pi
ssh pi@your-pi-ip
cd ~/octv2
# Install dependencies
sudo apt update
sudo apt install python3-picamera2 python3-opencv python3-serial
pip3 install -r requirements.txt
Hardware Connections:
ESP32 Pin → Component
2,3,4 → Rotation Stepper (Step, Dir, Enable)
6,7,8 → Elevation Stepper (Step, Dir, Enable)
5,9 → Limit Switches (Rotation, Elevation)
10 → Fire Servo
11 → Fire Solenoid (alternative)
13 → Status LED
Programming:
esp32_firmware/octv2_motor_controller.ino
in Arduino IDEAccelStepper
, ESP32Servo
# Connect ESP32 to Pi via USB
# Check USB device (usually /dev/ttyUSB0 or /dev/ttyACM0)
ls /dev/tty*
# Update port in Python code if needed
# Edit octv2_server.py line: ESP32Controller(port='/dev/ttyUSB0')
# Run the enhanced server (will wait for ESP32 connection)
python3 octv2_server.py
# Note: Server will retry ESP32 connection indefinitely until successful
Same as before - connect to Pi's IP address on port 8080.
Commands sent to ESP32:
HOME → Home both motors
MOVE 45.0 30.0 → Move to absolute position (rot, elev)
REL -5.0 2.5 → Move relative to current position
FIRE → Trigger fire mechanism
POS → Get current position
STATUS → Get detailed status
STOP → Emergency stop
Responses from ESP32:
OK → Command successful
ERROR: message → Command failed
45.0 30.0 → Position response (rotation pitch)
HOMED:1 ROT:45.0 ... → Status response
Edit in octv2_server.py
:
# Camera FOV for targeting calculations
self.camera_fov_h = 62.2 # Horizontal FOV degrees
self.camera_fov_v = 48.8 # Vertical FOV degrees
Edit in octv2_motor_controller.ino
:
#define ROTATION_GEAR_RATIO 5.0 // Your gear ratio
#define ELEVATION_GEAR_RATIO 3.0 // Your gear ratio
#define STEPS_PER_REVOLUTION 200 // Your stepper motor
#define MICROSTEPS 16 // Your driver setting
Edit in octv2_server.py
:
# Auto mode timing
self.target_cooldown = 2.0 # Seconds between shots
self.auto_fire_enabled = True # Enable/disable auto firing
# Detection parameters
faces = self.face_cascade.detectMultiScale(gray, 1.3, 5) # Adjust sensitivity
mouths = self.mouth_cascade.detectMultiScale(face_roi, 1.3, 5)
# Check USB connection
lsusb | grep -i esp
dmesg | tail
# Check permissions
sudo usermod -a -G dialout $USER
# Logout and login
# Test serial connection
screen /dev/ttyUSB0 115200
# Type "STATUS" and press Enter
# Test camera
libcamera-hello --preview
# Check OpenCV installation
python3 -c "import cv2; print(cv2.__version__)"
# Test detection manually
python3 -c "
import cv2
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
print('Cascade loaded:', face_cascade.empty() == False)
"
The iOS app works unchanged! All new features are handled on the Pi side:
Your OCTv2 now has AI-powered targeting and precision stepper control!