EDIT MODE

Rather than pick another of the community supplied robots that come with the EV3 software, I wanted to build a Rubik's Cube solving robot. It just so happens there is a fantastic project already available that creates one from just the 31313 EV3 parts - the MindCub3r created by David Gilday. Awesome :)

MindCub3r

Over at mindcuber.com they have freely available designs for a Rubik's Cube solving robot for either the NXT 2.0 or EV3 LEGO sets. The MindCub3r for EV3 can solve it in about 1.5 mins.

This is not to be confused with the Cubestormer 3 which recently made the news for breaking the world record time for cube solving (human or machine) in 3.253s. It achieves this with multiple EV3 sets, who knows how many sensors, and runs software on an Android phone.

The MindCub3r uses a standard home edition EV3 set, 3 motors, and 2 sensors. The software consists of four components:

  1. EV3 Enhanced Firmware V1.05M

    This is a modification of the standard LEGO firmware that works better with the Color Sensor in the way it's being used for this robot, and allows it run the background solver process.

    Update - The software now works with the standard 1.06H firmware version, but needs an additional "Brick App" program to be started manually each time it's turned on as detailed on the MindCub3r website.

  2. EV3 Color Sensor RGB Block v1.00

    MindCub3r runs the Color Sensor in a special RGB mode which is not supported in the standard software. This custom block can be imported and is used by the main Mindstorms Program.

  3. MC3Solver Executable

    This is a compiled C++ program that performs the Rubik's Cube solving algorithm. It communicates with the Mindstorms Program to tell it what physical moves are required - via command and data files.

  4. Mindstorms Program

    This is a standard Mindstorms project you can open and edit just like any of the standard robots that came with the set. It controls the operation of the motors and sensors, using input from the MC3Solver executable to tell it what to do.

 

The first three components might be new to some Mindstorms users. However, the MindCub3r website has very clear instructions on how to install and run everything.

Firmware

Update - The software now works with the standard 1.06H firmware version, so this section is no longer relevant but I'll leave the original text below. There is also a new Brick App program to load as detailed on the MindCub3r website.

Before starting, I was on the 1.06H firmware version. Unfortunately, this version has a problem with the way the Color Sensor runs in RGB mode which is why a special version was built - 1.05M. This was possible as LEGO released the source code of the brick.

The fact that I'm replacing 1.06 with 1.05 is not a problem, and the standard firmware can easily be restored afterwards by following the same procedure.

One gotcha is that the Mindstorms application will automatically detect that you are on an older version and remind you to update it!

Build

The building instructions come in a PDF with computer generated instructions. While they look great, there were a few quirks that made it hard to follow sometimes. The bottom framework structure was quite weak and put together in a strange order at first. Eventually it was built up enough to be quite strong and stable.

There were also cases where the part placements were not visible in the images, but rather had to be placed behind it. Basically, it ended up with several mistakes in the build that caused the robot to malfunction. More details on this later.

Design

Despite any building difficulties, the completed build is quite impressive. The four sideways mounted tyres are necessary for keeping the model in one place. While it's operating it can be flung back and forth quite a bit, so the rubber really helps.

The flipping/tilting arm is a clever design – it uses a single large motor. The motor rotates one way to start the flip, then rotates back to it's starting position to complete the flip. No extra movements are required to reset the arm ready for the next flip - all part of making it solve the cube in a pretty fast time.

The cube's rotating platform has about a 3mm gap around each side of the cube. So when it's rotated, needs to go a bit more than 90 degrees, to ensure the cube has fully turned, then it rotates back again to even up the platform. This is a bit of a wasteful movement, but is necessary since the cube needs the gap to flip properly.

The color sensor moves a lot, back and forth to measure the side and corner cubes properly. I wonder if there is a way to avoid this and have it positioned to get both types clearly. That would make scanning much faster, although I presume the designer tried to figure that out.

Getting It Working

You must get the build absolutely correct, or it will simply not work. I certainly didn't get it working first time, so here are the steps I went through.

  1. First attempt - refused to run as it thought the cube was in there when it wasn't, and so hung when scanning an empty space. Turns out there were a couple of wires inserted into the wrong ports. Oops.

  2. Second attempt - it recognised the cube properly, but the scanning arm fell way short of the cube. Eventually found that on page 97 an axle wasn't inserted fully.

  3. Third attempt - it was properly scanning and rotating, but wasn't performing any flips. On page 80 when connecting the flipper arm, there was a backwards connector.

  4. Fourth attempt - sort of working, but wasn't always flipping correctly which made it keep scanning over and over. Eventually I took a bunch of parts off and put them together again, not sure if anything was wrong or I just strengthened it.

  5. Worked! - it looks like some of the framework can work its way loose sometimes and needs to be watched.

One more thing to watch out for is the starting position of the flipper arm. If you set it manually make sure it is rotated fully towards the cube, not away from it - so that it is aiming up at a high angle instead of flat.

RIGHT

WRONG

If you set it wrong when it tries to flip the cube, the force of the motor can pull the whole thing apart. Check out the end of the video clip below for one example.

Cube Solving

MindCub3r can solve the Rubiks Cube from any starting position in no more than about 100 secs from what I measured. Of that, approximately 30 secs is required to scan the cube and then up to about 60 secs to solve it depending on how many moves are required.

The algorithm to solve the cube is built into the compiled MC3Solver code. I asked for the source code to it, but there are no current plans to release it. It uses a home-grown method that turns out to be very fast and efficient, especially considering the fairly low amount of memory available (~3MB of RAM). It solved most of my cubes in ~20-24 moves, which is very close to the official minimum.

Personally I can solve the cube in about 1.5 to 2 mins, but using far more moves. In timed tests, I never managed to beat MindCub3r though :)

Software

Opening up the Mindstorms Project reveals a fairly simple looking program - at first.

Main Program

The light blue blocks represent other custom programs. The entire program consists of many custom blocks, in fact it is written in a highly modular fashion. This makes it quite easy to understand and the code neat and intuitive.

As an aside - I had to upgrade the main Mindstorms software while writing this review to v1.1.1. I'm not sure what the differences are as there doesn't seem to be a public change log. What is annoying is that you always need to download the entire 600+MB installer, instead of a simple patch.

The top row is simply initialising the program, and the second row is a loop that solves the cube over and over again. In fact, the entire scanning and solving code lies behind the single block with the image of a brain and cogs called ScanAndSolve.

ScanAndSolve

The ScanAndSolve program contains most of the program flow for scanning the cube; sending the colors to the MC3Solver program; reading the list of moves from MC3Solver; and then applying those moves. The first custom block is the ScanCube program:

ScanCube

You can see that the ScanCube program simply calls other programs six times to scan each cube face. Inside those programs there are yet more calls to custom programs to scan the different types of edge/corner cubes.

Solve

The Solve program calls SendColorsRGB which writes the list of 54 cube face colors to the file mc3dat. This triggers the MC3Solver program which has been running constantly in the background to calculate the moves to solve the cube. When it's figured that out a few seconds later, it writes the moves back to the mc3dat file. The Solve program then reads from the file and stores the move commands in the arrays (mv_faces, mv_turns, mv_cut).

The ApplyMoves program then goes through the arrays and makes the moves one at a time. How it does this is probably the most confusing part of the program - with lots of nested Switch Blocks. One thing I don't like about the Mindstorms Software is that it will only show you one branch at a time - either the true or false branch must be selected for display/editing. This makes it particularly torturous to understand the nested Switch logic. Eventually each move comprises of a Spin and/or Tilt then a Turn.

Summary

I think this MindCub3r robot is awesome. I've always been fascinated with the Rubik's Cube puzzle since I was a kid. Being able to create a robot to solve the puzzle was a lot of fun. It is obvious that a lot of time and skill has gone into creating this MindCub3r project.

Not only is the MindCub3r a lot of fun, but it is also a great learning tool. By reading its code and truly understanding what it's doing, you can learn a lot of great techniques for programming your own robots.

Click here for the full list of Mindstorms EV3 reviews

12 COMMENTS

  • 1 year, 1 month ago mocbuild101 (3468) MOC Designer
    I want to build this but I can't import the ColorSensorRGB-v1.00 block, the program says "import completed with errors" Can you help ?

    Thanks
    • 1 year ago mocbuild101 (3468) MOC Designer
      FIXED!!!

      I found out that Lego has just updated the EV3 software so I installed the new software and it worked!!!!!!
  • 1 year, 4 months ago Rrz9pn9 (10)
    Curious if you're getting this to work with firmware version 1.06H or if you reverted to 1.05M. I've built this robot and tried using firmware 1.06H, 1.07H and the latest 1.08H. I have the ColorSensorRGB-v1.00.ev3b installed and running. However, when I run the program, the base that holds the cube spins and the display shows "Reset RGB". Did this happen to you? I've triple-checked my cables and they look properly connected.

    Thanks
  • 2 years, 4 months ago cvicisso (10)
    Built the Mindcub3r, but flipper arm doesn't reach far enough (like described in your 3rd attempt above). Can't find backward connector you are talking about on pg 80. Can you help?! Thanks in advance! Great site, btw.
    • 2 years, 4 months ago Nathan (62052) Site Admin Admin
      If memory serves, I had the 48989 spun around and connected with the pin at the front instead of at the back. But it could be anything, you'll just need to look at the images very carefully to spot the differences.
  • 2 years, 4 months ago malkhaz (358)
    Great!. Can someone reference to the algorithm of the Rubic Cubes solving used by this robot?
    • 2 years, 4 months ago Nathan (62052) Site Admin Admin
      I asked the author, but it's not currently open source. It is a home-grown custom built solution to work within the small amount of memory available.
  • 2 years, 4 months ago jantjeuh (60247)
    That's pretty awesome! Impressive to build such a robot with only the EV3 kit. That flip mechanism is quite ingenious.

Login to your account to write comments.