Rubik's cube Robot solver

Your Robot solver is very nice

Thanks ;)

I am doing same project and i really wonder how to connect Arduino to Cube Explorer . Please detail me about this

As mentioned I use a middleware to connect Arduino to Cube Explorer

This Python script does the following tasks: 1) Launch Cube Explorer 2) ask Arduino to move the cube, face by face, for color recognition by Cube Explorer 3) request and obtain the solution from Cube Explorer 4) transfer this solution to Arduino

Points 2) and 3), please refer to response #24 for technical details The code is still in the debugging stage

For point 4) see response #21 This code is 100% working

Part list for 5mm thickness material (plywood, acrylic, cardboard)

tml) - 14mm [brass standoff spacers](http://www.ebay.com/itm/10x-Brass-Standoff-Spacer-M3-Female-x-M3-Female-

14mm-/250955120249?hash=item3a6e173e79)

For Imperial people, just use 1/8" hardware

Hey kas! Any updates on the python code?

Before building the robot solver, make sure you use the test bench as described in reply #6, together with the test code

#define    CLOSE                85                  // servo's limits
#define    OPEN                132
#define    CW                    0
#define    MID                  87
#define    CCW                 171

You need to carefully adjust those servo’s limits to obtain clean moves as per attached video
Gripper should close tight enough to turn the cube and open enough not to touch the cube edges when rotating
Also grippers rotation should be adjusted to obtain exact O°, 90° and 180° moves

Nylock nuts should be very slightly tightened, to avoid any friction

Directly building the bot is the best recipe for preparing scrambled eggs :wink:

Please show us your work in progress
Photos/videos are welcome

The complete sketch, including cube.cpp and cube.h is attached to this message
Make sure to also download the VarSpeedServo library

I will post the final python code within a few days

EDIT
V1.3 is now available (Maker Faire 2017 release) see Post #318

CubeMover12.zip (3.98 KB)

Any update Kas??

Any update Kas??

Hi dd5665, care to share your project, as built so far ??

This is RubikKasBot.py V1.3

## Rubik kasBot             @ kas 2014/2017

## This script will:
##  launch Cube Explorer
##  move the cube, face by face, for color recognition by Cube Explorer ([Scan colors] button)
##  request and obtain the solution from Cube Explorer
##  transfer this solution to Arduino ([Solve cube] button)

## V1.3    communication with Cube Explorer (Web server)
## V1.13  changed windows position
## V1.11  slow/fast cube moves
## V1.1    communication error management
## V1.0    initial release, serial communication with Arduino only

from tkinter import *
import urllib.request
import serial, time
from serial import SerialException
import atexit
import subprocess

##  Settings
## webcam setUp: white balance 6253°K (manual), Exposition: -6 (manual) >> -9

defaultPortNumber = '3'                     ##  default Serial port
cubeExplorerPath = 'C:\\Program Files\\Cube Explorer\\cube512htm.exe' ## Cube Explorer program path
cubeExplorer = 'http://127.0.0.1:8081/'     ## Cube Explorer web server address
webCamConnect = '?connect1'                 ##  connects to 2nd device in Cube Explorer device drop down
delayB4scan = 1                             ##  delay before scanning 
....
....

** Please download attached file to get full code **
** Rename RubikKasBot_13posted.txt  >>  RubikKasBot_13posted.py **

Before running this code, please make sure that you can establish communication and drive your bot using V1.2 V1.13 code (see response #21)

Enjoy :wink:

RubikKasBot_13posted.txt (10.1 KB)

Hi Kas,

I just found this forum and I was thinking of doing something similar. Did you put some thought about having Arduino computing the solution, instead of going on line and importing it ? I'm quite familiar with some speed cubing algorithms. In theory, from any state of the cube, you can get to the solution in less than 20 moves (God's number). The Fridrich method that should be quite easy to program will average 60 moves. The Petrus method that I think is more difficult to program will average probably 40 moves. Granted, this won't be as fast as getting the solution on-line with cube solver, but the whole idea is to have Arduino do the whole thing, capture cube state, compute solution and solve cube. My take is an Arduino Due should be sufficient to do it. (enough RAM/ROM/IOs).

What do you think ?

Hi Slowowl

I am not too familiar with solving algorithms as such, for this project the main challenge is the hardware (robot) construction.

My take is an Arduino Due should be sufficient to do it. (enough RAM/ROM/IOs)

The MCU should also accept video signal for color recognition, not sure Arduino Due would fill the bill ::) Raspberry Pi or even an Android phone would probably be better candidates for this task.

I would love to test a pure Arduino solving solution if you develop one ;) - input 54 facelets colors: 0, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 4, 1, 1, 3, 5, 5, 3, 3, 1, 1, 1, 2, 2, 1, 2, 2, 5, 2, 1, 1, 4, 4, 1, 2, 2, 2, 3, 3, 0, 3, 3, 0, 4, 2, 3, 0, 0, 3, 0, 0, 5, 0, 0 - output solution (Singmaster notation): FUFD'

BTW Cube Solver does not get on-line, solution is computed on local PC and sent to Arduino via USB

Let us know

Hi Kas,

For the Video, I've been playing with the OV7670+Fifo, it is quite easy to interface with a Due. You can check my video at https://www.youtube.com/watch?v=zgiL_f0HxRc.

For the servo control, I got a servo board for 6 DOF robot arm, both off the shelf, it is controlled through UART.

I try to use a the robot arm to move the cube from 2 cube clamp that are at a 90 degree angle. Each clamp can be rotated with a stepper motor, the DOF clamp holding the top layer at fixed position while the 2 bottom layers are rotating.

It turns out the DOF arm I had is not accurate enough, especially when moving the cube from 1 clamp to the other 1.

I think your method is simpler, I think I could reuse my servo board, but I will have to build your robot myself (which I'm not very good at. For me programming is easier).

I'm not too familiar with Rasberry Pi neither with interfacing with an Android phone.

I'm more an Arduino purist (everything Arduino). If Arduiino DUE is not sufficient, we can always go to Gallileo... ;)

I will look into building your robot controlled by Arduino, with video capture from Arduino and Arduino computing the (non-optimum) solution, probably using the Fridrich method (average 60 moves).

BTW which cube did you use ?

I think the standard size is 54mm. But there are smaller ones.

Also Speed Cuber are using special cube that are more forgiving for face misalignment, meaning that if a face is not totally aligned, you can still rotate a perpendicular face without 'LOckiNG' the cube, and the cube realign itself.

For such cubes I would look into the 'DALIANG ZANCHI' or mini-ZANCHI (for smaller cube), you can get it on ebay, but also there is a good vendor in the US (www.lubix.com).

small correction US vendor for SPeed cubers is www.lubixcube.com (lubricated cube, forgive face misalignment).

For the Video, I've been playing with the OV7670+Fifo, it is quite easy to interface with a Due. You can check my video at https://www.youtube.com/watch?v=zgiL_f0HxRc.

Impressive :o Make sure that the OV7670 is smart enough to differenciate Orange and Red colors

BTW which cube did you use ?

I use a Dayan GuHong (57 mm) not lubricated, very smooth, easy corner cutting I ordered from Amazon, to get fast delivery, got it shipped from China (3 weeks :smiling_imp: )

The DaYan ZhanChi is also very good, do not use the not so smooth genuine Rubik's Cube(tm) The reference site in China for cubes: http://lightake.com/c/DaYan_001001005

I am currently working on a project...a rubik cube solver. I am building this using legos and arduino. I am using 8 servos(4.8-6v) for the project. My idea is to use a 9v battery for the arduino and a seperate power supply for the servos and sensors i am going to use.I do not understand what type of power supply would be better to use to control 8 servos. A Ni-mh battery pack or power supply? I dont really understand...what do you suggest ? Please help Thank you

Hi rjplant,

First let me describe my setup For convenience, I use two Lithium phosphate batteries (6.4V, 1500mA) to power both Arduino and servo's

LiFePO4 batteries have a very constant discharge voltage. Voltage stays close to 3.2V during discharge until the battery is exhausted. Thoses batteries also have a high burst discharge rate (15C -> 22A) I first used this battery chemistry for my GPS Logger project

Connecting both Arduino and servo's to the same power supply is not strickly kasher, but it works flawlessly. In this project there is four servo's, but during any move, only one servo is actually powered.

I also replaced battery holder wires with thicker ones to reduce voltage drop:

Now, for your project with 8 servo's :o , how many will spin at the same time ?? You may have to use a separate supply for the Arduino, to avoid possible CPU resets Can you describe your setup and/or post a photo ??

Thank you for the reply kas.
I will use a separate power supply for the arduino. I am planning to use power supply for the servos. I have converted the power supply I have into a dc power supply(image 3).
4 motors(maximum) will be spinning at the same time
below are the images of my setup.
I have employed 4 claws(4 servos) and each claw has a servo which brings it backwards when the claw is finished turning the cube.
as 4 servos will be spinning at same time how much voltage does my power supply be able to supply?

thank you

as 4 servos will be spinning at same time how much voltage does my power supply be able to supply?

:o :o :o Even with 10 servo's, 5 Volts will be enough, you just will need more amp's ;)

Typical stall current for a standard servo is 1 Amp So with 4 servo's spinning at the same time, you will be definitely safe with a 5Volt/5Amp power supply

Do not forget to connect Arduino's and servo's grounds

Also make sure that the Cube can't jam the system if misplaced a servo may stall and fry it in a couple of seconds You can detect servo stall by monitoring Amp's with a 0.5 ohm shunt resistor or a dedicated sensor

BTW, nice setup Out of curiosity, how do you perform color recognition ??

My software friend is working on a mobile application for the color recognition part. the output of the power supply i am using is +5@15A, +3.3V@15A, +12V@20A,...so the 5v connection would be enough right? and i read on the internet that its not possible to control 8 servos without using a servo shield, and its not safe to connect the power supply directly to the servos, is it true?

thank you

the output of the power supply i am using is +5@15A, +3.3V@15A, +12V@20A,...so the 5v connection would be enough right?

Right

i read on the internet that its not possible to control 8 servos without using a servo shield, and its not safe to connect the power supply directly to the servos, is it true?

Please send me a link to these statements The standard Servo library allows for up to 12 servo's Each servo consumes one digital pin, no need for a servo shield

A servo shield is useful to spare digital pins, as it is connected via I2C and requires only 2 pins It also saves Arduino processing overhead.

Hey kas! I am new to python. I am unable to execute the python code you provided. How do I install the tkinter, serial etc modules...can you give a step by step tutorial.

I'll be uploading my bot's pictures and videos in a few days.

Hey kas! I am new to python. I am unable to execute the python code you provided. How do I install the tkinter, serial etc modules...can you give a step by step tutorial.

What is your Operating System ?? What did you install ?? can you launch IDLE ide ?? Any error message ?? More info please

Hey kas, I couldn't find the link. I spoke to my instructor at school and he said the exact same thing you mentioned in ur previous post. Thank you for the help and again I need to connect a emergency stop button...When I press it... everything should stop....how am I supposed wire it? Should I wire it across the main power supply connection?