Raspberry Pi LEGO sorter
Raspberry Pi is at the heart of this AI–powered, automated sorting machine that is capable of recognising and sorting any LEGO brick.
And its maker Daniel West believes it to be the first of its kind in the world!
This mega-machine was two years in the making and is a LEGO creation itself, built from over 10,000 LEGO bricks.
It can sort any LEGO brick you place in its input bucket into one of 18 output buckets, at the rate of one brick every two seconds.
While Daniel was inspired by previous LEGO sorters, his creation is a huge step up from them: it can recognise absolutely every LEGO brick ever created, even bricks it has never seen before. Hence the ‘universal’ in the name ‘universal LEGO sorting machine’.
- Raspberry Pi 3 Model B+
- Raspberry Pi Camera Module V2
- 9 servo motors (controlled through a servo multiplexer communicating with the Raspberry Pi on I2C)
- 6 LEGO motors (controlled through L298N motor controllers using digital I/O ports on Raspberry Pi)
The artificial intelligence algorithm behind the LEGO sorting is a convolutional neural network, the go-to for image classification.
What makes Daniel’s project a ‘world first’ is that he trained his classifier using 3D model images of LEGO bricks, which is how the machine can classify absolutely any LEGO brick it’s faced with, even if it has never seen it in real life before.
Daniel has made a whole extra video (above) explaining how the AI in this project works. He shouts out all the open source software he used to run the Raspberry Pi Camera Module and access 3D training images etc. at this point in the video.
LEGO brick separation
Daniel needed the input bucket to carefully pick out a single LEGO brick from the mass he chucks in at once.
This is achieved with a primary and secondary belt slowly pushing parts onto a vibration plate. The vibration plate uses a super fast LEGO motor to shake the bricks around so they aren’t sitting on top of each other when they reach the scanner.
Scanning and sorting
A Raspberry Pi Camera Module captures video of each brick, which Raspberry Pi 3 Model B+ then processes and wirelessly sends to a more powerful computer able to run the neural network that classifies the parts.
The classification decision is then sent back to the sorting machine so it can spit the brick, using a series of servo-controlled gates, into the right output bucket.
Daniel is such a boss maker that he wrote not one, but two further reading articles for those of you who want to deep-dive into this mega LEGO creation:
- How I created over 100,000 labeled LEGO training images
- A high-speed computer vision pipeline for the universal LEGO sorting machine
This is SO IMPRESSIVE. It looks like a lifetime project, but the maker isn’t that old yet and has finished it already!
I wonder if I can borrow this machine for a few days. ?
Can I borrow it after you do?
I NEED THIS NOW!!!!!
This is just amazing. Cool project.
Jacques Mattheij built something like this four years ago:
Which is also mentioned a few seconds into the video.
I wonder if would be possible to create a “LEGO sorter Zero”, to classify images without human supervision, just watching different images of the bricks.
What about a machine to get the pieces of a desired set from the available stock? :)
Such wonderful engineering.
Great project! Any idea what the chances are of it making a mistake?
Would really like to see this go to market… Even if it isn’t made of Lego to keep the cost down.
Strony WWW Kłodzko
Awesome! I also use LEGO with my Arduino but RPi is more advanced!
You area genius. The Lego company should create your machine as a Lego model and pay you a gazillion dollars! I am going to watch for your beast model.
Daniel West, take a bow. This is such a great idea and is beautifully made! Genius.
Does this work with raspberry pi 0 w? I really want this but I don’t have that lego/money/more money – it’s absolute genius!
Comments are closed