bricKuber: list index out of range

Hello,

I am firing up my BricKuber and it is giving me the same error:

“List index out of range”

The furthest it got was 3 sides before generating this error. I looked through the forum but didn’t see any similar issues reported elsewhere. I suspect it is due to the camera being either misaligned or not entirely focused but I cannot be sure.

Many thanks in advance!

Hello all,

I was able to get all 6 sides to scan. It came down to raising the camera around an inch and adding better lighting.

Now, (to the next error!), after scanning all six sides I get the following error:

SyntaxError: invalid syntax
Using kociemba to compute an efficient solve solution.
Error: Error. Probably cubestring is invalid

I reinstalled the Kociemba for Python 3 on my RP but the error is still there. I’m not sure what else to do. Any help is appreciated. Thanks!

You installed the BrickKuber dependencies with this? sudo bash ~/Dexter/BrickPi3/Projects/BricKuber/install_brickuber.sh

Both of those errors are typically caused by poor lighting conditions and/or camera position. The light can’t be glaring off the cube. Try adjusting the lighting brightness and angle.

Another thing you can do is adjust how the images are pre-processed. These three lines all pre-process the images in different ways. Personally I find the first one (on line 275) to be most reliable for my lighting, camera, and cube. In the file ~/Dexter/BrickPi3/Projects/BricKuber/brickuber_lib.py try commenting/un-commenting different ones to see what works best for you.

If it’s still failing, look at the six .jpg images in the /tmp directory and see if they look good (good consistent lighting, no glare, etc.).

Thanks, Matt! I think I have the lighting dialed-in and can scan all 6 sides. However, when the cubestring is loaded the Kociemba solver errors out as I list above:

SyntaxError: invalid syntax
Using kociemba to compute an efficient solve solution.
Error: Error. Probably cubestring is invalid

I did install all BricKuber dependencies using

sudo bash ~/Dexter/BrickPi3/Projects/BricKuber/install_brickuber.sh

Or are you saying that the images are captured and the colors are being misidentified due to the lighting? I can share the most recent cubestring, if necessary. I’m so close, so I’m eager to figure out what is going wrong!

I think the images are being captured, but the colors are being mis-identified due to lighting and/or the pre-processing. If you think the lighting is good, try changing the settings in brickuber_lib.py as I mentioned above.

It could be helpful to see the cubestring. Can you copy the complete text output from the program, and paste it here?

Thanks again! I’m at work right now (don’t tell my boss I’m on this forum!), but I’ll send it over as soon as I get home.

As an aside, I tried modifying the script last night but was given a fairly lengthy error. What program do you use to open, modify, and save script? Many thanks for your time!

To edit files directly on the RPi from the command line, I use nano. For example, sudo nano ~/Dexter/BrickPi3/Projects/BricKuber/brickuber_lib.py To close and save the changes, hit Ctrl + x (“close”) then y (“yes” save changes) then enter (save with the existing file name).

Okay, here is the most recent attempt:

$ sudo python ~/Dexter/BrickPi3/Projects/BricKuber/BricKuber.py
Taking pictures of each face, and determining cube configuration.
[‘225, 0, 0’, ‘255, 255, 13’, ‘255, 255, 13’, ‘255, 255, 13’, ‘237, 242, 235’, ‘225, 0, 0’, ‘240, 244, 214’, ‘0, 76, 221’, ‘0, 82, 229’]
[‘226, 0, 21’, ‘255, 90, 7’, ‘255, 255, 13’, ‘226, 0, 22’, ‘254, 87, 13’, ‘254, 254, 13’, ‘240, 242, 225’, ‘255, 87, 15’, ‘237, 242, 235’]
[‘250, 26, 0’, ‘2, 254, 0’, ‘225, 0, 0’, ‘225, 0, 0’, ‘255, 255, 12’, ‘225, 0, 0’, ‘0, 72, 214’, ‘18, 251, 0’, ‘26, 247, 0’]
[‘255, 39, 0’, ‘0, 72, 228’, ‘0, 74, 236’, ‘0, 71, 216’, ‘0, 250, 0’, ‘3, 254, 0’, ‘0, 201, 0’, ‘255, 255, 12’, ‘255, 40, 0’]
[‘240, 241, 232’, ‘237, 242, 234’, ‘255, 93, 0’, ‘240, 243, 218’, ‘225, 0, 0’, ‘255, 92, 0’, ‘255, 255, 13’, ‘255, 41, 0’, ‘0, 251, 0’]
[‘225, 0, 0’, ‘237, 242, 235’, ‘255, 255, 12’, ‘240, 243, 219’, ‘0, 76, 218’, ‘0, 79, 227’, ‘0, 74, 213’, ‘0, 219, 0’, ‘0, 255, 0’]
rubiks-color-resolver.py --rgb ‘{“1”: [225, 0, 0], “2”: [255, 255, 13], “3”: [255, 255, 13], “4”: [255, 255, 13], “5”: [237, 242, 235], “6”: [225, 0, 0], “7”: [240, 244, 214], “8”: [0, 76, 221], “9”: [0, 82, 229], “10”: [255, 255, 12], “11”: [0, 79, 227], “12”: [0, 255, 0], “13”: [237, 242, 235], “14”: [0, 76, 218], “15”: [0, 219, 0], “16”: [225, 0, 0], “17”: [240, 243, 219], “18”: [0, 74, 213], “19”: [226, 0, 21], “20”: [255, 90, 7], “21”: [255, 255, 13], “22”: [226, 0, 22], “23”: [254, 87, 13], “24”: [254, 254, 13], “25”: [240, 242, 225], “26”: [255, 87, 15], “27”: [237, 242, 235], “28”: [255, 40, 0], “29”: [255, 255, 12], “30”: [0, 201, 0], “31”: [3, 254, 0], “32”: [0, 250, 0], “33”: [0, 71, 216], “34”: [0, 74, 236], “35”: [0, 72, 228], “36”: [255, 39, 0], “37”: [255, 93, 0], “38”: [255, 92, 0], “39”: [0, 251, 0], “40”: [237, 242, 234], “41”: [225, 0, 0], “42”: [255, 41, 0], “43”: [240, 241, 232], “44”: [240, 243, 218], “45”: [255, 255, 13], “46”: [250, 26, 0], “47”: [2, 254, 0], “48”: [225, 0, 0], “49”: [225, 0, 0], “50”: [255, 255, 12], “51”: [225, 0, 0], “52”: [0, 72, 214], “53”: [18, 251, 0], “54”: [26, 247, 0]}’
SyntaxError: invalid syntax
Using kociemba to compute an efficient solve solution.
Error: Error. Probably cubestring is invalid

Also, and probably not related, but due to the short length of the suggested RP camera’s ribbon cord I had to mount and rotate the camera as shown in the attached picture. Does this orientation matter as I am “spinning” the ribbon cord to accommodate the postion of my RP. Picture attached.

IMG_4858

edit: tried and flipped configuration and same error.

Just a quick update on my current status:

(1) Replaced camera cable with longer 24cm version to avoid rotation of image.
(2) Purchased different rubiks cube with better contrast between red/orange and that didn’t have a logo on a white square.
(3) Reflashed raspberrian and reinstalled all dependencies as discussed above.

Unfortunately, despite the changes above I am still facing the same error after reading all 6 sides.

I’ll leave this thread open for another day or so and then I’m going to move onto the next robot. Sort of a disappointing first project but I’m optimistic that the troubleshooting I have learned on this project will hopefully aid me in future builds.

Any input from the community or past (successful) BricKuber builders is greatly appreciated.

Cheers!

Have you looked at the six .jpg images in the /tmp directory to see if they look good? They should have consistent lighting and no glare.

Have you tried changing the pre-processing of the images as I described?

Hey Matt,

I did and your recommendation definitely was helpful. The first of the three post processing codes was successful much more often.

I also did review my pictures in the temp folder along with accessing the camera directly in the terminal to get everything focused. I now can scan all six sides repeatedly will very little variation in the rgb codes. I honestly just think It’s some coding issue.

I’m on a RP 3+ and so I’m not sure if that could be somehow related to these issues.

Thanks again for all your feedback.

Did you solve all your issues with this?

I just purchased the BrickPi3 and intend to build and code this with my son.

Aside from the Pi Camera is are any other parts required other than the home EV3 Lego Kit?