Otvinta.com Home
Home  •  Tutorials  •  Calculators  •  3D Models  •  About  •  Contact
 
3D Model 12: 3D-Printable Rubik's Cube Solving Robot

1. General Information

This 3D-printed Raspberry Pi-powered Rubikís Cube solving robot has everything any serious robot does -- arms, servos, gears, vision, artificial intelligence and a task to complete. If you want to introduce robotics to your kids or your students, this is the perfect machine for it.

This one-eyed four-armed giant stands 35cm (14") tall. 70 hours of print time and an entire spool of filament are needed to print it, not to mention over $200 worth of hardware, but once fully operational, it will surely wow your friends and neighbors. Scramble your Rubik's cube, place it in the robotís grippers, press a button, and then sit back and watch this amazingly smart and stunningly beautiful machine put it back together. Watch the video below!

This robot is fully 3D-printable. Other that the servos, servo horns, camera, electronics and a few dozen bolts and nuts, it has no traditionally manufactured parts. Absolutely no soldering or breadboarding is required.

Click to download these .STL files

Download Link
Filename:rubikscubesolvingrobot.zip
Format:.STL
Size:2.55 MB
Last Updated:2017-09-17

2. Introduction Video

3. Licensing

This product is distributed under the following license:

Creative Commons - Attribution - Non-Commercial - No Derivatives

For educational and commercial licensing, please contact us.

4. List of 3D-Printed Parts

ItemQuantityPrint Time (min.)Total Time (min.)Filament (gr.)Total Filament(gr.)
rcr_arm418674454.44217.76
rcr_slider414558032.26129.04
rcr_pinion421845.0320.12
rcr_rack44618413.9655.84
rr_corner85544015.68125.44
rcr_gripper4381527.1628.64
rcr_leg227154282.37164.74
rcr_nut415601.656.6
rcr_long_bolt2881766.1312.26
rcr_short_bolt2841686.1712.34
rcr_rod8796324.9639.68
rcr_clamp_half1413522.9811.92
rcr_clamp_half2413522.9111.64
rcr_camera_holder113213237.6937.69
rcr_camera_cover130308.648.64

Total Print Time: 4,028 min. (67 hours 08 min.)
Total Filament Required: 882 gr.

5. Hardware Shopping List

QuantityItemPrice Per Item (approx.)
4 DS3218 Servo Motor with Horn
$20.00
4 150 mm Servo Extension Lead, Male-to-Female
$1.00
4 Hitec HS-311 Servo Motor
$8.00
1 Raspberry Pi 3 Model B Quad-Core (optional)

This part is optional. The app can be run on a regular Windows 10 PC as well.
$35.00
1 Pololu Mini Maestro 12-Channel USB Servo Controller (Assembled)
$30.00
1 HDE USB 5MB Webcam with 6 LEDs
$8.00
1 6V, 3A (3000 mA) power source, wall-plugged or rechargeable

Our robot uses the SMAKN power supply adapter (shown here), with the round plug replaced by two female connectors to be plugged into the Pololu servo controller. The replacing was done by a competent technician proficient in soldering. Use a wall plug at your own risk. See the Connecting Electronics section below for more information.
$8.00
1 Standard-Size Rubik's Cube

Without this item, the robot is completely useless. We recommend the stickerless, smooth-operation variety. Our color recognition code was only tested with the standard (original) colors shown here. Please do NOT use a speed cube!
$12.00
76 Metric M3-12 Phillips-head Countersunk Bolts $0.06
36 Metric M3 Nuts $0.06
9 Small 2mm Wood screws or Metric M2x8 Molts
These are to attach the HS-311 horns to the servos, and one more to attach the Pololu servo controller to the back side of the camera holder.
$0.06

Total Cost of Hardware (approx.): $200.00.

6. Assembly Instructions

Step 1:

Attach the round horn that comes with the HS-311 servo to pinion with two small 2mm wood screws or two metric M2x8 bolts.


Step 2:

Insert the single-armed horn that comes with the DS3218 servo into gripper. Secure with two metric bolts. Screw in the bolt closer to the center first.


Step 3:

Insert the DS3218 servo into slider. Secure with 4 metric bolts and nuts.


Step 4:

Insert rack into slider, have the servo cable run in the triangular recess in the bottom of the rack. Align holes. Secure with 6 metric bolts.


Step 5:

Insert the HS-311 servo into arm. The servo's shaft must be aligned with the round hole on the other side of the arm. Secure with 4 metric bolts and nuts.


Step 6:

To secure the slider in place, install the pinion onto the HS-311 servo's shaft and secure it with an axis bolt that came with the servo. Note that during the calibration phase the pinion may need to be removed, slider adjusted, and pinion replaced.
Repeat Steps 1 to 6 to assembly three other arms.


Step 7:

Using the 8 corners, assemble the 4 arms into a single unit.


Step 8:

Set the assembly obtained in Step 7 onto the two legs, align holes. Insert the pair of long_bolts in the bottom holes, and short_bolts into the top holes. Secure all 4 bolts with nuts. The heads of the bolts must be on the same side as the HS-311 servos (far side on the picture below), while the nuts on the opposite side (near side on the picture below.)


Step 9:

Screw four rods into the heads of the long and short bolts tightly.


Step 10:

Screw four other rods into the slots of camera_holder tightly.


Step 11:

Position the camera holder in such a way that the ends of the rods attached to it are in close proximity to the ends of the rods attached to the main unit. The slit in the camera holder must point downwards. Using the clamp_halves, connect the 4 pairs of rod ends. Secure the clamp halves with the metric bolts and nuts.


Step 12:

Remove the stand and semi-circular ring from the webcam using a small screwdriver. Insert the webcam into the niche in the camera holder. Run the webcam cable through the slit in the camera holder. Secure the webcam with camera_cover. Plug the webcam into Raspbery PI's USB port. Install the grippers onto the DS3218 servos, secure with axis bolts that came with the servos. Do not tighten the servo horn clamps just yet as the positions of the grippers may need to be adjusted during the calibration phase.


7. Connecting Electronics

Thanks to the Pololu Mini Maestro servo controller, there is absolutely no need for PCBs or breadboarding. You connect the 8 servos to the Maestro, and the Maestro to your PC via a USB cable for calibration (and later to the Raspberry PI for the actual cube solving.)

The servos can be connected to any of the 12 channels of the Mini Maestro arbitrarily. The image below shows the channel assignment used by our robot. A white number in a red circle next to a servo denotes the Maestro channel number for this servo. Even channels are used for the gripper servos, and odd channels for the rack-and-pinion servos. Channels 4 and 5 are skipped for spacing.

For the power supply for the Maestro, you have a choice between a rechargeable 6V battery pack and a modified 6V, 3A (3000 mA) wall charger. The 1st option is safe but servos are power-hungry, and the battery pack drains quickly. Make sure you buy a high-capacity pack.

The 2nd option requires that the charger's standard round connector be removed and replaced, or extended, by two wires ending in the standard female connectors. The work has to be completed by a competent technician proficient at soldering. The charger must be rated at 3A or higher. Our robot is powered by this power supply adapter extended as shown below. Use this option at your own risk.

The servo controller should be attached to the back of the camera holder using a single small wood screw. The image below shows the controller in its working position, with all the servo cables and power wires attached to it. The green and yellow wires in the lower-right corner of the image are power wires.

8. Servo Calibration with Pololu Maestro Control Center

The purpose of the servo calibration is to find two key target settings for each servo's channel. For the gripper servos, the two target signals are for the neutral position and the 90° position. For the rack-and-pinion servos, the two target signals are for the "near" position (hugging the cube) and the "far" position (releasing the cube.) These numbers are determined experimentally using the Maestro Control Center software available on the Pololu web site and installed on your PC or MAC.

After firing up the Maestro Control Center, select the controller from the "Connected to" drop-down box. Go to the Serial Settings tab and select USB Dual Port for the serial mode. Then press Apply Settings.

Then return to the main Status tab to calibrate your servos.

Begin by putting the sliders in the "far" position in which the front of the slider is flush with the arm, and put the grippers in the "neutral" position, as shown on the image below. Write down the "far" target values of the rack-and-pinion servos, and "neutral" target values for the gripper servos.

Next, determine the target value for a 90° rotation for each gripper servo. On the image below, the right arm's gripper servo has been turned 90° relative to its neutral position. Do this for each gripper servo, and write down the target values for all four.

Finally, put the gripper servos back in the neutral position, and insert a Rubik's cube in the bottom gripper. Determine the "near" positions of all four rack-and-pinion servos in which the cube is tightly hugged and centered, as shown on the image below. Write down these target values.

Once acceptable target values for all servos have been determined, they need to be transferred to our application via its own user interface. The values can later be adjusted, if necessary.

Note that during calibration, the gripper and slider positions may need to be adjusted to allow a proper movement range. To adjust the position of a gripper, it needs to be removed from the gripper servo's shaft and then replaced in a different position. Once the final position is found, the servo horn's clamp needs to be tightened with an Allen hex key. To adjust the slider's position, the pinion needs to be removed, the slider moved as necesary, and then the pinion replaced.

For more information on using the Maestro servo controller and its Control Center software, please refer to the Pololu web site.

9. Software Installation and Configuration

9.1 Introduction

The robot is driven by a Universal Windows Platform (UWP) application of our own creation called RubiksCubeRobot. By sending control signals to the robot's 8 servos and webcam, the application photographs the cube, performs the image and color recognition on the photos, determines the initial position of the cube, computes the sequence of rotations necessary to solve the cube, and then executes the sequence. Please download the application via the link below.

9.2 Installation on Raspberry PI

Download Link for Raspberry PI
Filename:RubiksCubeRobot_ARM.zip
Version:1.0.30.0 (Beta)
Size:12.9 MB
Last Updated:2017-09-12
Platform:ARM

The following instructions assume that you have already downloaded and installed Windows 10 IoT Core on your local PC, installed the Windows 10 IoT Core operating system on your Class-10 Micro SD card, booted your Raspberry PI from it, and connected the PI to your local network via WiFi and/or an Ethernet cable. Your Raspberry PI device should be showing in the My devices list of the IoT Dashboard:

To install the RubiksCubeRobot onto your PI, please follow these easy steps:

  • Download the .zip archive for RubiksCubeRobot from the link above. Unzip it to a temporary directory of your PC's hard drive, such as c:\tmp.
  • Select Open in Device Portal from the IoT Dashboard. In the Windows Device Portal, go to Apps, Apps manager.
  • Under Install app, for App package, select the file with the extension .appx in the temporary directory, and for Certificate, select the file with the extension .cer.
  • Click on Add dependency three times. For the three Dependency boxes, select the three files in the \Dependencies\ARM subfolder of the temporary directory.
  • Click on Go under Deploy.

That's it! RubiksCubeRobot should now appear under Apps. You can start the application by choosing "Start" in the Actions drop-down box, and mark it as startup by clicking on the radio button in the Startup column.

9.3 Installation on a Regular Windows 10 PC

Download the x86 or x64 versions from the links below:

Download Links for Windows 10 PC
Filename:RubiksCubeRobot_x86.zip
Version:1.0.30.0 (Beta)
Size:12.8 MB
Last Updated:2017-09-12
Platform:x86

Filename:RubiksCubeRobot_x64.zip
Version:1.0.30.0 (Beta)
Size:12.9 MB
Last Updated:2017-09-12
Platform:x64

Unzip the content of the download to a temporary directory such as "c:\temp". Prior to installing the app on your PC, you need to install the certificate in the Trusted Root Certification Authorities of both the Current User and Local Machine sections of the certificate store. This only needs to be done once.

Double-click on the .cer file in the temporary directory, click Install Certificate, select Current User, then select "Place all certificates in the following store", and select the Trusted Root Certificate Authorities folder. Repeat this procedure but this time select Local Machine instead of Current User.

Once the certificate is installed, double-click on the .appx file in the temporary directory to install the app on your PC.

9.4 Configuring and Running the Application

When you run the appliction for the first time the following screen comes up:

The blue and red buttons of the main page perform the following functions:

  • calibration -- takes you the Calibration Center where the servo target values are entered.
  • configuration -- takes you to the Configuration Center where the parameters responsible for image and color recognition can be viewed, and changed if necessary.
  • training -- performs color training by taking photos of a fully assembled cube.
  • analysis -- performs image and color recognition of the most recent set of photographs stored on the device's hard drive. This function is only used for debugging purposes.
  • key -- allows you to enter your registration key.

  • OPEN -- brings the rack-and-pinion servos to the full-back position and gripper servos to the neutral position so that the cube can be inserted.
  • RUN -- starts the work sequence after the cube has been inserted.
  • STOP -- performs an emergency stop.
  • OFF -- switches all servos off.

The 1st required step is to click the key button and enter your registration key in the form XXXXX-XXXXX. Please contact us to obtain your free 30-day evaluation key. IMPORTANT: The application performs run-time key validation over the Internet, so your Raspberry PI (or PC) must be connected to the Internet for the application to function.

The 2nd required step is to enter all the servo target values in the Calibration Center:

The screenshot above shows the settings for our robot, but you must obtain your own numbers during calibration using the Pololu Maestro Control Center software.

Our image and color recognition algorithm uses a number of parameters to convert the color photographs to dual-tone images for line detection, and to determine the colors of the cube squares. These parameters can be modified in the Configuration Center: If your are running the application on a PC and it has another camera connected to it (laptops almost always do) you need to select the robot's webcam via the Camera Name drop-down box.

The parameter "White if Saturation below" was added in Version 1.0.29.0 to address situations where the white cubies are mistaken for other colors, such as blue, red or orange. The default value of 0 has no effect. If the value is set to a number between 0 and 1, such as 0.2, a cubie is identified as white when its saturation is below 0.2, regardless of the hue. Decrease this parameter or set it to 0 if non-whites are mistaken for whites.

Changing all other parameters manually is generally not recommended. Contact us if the robot consistently reports errors such as ERROR_NOLINESFOUND, ERROR_TOOMANY_MISIDENTS, or similar. We will ask you to enable the debug mode by checking the "Enable Debugging" checkbox, and send us the images and other files created in the \Data\Users\DefaultAccount\Pictures folder of your Raspberry PI (or the This PC\Pictures folder on your PC.)

Before clicking the RUN button, make sure all 8 servos are plugged into the Maestro servo controller, both the Maestro and webcam are plugged into the Raspberry PI's (or your PC's) USB ports, and the power source is connected to the Maestro.

We recommend that the first test run be performed without a Rubik's cube. The robot will perform the necessary manipulations of the arms and grippers, and take 12 photographs that are going to be displayed immediately. If the cube is not inserted, the image processing phase will, understandably, fail. An error will be displayed, and the arms and grippers returned to the open position.

Once the first test run is finished, insert the cube in the grippers and proceed with a live test run. Make sure the cube on the photographs is in focus, and roughly centered. Adjust the camera's focus and direction of the lens, if necessary.

To improve color recognition, the robot can be run in the color training mode to compute color hues reflecting your own unique lighting conditions. Insert a fully assembled cube with the white face facing the camera and red face pointing upwards, and press the train button. The cube will be photographed and new color hues calculated based on those photographs. You will then be asked if you want to save these new hue values. You can always return to the "factory" settings by clicking the Restore Defaults button.

10. Frequently Asked Questions

  • Is Raspberry PI required?
    No, any device with two USB ports can be used (one for the Maestro, the other for the webcam.) The software is currently available for Raspberry PI running Windows 10 IoT, as well as regular Windows 10 PCs.
  • Why was this particular webcam model chosen?
    This webcam was chosen because it produces small photos (640x480) which results in faster processing, is equipped with LED lights, nicely shaped, and inexpensive.
  • Why use a separate servo controller, why not control the servos directly with the Raspberry PI?
    Initially we tried to do just that, but have failed to achieve satisfactory results even with 4 servos. Breadboarding with 8 servos does not seem to be reliable enough. However, we admit it may still be doable.
  • Why does the robot take two pictures per cube face instead of just one?
    The grippers, when engaged, cover a significant portion of the cube's face, which makes it difficult to accurately identify the colors of the side cubies. As a workaround, the robot photographs each face first with the vertical grippers retracted, and then the horizontal ones.
  • Why does the robot make three clockwise 90° turns instead of a single counterclockwise 90° turn?
    Because of a slack between the gripper and cube, it takes a greater-than-90° turn of the gripper to perform a 90° turn of the cube's face. Therefore, a 180° servo such as the one we are using won't do both a 90° and -90° turns with proper precision. 270° servos would probably work better, and future versions of our app may support those.

Related: How to Model a Rack-and-Pinion in Blender