How souptik-mu/chess-robot works
Project Type and Purpose
• This is a hybrid desktop‐to‐hardware control system: a Python GUI application (CustomTkinter + OpenCV + python-chess) running on a PC that communicates via serial (USB) with an ESP32 microcontroller to drive an LED chessboard.
File Structure Analysis
• Top level:
• MAIN.py – application entry point
• requirements.txt – Python dependencies (CustomTkinter, OpenCV, python-chess, pyserial, etc.)
• firmware/ – ESP32 Arduino sketches for LED matrix control
• src/ – Python modules:
• BoardDetection.py – uses OpenCV to detect board state from camera frames
• Game.py – wraps python-chess, enforces move logic and state
• widgets.py – CustomTkinter widgets and main GUI layout
Key Technologies and External Interfaces
• GUI layer: CustomTkinter on Python
• Vision layer: OpenCV (camera capture → board grid detection)
• Logic layer: python-chess for move legality, game state
• Communication layer: pyserial over USB → ESP32
• Firmware: Arduino code on ESP32 controlling LED drivers/matrix
Main Components and Interactions
a. Camera Input → BoardDetection module → detected board state
b. Board state → Game module → validate moves and update game state
c. Game state → GUI widgets → update on-screen board & controls
d. Game state → Serial communication → ESP32 firmware → physical LED matrix updates
e. User actions in GUI → Game module → (loop back: validate and send to firmware)
Architectural Patterns and Design Principles
• Layered pattern: Vision → Logic → Presentation → Hardware interface
• Single Responsibility: each Python module handles one concern
• Event-driven GUI: user input triggers callbacks in widgets.py
• Pipeline for image processing: capture → preprocess → grid detection
Final Checklist
• All main components present and labeled
• Notes on external libraries and protocols
• Clear separation (boundary) between PC application and microcontroller hardware