← Back to Home
advertisement
From zero to Rubik’s cube solving robot

From zero to Rubik’s cube solving robot

TL;DR: I have built a robot that solves the Rubik's cube without any prior experience. knowledge or experience with electronics or Raspberry Pi, Arduino, Python in less than a year as a pet project. How it all started It all started when I bought a Rubik's cube just for fun. I had several of them when I was a kid, but I could never solve any of them. I even remember that I had some papers explaining how to solve it, but I didn't understand anything at the time. So when I got my cube, a year ago, I set out to solve it and I could only solve one side and maybe get the corners matching, but that was it, I couldn't solve the next phase (the second layer). Then I found a tutorial on the Internet “The Beginner's Method”. It was a step by step tutorial on how to solve any Rubik's cube. It was a little frustrating at first, until I learned the notations and could understand the steps. The next phase was learning the order of the steps and their algorithms, and I was finally able to solve my cube. This was my mental exercise for several days, maybe a week. After mastering the "beginner's method", I was able to solve the cube in about 2.5 minutes. After that the fun stops, you know you can solve the cube and it's no longer interesting unless you need to kill time. Algorithm Challenge: Represent the Cube in Code The next phase was to make a program that can solve the Rubik's cube, not that any of them were developed before, but I thought it would be a good exercise for me. Since the “beginner method” is a simple algorithm that must be applied to the cube in a certain order, it should be easy to develop a program that does it for me. The first challenge was to make a good representation of the cube using Objects in object-oriented programming. I chose to use Test Driven Development (TDD) and I never regretted it. Writing complicated software requires a lot of attention to detail and requires keeping track of every algorithm, and that's impossible to achieve without TDD, especially when you don't develop it every day, because it's a pet project and you only spend a fraction of your free time on it. Without testing you will surely be lost after 2 weeks of development and you will never know if any of your changes break anything until you apply all the steps to the bucket, which is time consuming and exhausting. After several unit and object tests, I was able to create the first console application where I could visually see how my application progressed, from coding to solving cube variations. When I was done with the algorithm and it passed all the unit tests, the application was able to define a solved cube, code it, and solve it using the "beginner method", all done in ~200 steps. I was very amazed and proud, not because I had done something that had not been done before, but because I did it completely alone and my favorite project was underway. Raspberry Pi Have an algorithm that solves the cube, and only works as a console The app is not very fun. It is so abstract that it solves a real problem in the abstract environment. You can't see/feel the actual resolution, you can only define a matrix that represents a formation/combination of cubes and the algorithm will give you a set of rotations that you must perform to solve the cube. The next phase for me was to build a robot that solved the cube. All you have to do is apply the steps of the algorithm output to a physical cube. I never built or programmed a robot, I had no idea where to start. My idea was to have a motor that would rotate the hub, that was the simplest model I could think of. After doing some research on the internet, I discovered stepper motors. A stepper motor is a type or
advertisement

Related Articles

advertisement