Demostración educativa comercial: Integración del brazo robótico Dobot Magician con ajedrez, jugando contra el motor de ajedrez Stockfish en tiempo real.
- Frontend Interactivo: Interfaz React moderno y responsivo
- Backend Python: FastAPI con WebSockets para tiempo real
- Motor de Ajedrez: Stockfish local (800 ELO - Fácil)
- Control de Robot: SDK Dobot con reintentos automáticos
- Cola de Jugadores: Sistema de turnos para múltiples usuarios
- Dockerizado: Listo para desplegar en Raspberry Pi
- Dobot Magician arm
- Raspberry Pi 4+ (2GB mínimo)
- Cable USB para conectar Dobot
- Conexión a red
- Docker & Docker Compose
- O (sin Docker):
- Python 3.11+
- Node.js 18+
- Stockfish 15+
# Clonar/descargar el proyecto
cd Dobot-Chess
# Construir imágenes
docker-compose -f docker/docker-compose.yml build
# Ejecutar servicios
docker-compose -f docker/docker-compose.yml up
# Acceder a:
# Frontend: http://localhost:3000
# Backend API: http://localhost:8000
# Health Check: http://localhost:8000/healthcd backend
# Crear entorno virtual
python3 -m venv venv
source venv/bin/activate # En Windows: venv\Scripts\activate
# Instalar dependencias
pip install -r requirements.txt
# Configurar Dobot (ver calibración más abajo)
# Crear archivo .env si es necesario
# Ejecutar servidor
python app.pyBackend corre en: http://localhost:8000
cd frontend
# Instalar dependencias
npm install
# Ejecutar servidor de desarrollo
npm startFrontend corre en: http://localhost:3000
Muy importante: Antes de jugar, calibrar las esquinas del tablero.
cd calibration
python board_calibration.pyEl script te guiará interactivamente:
- Posiciona el gripper en esquina superior-izquierda (a8)
- Posiciona en esquina superior-derecha (h8)
- Posiciona en esquina inferior-izquierda (a1)
- Posiciona en esquina inferior-derecha (h1)
Las coordenadas se guardarán en backend/config.py
- Iniciar partida: Click en "Iniciar Partida"
- Si hay cola: Esperar tu turno (máximo 5 minutos en cola)
- Realizar movimiento: Click en casilla origen, luego destino
- Robot juega: El brazo automáticamente ejecuta su movimiento
- Repetir: Hasta que alguien gane/pierda/pida tablas
Dobot-Chess/
├── backend/
│ ├── app.py # FastAPI main application
│ ├── config.py # Configuration settings
│ ├── chess_engine.py # Stockfish wrapper
│ ├── dobot_controller.py # Robot arm control
│ ├── game_manager.py # Game logic & queue
│ └── requirements.txt # Python dependencies
├── frontend/
│ ├── public/
│ │ └── index.html # HTML entry point
│ ├── src/
│ │ ├── App.jsx # Main component
│ │ ├── components/ # React components
│ │ │ ├── GameBoard.jsx
│ │ │ ├── GameInfo.jsx
│ │ │ └── Queue.jsx
│ │ ├── services/
│ │ │ └── gameService.js # API client
│ │ └── index.js # React entry point
│ └── package.json # Node dependencies
├── calibration/
│ └── board_calibration.py # Board mapping tool
├── docker/
│ ├── docker-compose.yml # Container orchestration
│ ├── Dockerfile.backend # Backend image
│ └── Dockerfile.frontend # Frontend image
└── README.md # Este archivo
Crear backend/.env:
DEBUG=False
HOST=0.0.0.0
PORT=8000
DOBOT_PORT=/dev/ttyUSB0
DOBOT_BAUDRATE=115200
DOBOT_RETRY_ATTEMPTS=3
STOCKFISH_PATH=/usr/games/stockfish
STOCKFISH_ELO=800
STOCKFISH_DEPTH=15
MAX_CONCURRENT_GAMES=1
QUEUE_TIMEOUT=300POST /api/game/start - Iniciar/encolar partida
GET /api/game/state - Estado actual
POST /api/game/move - Realizar movimiento
POST /api/game/resign - Rendirse
WS /ws/game/{game_id} - WebSocket actualizaciones
# Verificar puerto USB
ls -la /dev/ttyUSB*
# Verificar permisos
sudo usermod -a -G dialout $USER# En Raspberry Pi
sudo apt-get install stockfish
# En macOS
brew install stockfish
# En Ubuntu
sudo apt-get install stockfish- Aumentar
QUEUE_TIMEOUTenconfig.py - Verificar firewall: asegura puerto 8000 abierto
┌─────────────────┐
│ Frontend │ (React)
│ :3000 │
└────────┬────────┘
│ HTTP/WebSocket
│
┌────────▼────────────────────────┐
│ Backend (FastAPI) :8000 │
├─────────────────────────────────┤
│ ├─ Game Manager (Queue) │
│ ├─ Chess Engine (Stockfish) │
│ └─ Dobot Controller │
└────────┬──────────┬─────────────┘
│ │
│ │ USB
│ │
[Files] ┌────▼─────────┐
│ Dobot Magician│
└────────────────┘
Este proyecto demuestra:
- Integración Hardware: Comunicación USB con dispositivos
- Sistemas Tiempo Real: WebSockets, colas, reintentos
- Ajedrez: Notación UCI, movimientos legales, Stockfish
- Full-Stack: Python backend, React frontend
- DevOps: Docker, configuración, health checks
- Robótica: Cinemática inversa, movimientos precisos
Proyecto educativo. Uso libre para fines comerciales y académicos.
Demostración desarrollada para mostrar capacidades de integración en ingeniería.
Última actualización: Mayo 2026