Industrial Control Exemplified: An OSD335x Powered Rubik’s Cube Solving Robot

 

Small scale puzzle, big scale understanding

Applications requiring machine vision and the ability to make decisions without human interference are becoming more widespread.  The OSD335x System-in-Package is a perfect starting point for these types of applications.  Its Texas Instruments ARM Cortex-A8 processor has the power and the peripherals required for them.  The below block diagram illustrates how the OSD335x would fit into a generalized industrial control system.

Industrial Control Robotics System Block Diagram

 

Our team was challenged to design a portable robot to showcase these capabilities.   What better way to highlight the OSD335x’s number crunching might and precise control abilities than a Rubik’s cube solver robot?

System Objectives

As with building any system, the first thing to do when building a robot is to evaluate the objectives and determine system needs. The aim of our robot was to autonomously solve a Rubik’s cube from any starting configuration. Specifically our system needed to:

BeagleBone Blue powered by OSD335x delivers effective control system
  1. Evaluate: Determine the starting position of the cube by extracting color information using a camera
  2. Decide: Calculate the solution to solve the puzzle given any initial configuration
  3. Control: Execute a set of precision moves to solve the cube

In addition, we wanted the system to:

  1. Use existing, off-the-shelf tools and resources
  2. Have a single board design for both image evaluation and control
  3. Be easy to replicate via both Python coding and mechanical design

While brainstorming the ideas, the team identified that the BeagleBone® Blue from Beagleboard.org delivers many of the industrial robotic control features required for this project, including precision motor control. BeagleBone Blue provides an off-the-shelf hardware and software platform that takes advantage of many of the industrial control features provided by the OSD335x devices. The powerful on board processor integrated into the OSD335x runs a Debian Linux software image that is capable of quickly analyzing data and executing complex algorithms developed in languages such as C and Python.

Design the mechanical control system

Determining the number of ‘arms’ needed, their configuration and how to control them were key design decisions of the mechanical control system. We could have as many as six arms, each controlling the rotation of a particular side. However, by evaluating hardware techniques from other projects online[1] we decided to use three arms to execute all the movements. This also frees up one side of the cube so that a camera can easily capture the images of it for the BeagleBone Blue to process.

Mechanical design of control arm

We used the Actobotics[2] building system for the arm construction materials. We chose to use six Hitec (HS-422) servos to control the arms. The servos provide the features the design required and easily interface with BeagleBone Blue.

Each arm has 2 servo motors:

  • One to open and close the “hand”, which holds the cube and interfaces easily with the Actobotics gripper kits
  • The second is used to operate the “wrist” which will rotate the cube both 90 degrees clockwise and 90 degrees counter-clockwise.

We also needed a base board that would enable us to mount all the arms and the camera at fixed positions. While debugging, we used a hot glue gun to experiment with the positioning of the arms. After testing and performing all possible moves on a Rubik’s cube, the arms were attached to the base board with aluminum brackets to make assembly and disassembly easy.

Completed mechanical design of Rubik’s Cube solver

 

Determine the initial state

Once the arms were complete, we moved on to the next task of determining the initial state of the cube by identifying the color and position of each tile. Based on available tutorials with Beaglebone[3], we chose to use OpenCV along with a Logitech C920 camera to capture and identify the colors on each side of the cube. OpenCV has a feature rich set of library functions designed for Computer Vision tasks. The framework comes with functions to not only interface and set parameters of the camera, but also manipulate and extract information from captured images.

Due to the configuration of the camera and arms, the camera cannot actually ever see the left and right faces of the cube. Therefore, we developed a series of moves that allows the camera to scan the tiles on the left and right sides of the cube. The centers of the left and right faces have to be inferred from the centers of the four faces the camera can see.

Camera capture of cube tile positions

To make our demo portable, we needed to address the variability of light in the environment and the camera’s automatic white balancing capabilities. Due to the nature of the RGB color space, it can be difficult to reliably classify colors in different lighting environments. In order to minimize environmental effects, an LED light strip was employed to illuminate the cube and white strips were placed at 4 corners of the cube to provide a white reference for the camera. Also a LAB + RGB color space based thresholding algorithm was used to classify colors. This made for a robust color classifier for the robot.

Calculate the solution

We then used an algorithm to solve the Rubik’s cube once it had been mapped. Though this part of the software can be a little processor intensive, the 1GHz OSD335x handles these kinds of tasks with ease. Rubik’s cube Python solver Cube Explorer 5.13 package[4] was chosen for the task since it can often provide a solution in less than 20 moves.

Software development for Rubik’s cube solver

This program is based on Herbert Kociemba’s Two-Phase Algorithm[5] which divides the cube solution into smaller sub-problems. The space of all possible cube positions is divided into subgroups where each sub group is derived by restricting the types of moves executed. The algorithm works by determining cube movements from one sub group to the next and later optimizing the set of moves. This algorithm needs at most 29 moves and can generally solve the cube in less than 20 moves. The results of Kociemba’s method is an efficient algorithm for our purpose.

Execute the commands

To control each arm we took advantage of Beaglebone Blue’s 8 servo control channels which are controlled by one of the internal PRUs (Programmable xReal-Time Units). These are 200MHz microcontrollers that run independently from the main AM335x processor and are able to generate fine-grain PWM signals needed for the servo control without putting any extra burden on the processor. We used off-the-shelf software resources available to develop and fine tune the control system. A motor control library called RoboticsCape[6] is available with a Python wrapper called ‘rcpy’[7] and was written specifically for the BeagleBone Blue.   The Cloud9 IDE that comes with the Blue out of the box allows for software development through any web browser and is easy to use.

The overall system was able to effectively scan the cube, determine current state, run the solution algorithm and execute the moves. Based on our trial runs, the robot solves the cube in four minutes, which is way faster than Greg who is still working on his solving skills!

Take it on the road

In addition to a fun engineering challenge, the project shows how easy it is to develop and build complex industrial control systems with OSD335x System-In-Package. By using BeagleBone Blue, no additional circuitry was needed, it was low cost, and easily portable. In fact, the BeagleBone Blue is a perfect example of a complex electronic system that benefits from the System-In-Package technology of the OSD335x.

Due the overwhelming popularity we decided to share additional insight into the creation of the demo on this Hackster.io page.

Contact us to solve the puzzles in your Industrial Control Systems design.

Rubik’s cube solver demonstration

References:

[1] Cornell mechanical reference
[2] Actobotics
[3] Using Beaglebone & OpenCV
[4] Cube Explorer 5.13 Package
[5] Kociemba Algorithm
[6] Robotics libraries
[7] rcpy repository

 

 

 

 

 

 

 

 

One thought on “Industrial Control Exemplified: An OSD335x Powered Rubik’s Cube Solving Robot

    Comments are closed.