# Baxter Solves Rubiks Cube

## Summary

Version 1.0 of Active Robots Systems Integration Example, using the Baxter Research Robot to solve a Rubik's Cube.

This project was conceived to give an example of how to easily integrate the Baxter Research Robot into a research application, including the use of additional open and closed source software libraries, the Baxter Research Robot Research Software Development Kit (RSDK) and external sensors integrated into the system as a whole, with no custom designed hardware, everything is 'out-of-the-box'.

This version of the software was first publicly demonstrated at the Rethink Robotics UK Conference, hosted by Active Robots, with Guest Speaker: Rodney Brooks. Earlier versions were demonstrated at various Universities around the UK from November 2013.

## System Workflow Overview

The process workflow was as follows:

Detect -> Verify -> Solve -> Manipulate -> Complete

## Detect

Using Baxter's Zero Force Gravity Compensation mode, Baxter is taught the position of the flatbed scanner. Baxter then uses the scanner to take an image of each of the Rubik's cubes 6 faces. Using the functionality of the open-source computer vision library, OpenCV, the images are processed using a combination of square, line, edge and blob detection. Missing squares are interpolated from the known 3x3 pattern if needed. Colours are then sampled from the centre of each of the 9 squares on the face and matched as RGB tuples in vector space. A mapping of the cube is generated.

## Verify

Custom verification algorithms were developed that verify the mapping created is of a valid cube. Finding the cube to be invalid would indicate that the detection was flawed, and lead to Baxter re-evaluating the cube with the scanner. Verification checks include determining that there are: 6 distinct colours, 9 of each colour, centres are unique, edges/corners have valid colours and are unique.

## Solve

Solving of the Rubik's Cube is performed using the Kociemba algorithm. Developed by Herbert Kociemba in 1992, it was used in 2010 to prove that all mappings of the Rubik's cube can be solved in 20 or fewer moves. We used a closed source implementation for ease of use, however open source implementations are available. Our cube mapping is given to Kociemba and returned is a list of manipulations to be performed on the cube, in Singmaster Notation, a standard description of Rubik's Cube manipulations.

## Manipulate

Most Rubik's cube robots are custom built, with the cube/robot interface being designed or adapted to fit the cube and allow for fast, accurate manipulations with self-centring grips and no possibility of misalignment. This implementation contains no hardware modifications, all grippers and manipulators are standard Rethink Robotics Electric Parallel Grippers, with standard fingers and fingertips.

Manipulations are achieved using the RSDK to command Inverse Kinematics (IK) moves and the Joint Position Control interface.

## Development Changes v0.1 - v1.0

Beta v0.1 was functional, but had limitations in 2 main areas:

• Robustness of colour detection in varying light conditions, leading to incorrect colour mapping.
• Robustness of manipulation due to Joint Position Control Accuracy, leading to failed manipulations.

These limitations were addressed in two ways:

• Utilising an external flatbed scanner to enable robust colour detection and matching (instead of head camera), additionally demonstrating the ease of integration of external sensors into the Baxter Research Robot environment.
• Use of the update to the RSDK (version 0.7.0) by Rethink Robotics that improved Joint Position Control Accuracy by a factor of 10.

## Future Development

• Update to RSDK v1.0.0.
• Clean code from Development to Release Candidate status.
• Expand this wiki entry.