-
Phase 3.5 Completed โ July 2025
-
Phase 4 In Progress โ Q1 2026
-
All core competition features implemented and tested.
-
Multi-robot support, official timer, scoring, and advanced reliability simulation are live.
-
Educational modules (tutorial system, guided exercises) under development.
-
Developer guide for educational features now available.
-
Automated tests for all educational modules run in venv (
fll-sim-env/bin/python). -
Test plan and coding standards updated for Phase 4.
-
Ready for classroom, team, and tournament use. Community and curriculum features coming soon.
FLL-Sim provides a virtual environment for testing and developing strategies for First Lego League competitions. The simulator includes:
- Robot Simulation: Physics-based LEGO robot with customizable sensors and actuators
- Map Environment: Interactive game mat with missions and obstacles
- Mission Framework: Configurable challenges based on FLL seasons
- Visualization: Real-time 2D/3D visualization of robot and environment
- Programming Interface: Python API for robot control and autonomous programming
- Competition Mode: Official FLL timer, rules enforcement, scoring, and tournament features
- Multi-Robot Support: Simulate multiple robots, team coordination, and collision
- Advanced Simulation: Battery, hardware reliability, and performance analytics
- โ Realistic robot physics simulation
- โ Customizable robot configurations
- โ Interactive game mat with obstacles and missions
- โ Sensor simulation (color, ultrasonic, gyro, touch)
- โ Motor control and movement mechanics
- โ Mission scoring system
- โ Real-time visualization
- โ Educational programming interface
- โ Competition timer and rules enforcement
- โ Multi-robot simulation and coordination
- โ Advanced reliability and performance analytics
- โ New: Modular tutorial system and guided programming exercises (Phase 4)
- โ Planned: Community content sharing, curriculum integration, and AI-driven features
- Python 3.8 or higher
- pip package manager
- Clone the repository:
git clone <repository-url>
cd FLL-Sim
```text
1. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```python
1. Install dependencies:
```bash
pip install -r requirements.txt- Install the package in development mode:
pip install -e .
```text
## ๐ฎ Quick Start
```python
from fll_sim import Robot, GameMap, Simulator
# Create a robot
robot = Robot(x=100, y=100, angle=0)
# Load a game map
game_map = GameMap.load_season("2024-submerged")
# Create simulator
sim = Simulator(robot, game_map)
# Run simulation
sim.start()
# Program your robot
robot.move_forward(distance=500) # Move 500mm forward
robot.turn_left(degrees=90) # Turn 90 degrees left
robot.move_forward(distance=300) # Move 300mm forwardFLL-Sim/
โโโ src/fll_sim/ # Main source code
โ โโโ core/ # Core simulation engine
โ โโโ robot/ # Robot implementation
โ โโโ environment/ # Game map and obstacles
โ โโโ sensors/ # Sensor implementations
โ โโโ missions/ # Mission definitions
โ โโโ visualization/ # Rendering and UI
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ scripts/ # Utility scripts
โโโ examples/ # Example programs
โโโ assets/ # Game assets and resources
Run the test suite (always use the project venv):
fll-sim-env/bin/python -m unittest tests/Run with coverage:
fll-sim-env/bin/python -m coverage run -m unittest tests/
fll-sim-env/bin/python -m coverage htmlProduction & testing images are built via the multi-stage Dockerfile in docker/Dockerfile.
docker build -t fll-sim -f docker/Dockerfile .docker run --rm -e FLL_SIM_HEADLESS=1 fll-sim python -m unittest -v testsdocker run --rm -e FLL_SIM_HEADLESS=1 fll-sim fll-sim --headless --exit-after 5Allow local X access (one-time):
xhost +local:root
docker run --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
fll-sim fll-sim-gui --exit-after 5Wayland users may export QT_QPA_PLATFORM=wayland or fallback to xcb.
docker compose up --build sim-headless
docker compose run --rm sim-gui| Issue | Fix |
|---|---|
Could not load the Qt platform plugin "xcb" |
Install host X11 libs, ensure volume mount of /tmp/.X11-unix |
| Black window / no display | Verify DISPLAY and permissions (use xhost +local:root) |
| Wayland warnings | Set QT_QPA_PLATFORM=xcb |
If your OS enforces PEP 668 (externally managed Python), system-wide pip install may be blocked. Prefer using the bundled virtual environment (fll-sim-env/) or install pygame via your package manager:
- Debian/Ubuntu:
sudo apt-get install python3-pygame - Fedora:
sudo dnf install python3-pygame - RHEL/CentOS:
sudo yum install python3-pygame
Alternatively, we provide a helper target and script:
- Makefile target:
make install-system-pygame - Script:
scripts/install-system-pygame.sh(falls back topip install pygame --break-system-packageswhen necessary)
Docker builds already install pygame from requirements.txt inside an isolated venv in the image.
PyInstaller packaging (onefile/onedir) will be provided under scripts/build_windows_exe.ps1 and a spec in packaging/. After build the GUI can be launched via the generated FLL-Sim.exe.
Planned features:
- Bundled Qt platform plugins (qwindows, styles, imageformats)
- Custom application icon
- About dialog with version + license
After pip install -e . you can use:
fll-sim --headless --exit-after 3
fll-sim-gui --exit-after 5Use --headless (or env FLL_SIM_HEADLESS=1) for CI and container runs.
You can provide a mat image or PDF for the GUI background.
- Direct image URL (PNG/JPG):
python launch_gui_enhanced.py --season latest --mat-url https://example.com/mat.png
- Direct PDF URL with rasterization:
python launch_gui_enhanced.py --season latest --mat-pdf-url https://example.com/mat.pdf --mat-pdf-page 0 --mat-pdf-dpi 300- Optional selectors:
--mat-pdf-page-label <label>(uses PDF page label, if present)--mat-pdf-toc-title <title>(uses PDF Table of Contents title, if present)
Downloaded mats are cached under assets/mats/<season>/mat.png.
Use the manifest downloader to grab multiple seasons into assets/mats/:
# manifest.yml
- season: 2024-submerged
url: https://example.com/2024-mat.pdf
type: pdf
page: 0
dpi: 300
# Optional selectors (if available in the PDF):
# page_label: "Mat"
# toc_title: "Field Mat"
- season: 2023-masterpiece
url: https://example.com/2023-mat.png
type: imageRun:
python -m fll_sim.scripts.fetch_all_mats --manifest manifest.ymlDefault physical size is used when exact season sizes arenโt provided. You can override sizes in configs/profiles/defaults.yaml:
mat_sizes:
2024-submerged: [2362.0, 1143.0]
2023-masterpiece: [2362.0, 1143.0]These values are in millimeters: [width_mm, height_mm].
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- First Lego League organization for inspiration
- LEGO Education for the educational robotics platform
- The open-source robotics community
For questions and support:
- Open an issue on GitHub
- Check the documentation
- Join our community discussions
Note: This is an educational simulation and is not officially affiliated with FIRST or LEGO Group.
- Q4 2025: Competition features and multi-robot support (v0.9)
- Q1 2026: Educational platform & community features (v1.0)
- Q2-Q3 2026: AI integration and advanced analytics
- Q4 2026: Enterprise platform and commercial features (v2.0)
For full details, see Project Plan.