December 8, 2022
  • December 8, 2022

Forget Sudoku, Build Yourself a Minimalist Rubik’s Solver Robot

By on February 3, 2022 0

Some people love crossword puzzles, others are serious sudoku ninjas, but [Andrea Favero] likes to stay sharp, learning to code and solving control problems, and that’s something we can definitely relate to. When learning a new platform, it’s a very good idea to have a substantial project or goal in mind, and learn what’s needed along the way. [Andrea] chose to build a standalone Rubik’s cube solver, and was kind enough to document exactly how to do it, and we’re thrilled about it!

The result of the openCV processing chain

Work in python with OpenCV, [Andrea] uses the methodology by [Oussama Barkouki] to process each face image and convert it into a color chart of the individual facets. The basics of this are to first convert the image to grayscale and then use a Gaussian blur to denoise the image. Edges are identified using the clever algorithm, the result of which is then expanded and fed to an edge detector. The outlines are sent through a smart filter that identifies square outlines, and the incorrectly sized ones are filtered out. You are left with only the outlines of the actual colored facets. Once you have a list of squares, these can be used to form image masks and then select the average color for each square. The color is then quantized and stored as a labeled color from the standard Western Rubik’s cube color scheme. Finally, once all the face images have been captured and the facet colors have been identified, the data is passed to a Rubik’s cube solving algorithm developed by [Hegbert Kociemba,] a guide for which is available on the speed resolution site. The result of the solving step is a sequence of descrambling moves, in the move notation developed by [David Singmaster]. Fascinating stuff, if you ask us!

Modular hardware approach – no custom PCBs

All of the above can be prototyped on a PC, but [Andrea] wanted to know more about Raspberry Pis. Part of the fun was installing and configuring a Pi4, complete with all the necessary dependencies. The hardware was constructed from plywood and 3D printing filler. (All STLs are available in the first link) Following the (incredibly detailed) build guide should be pretty straightforward. A Pi4/2Gb model with PiCamera was deemed sufficient (good luck finding one! Maybe try rpilocator?) with a stepper motor for cube rotation and a pair of servos, one to operate the lid/ camera support, and a second for kick the cube around a second axis. The beauty of this simple and elegant approach is that it can handle a standard unmodified (ok, a little sandblasted) cube – unlike some of the crazy speed solving builds we’ve seen – it’s not the solver of fastest cube we’ve seen, but it’s one of the coolest.

Want to see a cube solve itself? (sort of) here it is. And let’s end on a hot topic, with a coronavirus-inspired cube hack, just because they could.