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

Some people like crossword puzzles, some are serious sudoku ninjas, but [Andrea Favero] likes to keep himself sharp, by learning coding and solving control problems, and that is 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 is needed on the way there. [Andrea] chose to build an autonomous Rubik’s cube solver, and was kind enough to document exactly how how to do it, and we’re glad of it!

The result of the openCV processing chain

Working in python with OpenCV, [Andrea] uses the methodology by [Oussama Barkouki] to process each face image and convert it into a table of the colours of individual facelets. The basics of that, are first to convert the image to grayscale, then use a gaussian blur to denoise the image. Edges are identified using the canny algorithm, the result of which is then dilated and passed into a contour detector. The contours are sent into a cunning filter that identifies square contours, and those the wrong size are filtered off. What you’re left with are the outlines of the actual coloured facelets. Once you have a list of squares, these can be used to form image masks, and thence select the average colour from each square. The colour is then quantised and stored as a labelled colour from the standard Western Rubik’s cube colour scheme. Finally, once all face images are captured and facelets colours identified, the data are passed into a Rubik’s cube solving algorithm developed by [Hegbert Kociemba,] a guide to which is available on the speedsolving 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 learn about Raspberry Pis. Part of the fun was installing and configuring a Pi4, with all the necessary dependencies. The hardware was constructed from plywood, and a load of 3D printing. (All STLs are available in the first link) Following the (incredibly detailed) build guide should be straightforward enough. A Pi4/2Gb model with PiCamera was found sufficient (good luck finding one! Maybe try rpilocator?) with a stepper motor for cube rotation, and a pair of servos, one for operating the lid/camera mount, and a second to kick the cube around a second axis. The beauty of this simple, elegant approach is that it can handle a standard unmodified cube (ok, a slightly sanded one) — unlike some of the crazy speed-solving builds we’ve seen — it isn’t the fastest cube solver we’ve seen, but it is one of the coolest.

Want to see a cube solve itself? (kind of) here you go. And let’s finish on a, topical subject, with a coronavirus inspired ‘cube hack, just because they could.


12 thoughts on “Forget Sudoku, Build Yourself A Minimalist Rubik’s Solver Robot

    1. Hi, in theory you’re fully right, in practice the cube and camera positions have tolerances…. especially when the facelets aren’t well aligned to the face.
      By restricting the facelet area to a small portion it might be still possible, yet the average color detection will be less trustable.
      This project is far from being optimized, therefore it leaves lot of space for improvements 😁

  1. There’s nothing to say it can’t choose a valid combination and solve it to match.
    Perhaps it could be an interesting art piece. A wall of rubix cubes, each one set to match the pixels in order to collectively display an image.

  2. The number of unique permutations is huge, right? Although if you keep a particular state and just permuted colors, that’d cut things down by 6!, but idk maybe that’s already factored in.

    Anyway, that would seem to imply it takes a fair number of bits to identify a state, right? Conversely, a cube state could represent that many bits. So, provided you could look at a ‘randomized’ cube and recover the number for that permutation, you’d get that many bits. So a bunch of seemingly scrambled cubes could be used to convey a message.

    You got to think like a squirrel

  3. Looks conceptually similar to the Tilted Twister Lego Rubik’s Cube solvers—scroll down past the clocks—and it’s even tilted the same way, but the cube flipping mechanism is different. Interesting example of convergent design: presumably the tilt in both designs is to help reseat the cube after flipping it.

    1. BricKuber is also similar, though without the tilt, and was covered by Hackaday a few years ago:

      According to the comments there—I didn’t watch the second video—that one cites the MindCuber family of Lego Rubik’s Cube solvers (also untilted) as inspiration, and the commenter says “the design goes back farther” to Tilted Twister, but I don’t know if that’s in the form of inspiration or just a coincidence, because the MindCuber website doesn’t seem to say.

      1. Here’s another similar one: It’s quite cobbled-together-looking, requires manual entry of the starting state of the cube, and uses what looks like an extremely inefficient algorithm (which might also be limited by not having continuous rotation on the vertical axis like the others do), but still won multiple awards! Its creator complains (in the comments on another post) that it’s hard to find the Hackaday post because “Rubik’s” is misspelled every time it appears in the title, body, and tags, and says that might be why hasn’t been linked to from any other posts.

    2. I got indeed inspired by the Tilted Twister concept, for the inclined cube holder; This is esplicitly reported on the robot build documentation ( .
      Thanks to that angle, the cube flipping is achieved by forcing a limited angle change: The remaining pflipping action simply happens because of gravity force (center of mass moved beyhond the foothold).
      Without such initial slope, the cube flip would require a less simple action…

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.