DD: Android Things Rubik’s Cube Solver (3)

I have received the next shipments, which includes a second claw and 2 more servos.

Now that I have 3 non-defective servos (and a 4th one still on transit), I can at least test the concepts of face twist and cube rotation. This is a first step towards manipulating a cube programmatically, and then solve it, but this step has proven to be more complex that anticipated, and for partly unexpected reasons.

One claw face twist

I received the servos first, so the first thing I tried was to have one functional claw perform a face twist while I held the cube. This test worked out quite nicely.

The code for that is actually quite simple:

fun twistFace() {
    claw.turnClockWise()
    Thread.sleep(600)
    claw.release()
    Thread.sleep(800)
    claw.resetRotation()
    Thread.sleep(600)
    claw.grab()
}

Given that setting the servo is an asynchronous operation, I am just having a Thread.sleep to check how long it does take to execute the move. I expect this to be cleaner as I move along.

And then a few days later I received the second claw, so it was time to test the same concept but with 2 claws.

One would thing that cube twists and cube rotations with 2 claws was going to be easy after the previous test.

Well, spoiler alert, I was wrong.

Using two claws

When I assembled the second claw, I noticed that the servos were quite different in terms of configuration. This may happen because they came from different manufacturers, even when they are built on the same spec. In any case I had to tweak the pulse duration individually for each claw to open and close the same way. I was hoping to have the same configuration for each claw, but it is not going to be possible.

After some trial and error, the current configuration for my servos is:

rightClaw = Claw(pca9685, 0, 1)
rightClaw.setGripPulseDurationRange(1.0, 2.5)
leftClaw = Claw(pca9685, 2, 3)
leftClaw.setGripPulseDurationRange(1.0, 2.0)

In the meantime I also created a very simple UI for the NXP iMX7D with 4 buttons to:

  • Reset the claws: putting both claws on the position open and centered on rotation
  • Grab the cube: The claws open and then close, but not fully, just enough to grab the cube
  • Twist: Same move as before, but the other claw is always holding
  • Turn: Same move, except that this time the second claw releases and then grabs it again}

And -as the naive engineer I am- once the opening and closing of both claws was properly configured. I went straight away to try a face twist and this is what happened.

The servos have some “room” and when they release, the reattachment position is different. Not by much, but enough to make the re-grab at the end of the face twist fail.

I did not notice that I was subcounsciously correcting this myself when I was the one holding the cube.

So, to just be able to visualize this problem, I added a new method to the app, one that simply releases and regrabs the cube, first one claw and then the other.

Even this simple test proved that it was going to be trickier than expected.

So, where am I now and what is next?

Still missing one more servo, maybe once I have it properly screwed to the claw the movement gap will be smaller, but as I said on the tweet, I am afraid I’ll need proper brackets.

The physical part of this project is turning out to be the most challenging one so far and I want to think about it, maybe use wood and proper brackets is the solution, but I also want to have some rails to adjust the claw distance…. and no, Lego does not have enough resolution to do that, a Lego dot is too big.

The next goal is to be able to scramble a cube using a few different face moves. Once I get passed the first twist I reckon it will be easy.

I’m also afraid I’ll have to swallow those words.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.