A Python-based AI framework for controlling robotic soccer teams in both simulation and real-world environments. The system supports the RoboCup Soccer Simulation Server and can be extended for physical robot control.
- Overview
- Features
- Architecture
- Installation
- Usage
- Development
- Environment Modes
- Technical Details
- License
- Contact
This project provides a complete infrastructure for developing AI strategies for soccer-playing robots. It includes networking components for communication with simulators and robots, data processing utilities, and a modular AI interface for implementing custom strategies.
- Multi-environment Support: Works with simulation, mixed simulation/physical, and field environments
- SSL Vision Integration: Camera-based game state processing using SSL vision protocol
- Concurrent Team Control: Can control multiple teams simultaneously using threading
- Modular AI Interface: Easy-to-extend AI system for implementing custom strategies
- Real-time Game State Processing: Efficient parsing and processing of game state data from simulators and cameras
- Flexible Network Communication: Support for simulator, robot, and camera communication protocols
- Main Entry Point (
__main__.py): Application entry point with command-line interface - AI Interface (
ai_interface/): Pluggable AI system for decision making - Networking (
networking/): Communication layer for simulators and robotsnetworker.py: High-level networking coordinatorsocket_utils.py: Socket management and communication protocolsdata_utils.py: Data serialization/deserialization utilities
ai-team/
├── __main__.py # Main application entry point
├── ai_interface/ # AI strategy implementations
│ └── naive.py # Basic AI implementation
├── networking/ # Network communication layer
│ ├── networker.py # Main networking coordinator
│ ├── socket_utils.py # Socket utilities and protocols
│ └── data_utils.py # Data processing utilities
├── game_logs/ # Game state logs (generated)
└── text_logs/ # Debug/info logs (generated)
Prerequisites: conda must be installed on your system.
- Clone the repository:
git clone <repository-url>
cd ai-team- Create the conda environment with all dependencies:
conda env createThis creates a new "rcai" Python 3.11 environment with all required dependencies including sslclient for camera integration.
- Activate the environment:
conda activate rcaiNote for developers: When adding dependencies, regenerate the environment file using:
conda env export --no-build | grep -vE "prefix: |_libgcc_mutex|_openmp_mutex|ld_impl_linux-64|libgcc-ng|libgomp|libstdcxx-ng" > environment.ymlRun the AI system with default settings:
python .--teamname: Set team name (default: "TritonBots")--env: Set environment modesim-only: Simulator only (default)sim-mixed: Mixed simulator and physical robotsfield-practice: Physical robots with camerafield-tournament: Tournament mode (own team only)
- Create a new AI class in
my_custom_ai.pyunderai_interface/:
from networking.data_utils import GameState
class SoccerAI:
def __init__(self):
# Initialize your AI
pass
def decide_action(self, game_state: GameState, teamname: str):
# Implement your decision logic
output = None
# ... your logic here
return output
def translate_ai_output(self, ai_output):
# Translate AI decisions to robot commands
return ai_output- Update
__main__.pyto use your custom AI:
from ai_interface.my_custom_ai import SoccerAIThe GameState object contains:
count: Server cycle numbertimestamp: Current timestampball_pos: Ball position (x, y)robot_poses: Dictionary of team robot positions
- One or both teams controlled by AI in simulation
- Uses RoboCup Soccer Server
- Ideal for development and testing
- Combination of simulated and physical robots
- Requires additional hardware setup
- Physical robots with SSL vision camera system
- Real-time ball and robot detection via camera
- One or both teams can be controlled
- Only controls your own team
- Other team controlled by opponents
- SSL vision-based positioning and game state
Simulation Mode: Communicates with the Simulation Server using UDP sockets on localhost:
- Client Port: 6000 (robot commands)
- Trainer Port: 6001 (game state monitoring)
Camera Mode: Uses SSL vision protocol via sslclient:
- Receives detection data with ball and robot positions
- Processes protobuf-formatted vision messages
- Real-time field coordinate system
The system processes game state data from two sources:
Simulator Data: Parsed using regex patterns to extract:
- Ball position from simulation messages
- Robot poses and orientations
- Game timing information
Camera Data: Processed from SSL vision protocol to extract:
- Ball position with confidence filtering
- Robot detection with pattern IDs
- Real-time field coordinates and orientations
The system uses threading to:
- Process multiple teams concurrently
- Send commands to multiple robots simultaneously
- Maintain responsive network communication
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 UCSD RoboCup TritonBots
[Add contact information here]