AndreaFavero71 / cubotino

Updated scripts and files for CUBOTino autonomous: A small, 3D printed, Rubik’s cube solver robot
Creative Commons Attribution 4.0 International
47 stars 16 forks source link

Handle case when cube is already solved #13

Closed rbuehlma closed 10 months ago

rbuehlma commented 10 months ago

The application crashed for me if the cube was already solved. This is a fix for this issue.

AndreaFavero71 commented 10 months ago

Hi, thank you for spotting the error. I've clearly spoiled the "already solved" cube status, that was correctly managed so far; The error has been introduced with the latest release, by adding a little improvement at Cubotino_T_servos.py. To keep consistency with the logic used so far, the issue get better solved by changing Cubotino_T_servos.py:

from (row 1087):

    if moves[0] == 'S':                        # case the first move requires a cube spin
        flip_to_open()                         # Top_cover is set to open position
    elif moves[0] == 'R':                      # case the first move requires a cube layer rotation
        flip_to_close()                        # Top_cover is set to close position

to:

    if len(moves)>0:                               # case moves > 0 (there are moves)
        if moves[0] == 'S':                        # case the first move requires a cube spin
            flip_to_open()                         # Top_cover is set to open position
        elif moves[0] == 'R':                      # case the first move requires a cube layer rotation
            flip_to_close()                        # Top_cover is set to close position

I'm going to close this kind merge request from you, and upload the above change. Right after I'll start studying on the info you've shared via Instructables message, quite intriguing Regards, Andrea