This project is heavily inspired by numerous preceding LEGO® sorting machines, I'd like to give credit in this post. For background information visit our blog or YouTube channel.
If you want to build a LEGO® sorting machine yourself, I suggest to start with the DIY build instructions. This repository maintains the sources to operate the LEGO® sorting machine. If you want to work on the machine learning components, the training scripts for the part classifier are maintained here.
With prerequisites Python 3.11 and Conda installed, setup conda environment:
./update_environment.sh # Linux
update_environment_win.bat # Windows
Adapt local config (currently no adaptions needed):
cp config.json.example config.json
Machine controller (on raspberry pi, connected to motor drivers):
python sorter.py controller [--disable_machine]
Vision service (on alternative PC):
python sorter.py vision --host=RASPBERRY_PI_IP_ADDRESS --collect_class=None
Classification service (on alternative PC):
python sorter.py classification --host=RASPBERRY_PI_IP_ADDRESS --model=models/CLASSIFIER_MODEL.h5
Notification service (on alternative PC):
python sorter.py notification --host=RASPBERRY_PI_IP_ADDRESS
Install git pre-commit hooks for flake8
, black
and isort
usage:
pre-commit install
Run unit tests:
python -m unittest discover -s test -p "test_*.py"
Run static type checking via mypy
(type hints are still pretty sparse in the code so mypy support is currently limited):
python -m mypy sorter.py