RuCuS - Autonomous Rubik's Cube Solving Robot using NI Hardware and Software Products by Christian V. Madritsch Electronic and Equipment Engineering Carinthia University of Applied Sciences Austria Andreas Bachinger, Gerald Stanje, Dominik Kropiunik, Christian Cemernjak, Stefan Lanschützer Students of Electronic Engineering Carinthia University of Applied Sciences Austria Dr. Thomas Klinger Head of School Carinthia University of Applied Sciences Austria Category: Control Products Used: NI LabVIEW™ 7.1, NI Vision Builder AI™ 2.0, NI Vision Assistant™ 7.1, NI Vision Development Module™ 7.1, NI Compact Vision System™ 1455, NI cRIO-9004, NI cRio-9474, NI cRio-9263, NI cRio-9215, NI cRio-9411 The Challenge: To develop an autonomous robotic system which automatically detects the state of a Rubik's Cube, computes, using a known solving algorithm, the necessary movements to solve the cube, and finally controls the robotic system to solve the Rubik's Cube. The Solution: Using NI hardware and software products in all phases of system design and implementation: Vision Assistant, Vision Builder AI, and Compact Vision System to develop the image processing and analysis methods, LabVIEW and the Real-Time I/O Module to develop the solving algorithm and to perform the robot control. Abstract A group of five electronic engineering students decided to design and develop a challenging autonomous Rubik's Cube Solving Robot - RuCuS. The objective was to design a system which is able to automatically detect the scrambled state of a Rubik's Cube using image processing and analysis methods. The state information is used as an input for the computation of the solving algorithm. The output of the solving algorithm is a list of necessary movements to bring the cube into its initial ordered state. Finally, three grippers are being controlled to carry out the computed movements. Introduction The Rubik's Cube, invented by Erno Rubik in 1974, is the best selling toy puzzle in history. In a Rubik's Cube, twenty-six individual little cubes or cubies make up the big cube. Each layer of nine cubies can twist and the layers can overlap. Any three squares in a row, except diagonally, can join a new layer. A Rubik's Cube can have about 43 quintillion (a one with 18 zeros) different positions. Despite the vast number of possible positions, all cubes can be solved in 29 moves or fewer. The autonomous Rubik's Cube Solving Robot (RuCuS) consists of three main subsystems: image processing and analysis, solving-algorithm computation, and the robot control. The purpose of the image processing and analysis subsystem is to detect the scrambled state of the Rubik's Cube. The cube can be placed into the system in any valid scrambled state; the image analysis detects the position of all cubies and their corresponding colors. The output of the image analysis is a string containing the color information of all 54 color planes using the format: RGGRWRWY…; each letter corresponds to a color; the position of the letters corresponds to the position on the cube. This information is sent to the solving-algorithm computation subsystem. This subsystem uses an existing solving algorithm and the input color string to compute a list of movements which will transform the cube into the solved state. Those movements are performed by the robot control subsystem using three independent grippers. Figure 1 shows an overview of the complete system including information about the communication. The image processing and analysis is realized using a Sony DFW-VL500 digital camera with FireWire-interface and the NI Compact Vision System CVS1455. The output string is sent via Ethernet to the NI cRIO-9004 module. There, the solving-algorithm subsystem and the robot control subsystem are being executed. After the solving-algorithm computed the necessary movements, this information is passed to the robot control. The robot control interconnects to the hardware using digital and analog I/O lines. Figure 1: Overview of the Autonomous RuCuS System The system development was done using a PC with LabVIEW and the image processing tools (IMAQ Vision, Vision Builder, etc.). After the prototyping phase was completed, the developed software components were migrated onto the target platforms CVS and cRIO. Image Processing and Analysis The purpose of the image processing and analysis is to detect the scrambled state of the cube. Therefore, three of the six sides of the cube need to be analyzed. The remaining three sides can be calculated. This color information is passed to the solving algorithm. The hardware setup for the image processing and analysis consists of a Sony DFW-VL500 digital camera with FireWire interface. The illumination of the system is realized using LED-rows of different colors. During development, NI Vision Builder and Vision Assistant have been used. Different processing and analysis methods have been tried out. The final version comprises of only a Color Threshold in combination with a Count Pixel function. The color threshold is set to one of the six possible colors (blue, white, red, orange, yellow, and green). Using the count pixel method, each cubie is analyzed if at least 50 pixels of the checked area are of the selected color (see Figure 2). Figure 2: Screenshot of the Analyze Cube Functionality If this is the case, the color of the cubie is detected; if not, the whole process is repeated using a different color threshold. The output of the image analysis is a string containing the color information of all color planes. This information is sent to the solving-algorithm subsystem using Ethernet. Computation of the Rubik's Cube Solving Algorithm The solving subsystem uses the Two-phase algorithm which performs an iterative search on a unary tree using additional heuristical information. The memory consumption is less than 20MB and the average computed solution length is about 20 moves. Using the cRIO-9004 system as target platform, the calculation of the list of necessary movements usually does not take more than a few seconds. The calculated list consists of rotation operations by 90or 180-degrees for each side of the cube (e.g. R, L', F2 means: rotate left side by 90-degrees clockwise, rotate left side by 90-degrees counterclockwise, rotate front side by 180-degrees). The results of the solving algorithm are passed to the robot control subsystem. Robot Control using NI cRIO Hardware The robot control subsystem consists of three independent grippers with two degrees of freedom each. The grippers can be opened, closed, and turned around their main axis using two DC-motors. During cube movement, usually two grippers hold the cube and the third gripper performs the rotation operation. All mechanical components have been manufactured in house using a 3D-plotter based on plastic strings. The DC-motor boosters and the sensors are connected to the I/O-modules of the cRIO system. Furthermore, a simple user interface is realized using start/stop buttons and a LCD-display to output status information. During robot control, the list of movements from the solving algorithm is transformed into individual movements of each gripper. After all movements have been carried out, the solved Rubik's Cube can removed from the system. Conclusion The RuCuS student project is an ideal example of problem based learning. Different concepts like image processing and analysis, computation-intensive search algorithms, and robot control could be combined into one system. The attending students have become experts in using hardware and software components from NI.