Comments (64)
So the first one
AssertionError: black_border_width 94, median_square_width 39
basically this is a scanning error that will likely go away if you try it again. Various lighting conditions can lead to this...things like glare on the cube from a bright light, or if it is too dark, etc. Long term I should really move to using machine learning to locate the cube in the picture I just haven't gotten around to it.
This one is more mysterious
File "/usr/local/bin/rubiks-cube-tracker.py", line 56, in
rimg.analyze_file(args.filename)
File "/usr/local/lib/python3.7/dist-packages/rubikscubetracker/init.py", line 1685, in analyze_file
return self.analyze(webcam=False, cube_size=cube_size)
File "/usr/local/lib/python3.7/dist-packages/rubikscubetracker/init.py", line 1531, in analyze
self.get_black_border_width(webcam)
AttributeError: 'RubiksImage' object has no attribute 'get_black_border_width'
Because that method is there in the latest code:
https://github.com/dwalton76/rubiks-cube-tracker/blob/master/rubikscubetracker/__init__.py#L1099
so maybe you have an older version installed? I would remove the current install and re-install like so:
sudo rm -rf /usr/local/lib/python3.7/dist-packages/rubikscubetracker/
sudo rm /usr/local/bin/rubiks-cube-tracker.py
sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
from rubiks-cube-tracker.
Hi Daniel, thanks for the response. I noticed when I first built the robot (Jan 2019) that the amount and type of light (daylight or artificial) had an enormous effect on whether the software resolved the faces and hence found a solution.
The mystery is that between one boot yesterday and the next boot today the method disappeared. Maybe when I loaded the code into Geany today to print it I inadvertently removed that part. Who knows?
I followed your recommendation for reinstalling but now the /usr/local/bin/rubiks-cube-tracker.py is missing. Is that installed from a different .git?
Thanks again.
Chris (aka Cpt Dangerous)
from rubiks-cube-tracker.
later:
In fact /usr/local/lib/python3.7/dist-packages/rubikscubetracker/ failed to install! rubiksresolver/ is there.
even later:
OK, problem solved, I had to add --upgrade to the pip install to get the latest version (3.0.0) which seemed to be already know about:
Successfully built rubikscubetracker
Installing collected packages: rubikscubetracker
Found existing installation: rubikscubetracker 3.0.0
Uninstalling rubikscubetracker-3.0.0:
Successfully uninstalled rubikscubetracker-3.0.0
Successfully installed rubikscubetracker-3.0.0
Thanks again.
Now I need to experiment with the lighting...
from rubiks-cube-tracker.
I can't get beyond:
Failed in processing image: 2022-10-05 10:37:35,298 init.py INFO: Analyze /tmp/BricKuber_top_face.jpg
The image it's trying to analyze is:
Focus doesn't seem too great. I'm using a brand new Raspberry Pi camera V2 having managed to brick my old V1.3 somehow!
I wondered if it might help the processing if I put a matt black card below the cube table so there aren't any
extraneous objects to filter out?
from rubiks-cube-tracker.
I wondered if it might help the processing if I put a matt black card below the cube table so there aren't any extraneous objects to filter out
that sounds like a good next step. Especially the part on the right side where you can see the motor...I wonder if that is confusing it somehow.
from rubiks-cube-tracker.
OK, black card arrived this afternoon. Cut a sheet to cover the main part of the camera view so the image looked like:
but still got the error message:
Failed in processing image: 2022-10-07 16:16:54,547 __init__.py INFO: Analyze /tmp/BricKuber_top_face.jpg
Where to go from here ...?
from rubiks-cube-tracker.
If you can upload the images in /tmp/
here to this github issue I should be able to reproduce it and figure out what is going on.
from rubiks-cube-tracker.
That is the image from /tmp/
Are you not able to download it?
from rubiks-cube-tracker.
ah, I wasn't sure if that was the original or not. Will give it a try
from rubiks-cube-tracker.
Yes, I pulled the image straight out of /tmp for the post. Good luck.
from rubiks-cube-tracker.
@CptDangerous I have good news and bad news...the good news is I am able to process your image with the latest and greatest rubikscubetracker code. The bad news is that means you somehow have an older copy installed that you are using which fails to process the image above. Run the following to find and delete any copies you have installed
sudo find /usr -name rubikscubetracker | xargs rm -rf
sudo find /usr -name rubiks-cube-tracker.py | xargs rm -rf
Then run sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
to re-install it. Logout, log back in and then run
rubiks-cube-tracker.py --filename cube.jpg
where cube.jpg
is the pic above. You should see this
$ rubiks-cube-tracker.py --filename cube.jpg
2022-10-07 20:21:42,862 __init__.py INFO: Analyze cube.jpg
{"1": [239, 122, 75], "2": [253, 247, 253], "3": [254, 254, 252], "4": [237, 119, 70], "5": [35, 82, 182], "6": [253, 253, 127], "7": [235, 113, 69], "8": [39, 81, 179], "9": [253, 174, 115]}
$
from rubiks-cube-tracker.
PS
If you want to see some debug images as to what the code is doing when it processes the image run rubiks-cube-tracker.py --filename cube.jpg --debug
from rubiks-cube-tracker.
I hope you don't mind me contradicting you but I consider that to be all good news. I had come to the conclusion that there had to be something wrong with the installation of the software. It didn't go smoothly - I had a nightmare getting the right version of numpy that would satisfy all the dependancies so I was kind of expecting repercussions further down the line.
My wife and I have to go out and do a paper round for the local village shop where the owner has recently had a heart attack - not us reliving our misspent youths! I'll give your suggestions a try later this morning.
Many thanks for your attention to this.
Cheers
Chris
from rubiks-cube-tracker.
OK, so here's a really strange thing. Running rubiks-cube-tracker.py --filename /tmp/BricKuber_top_face.jpg gets:
2022-10-08 10:50:40,495 __init__.py INFO: Analyze /tmp/BricKuber_top_face.jpg
{"1": [236, 200, 41], "2": [251, 110, 58], "3": [242, 215, 202], "4": [220, 9, 43]}
(results are slightly different 'cos I had to run BricKuber.py again to get a new image of the same face)
However, running BricKuber.py and starting at the same face gets:
Taking pictures of each face, and determining cube configuration.
START: Read Face Colors: top
Picture taken
Failed in processing image: 2022-10-08 10:52:22,616 __init__.py INFO: Analyze /tmp/BricKuber_top_face.jpg
So, I'm inclined to think that something is wrong further up the food chain. I'm tempted to ditch the installation and start from scratch ... again. As I mentioned I had problems earlier installing numpy so that the version satisfied all dependencies.
Following your instructions above didn't go smoothly. The "sudo find/rm" sequence failed with 'Permission denied' despite the ownership being pi:pi
sudo find /usr -name rubiks-cube-tracker.py | xargs rm -rf
rm: cannot remove '/usr/local/bin/rubiks-cube-tracker.py': Permission denied
However:
ls -l /usr/local/bin/rubiks-cube-tracker.py
-rwxr-xr-x 1 pi pi 3056 Oct 8 10:30 /usr/local/bin/rubiks-cube-tracker.py
Once I'd removed the offending file(s) as root I still had to use --upgrade on the pip install command:
sudo pip install --upgrade git+https://github.com/dwalton76/rubiks-cube-tracker.git
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/dwalton76/rubiks-cube-tracker.git
Cloning https://github.com/dwalton76/rubiks-cube-tracker.git to /tmp/pip-req-build-8c_o3qhv
Installing build dependencies ... done
Requirement already satisfied, skipping upgrade: opencv-python>=4.5 in /usr/local/lib/python3.7/dist-packages (from rubikscubetracker==3.0.0) (4.6.0.66)
Requirement already satisfied, skipping upgrade: numpy>=1.14.5; python_version >= "3.7" in /usr/local/lib/python3.7/dist-packages (from opencv-python>=4.5->rubikscubetracker==3.0.0) (1.21.6)
Building wheels for collected packages: rubikscubetracker
Running setup.py bdist_wheel for rubikscubetracker ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-ypjkuaxo/wheels/83/ef/54/764e78cffe69f137e6be3f317be5164c4dedf8f39d83e02504
Successfully built rubikscubetracker
Installing collected packages: rubikscubetracker
Successfully installed rubikscubetracker-3.0.0
Otherwise I got:
sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/dwalton76/rubiks-cube-tracker.git
Cloning https://github.com/dwalton76/rubiks-cube-tracker.git to /tmp/pip-req-build-e93lhhq6
Installing build dependencies ... done
Requirement already satisfied (use --upgrade to upgrade): rubikscubetracker==3.0.0 from git+https://github.com/dwalton76/rubiks-cube-tracker.git in /usr/local/lib/python3.7/dist-packages
etc...
It feels to me like there is a basic problem with the installation which may require a fresh start rather than trying to track down the culprit. What say you?
BTW do you work late into the night or are you in a different time zone from me (BST)?
from rubiks-cube-tracker.
I can reproduce the same output from rubiks-cube-tracker.py as you by resurrecting the original BricKuber_top_face.jpg from this thread.
from rubiks-cube-tracker.
ok the fact that you have to do --upgrade
means it didn't get removed beforehand. It sounds like the pi user does not have sudo permissions but you do have root access though so do this to remove the old installation
# login as root
su
# delete the old install
find /usr -name rubikscubetracker | xargs rm -rf
find /usr -name rubiks-cube-tracker.py | xargs rm -rf
# then make 100% sure they are gone
find /usr -name rubikscubetracker
find /usr -name rubiks-cube-tracker.py
# logout as root
exit
After that does sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
work?
from rubiks-cube-tracker.
BTW do you work late into the night or are you in a different time zone from me (BST)?
I was just up late last night...I am on EST (southeast US)
from rubiks-cube-tracker.
'fraid not!
...
Requirement already satisfied (use --upgrade to upgrade): rubikscubetracker==3.0.0 from git+https://github.com/dwalton76/rubiks-cube-tracker.git in /usr/local/lib/python3.7/dist-packages
...
from rubiks-cube-tracker.
pi is a member of group su
sudo:x:27:pi in /etc/group
I wondered if there was something odd about the ownership & permissions on /usr/local/bin but:
root@BricKuber:~# ls -ld /usr
drwxr-xr-x 11 root root 4096 Sep 22 03:13 /usr
root@BricKuber:~# ls -ld /usr/local
drwxr-xr-x 10 root root 4096 Sep 22 03:05 /usr/local
root@BricKuber:~# ls -ld /usr/local/bin
drwxr-xr-x 3 root root 4096 Oct 8 14:03 /usr/local/bin
root@BricKuber:~# ls -l /usr/local/bin
total 72
-rwxr-xr-x 1 pi pi 219 Sep 28 22:50 f2py
-rwxr-xr-x 1 pi pi 219 Sep 28 22:50 f2py3
-rwxr-xr-x 1 pi pi 219 Sep 28 22:50 f2py3.7
-rwxr-xr-x 1 pi pi 344 Sep 30 12:06 fileswith
-rwxr-xr-x 1 pi pi 218 Sep 28 20:12 futurize
-rwxr-xr-x 1 pi pi 32780 Sep 28 20:03 gpio
-rwxr-xr-x 1 pi pi 223 Sep 28 20:12 kociemba
-rwxr-xr-x 1 pi pi 220 Sep 28 20:12 pasteurize
drwxr-xr-x 2 pi pi 4096 Oct 8 10:49 __pycache__
-rwxrwxrwx 1 pi pi 263 Sep 28 20:12 rubiks-color-resolver.py
looks OK to me.
In the words of an old Carson Robison talking blues:
"There's something cockeyed somewhere."
from rubiks-cube-tracker.
Can you post the output from these commands (you will need to be root or use sudo for the second one)
pip --version
ls /usr/local/lib/python3.7/dist-packages | grep rubiks
Also regarding the red X in your comment above, you can use ``` to start and end a block of pre-formatted text (I edited your comment above to add those).
from rubiks-cube-tracker.
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
rubikscolorresolver
rubikscolorresolver-1.0.0.dist-info
rubikscubetracker-3.0.0.dist-info
from rubiks-cube-tracker.
ok pip looks good.
ah I did not think about the dist-info directory, that is what is causing the confusion. As root do rm -rf /usr/local/lib/python3.7/dist-packages/rubikscubetracker-3.0.0.dist-info
and then install via sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
from rubiks-cube-tracker.
I was fascinated to see the various stages of analysis of the cube face output by rubiks-cube-tracker.py
OK, appeared to work:
pi@BricKuber:~ $ sudo pip install git+https://github.com/dwalton76/rubiks-cube-tracker.git
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/dwalton76/rubiks-cube-tracker.git
Cloning https://github.com/dwalton76/rubiks-cube-tracker.git to /tmp/pip-req-build-qis__76o
Installing build dependencies ... done
Requirement already satisfied: opencv-python>=4.5 in /usr/local/lib/python3.7/dist-packages (from rubikscubetracker==3.0.0) (4.6.0.66)
Requirement already satisfied: numpy>=1.14.5; python_version >= "3.7" in /usr/local/lib/python3.7/dist-packages (from opencv-python>=4.5->rubikscubetracker==3.0.0) (1.21.6)
Building wheels for collected packages: rubikscubetracker
Running setup.py bdist_wheel for rubikscubetracker ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-95r79jt8/wheels/83/ef/54/764e78cffe69f137e6be3f317be5164c4dedf8f39d83e02504
Successfully built rubikscubetracker
Installing collected packages: rubikscubetracker
Successfully installed rubikscubetracker-3.0.0
from rubiks-cube-tracker.
... but:
Taking pictures of each face, and determining cube configuration.
START: Read Face Colors: top
Picture taken
Failed in processing image: 2022-10-08 14:52:53,531 __init__.py INFO: Analyze /tmp/BricKuber_top_face.jpg
from rubiks-cube-tracker.
can you post the /tmp/BricKuber_top_face.jpg
that failed
from rubiks-cube-tracker.
It's the same as the one I posted above but a new scan:
I have to drop this for today. We are about to go out for the evening. Thanks for your help.
from rubiks-cube-tracker.
That one works fine for me
$ ./usr/bin/rubiks-cube-tracker.py --filename cube3.jpg
2022-10-08 12:16:14,872 __init__.py INFO: Analyze cube3.jpg
{"1": [234, 126, 92], "2": [253, 246, 253], "3": [253, 254, 252], "4": [232, 123, 89], "5": [34, 87, 189], "6": [253, 252, 159], "7": [230, 118, 87], "8": [37, 85, 185], "9": [253, 172, 131]}
$
This output though:
Taking pictures of each face, and determining cube configuration.
START: Read Face Colors: top
Picture taken
Failed in processing image: 2022-10-08 14:52:53,531 __init__.py INFO: Analyze /tmp/BricKuber_top_face
That isn't coming from the rubikscubetracker code. Can you point me to the code you are running that is using rubikscubetracker?
from rubiks-cube-tracker.
oh I see that is coming from
https://github.com/DexterInd/BrickPi3/blob/master/Projects/BricKuber/brickuber_lib.py#L284-L291
The line that does if raw_result.stderr == '':
that needs to be if raw_result.exit_code == 0
from rubiks-cube-tracker.
Good morning.
Thanks for the suggestion. Changing:
if raw_result.stderr == '':
to:
if raw_result.exit_code == 0:
gets me:
Picture taken
Error: 'CompletedProcess' object has no attribute 'exit_code'
However:
if raw_result.returncode == 0:
gets a little further but falls over with:
Picture taken
Error: list index out of range
which is a familiar error message from the previous incarnation of this project. This is generated further down the line at:
raw_result = raw_result.split("\n{")[1]
which is Dexter's code.
Once again many thanks for all your help. It looks like I need to post something on the DexterIndustries forum.
Later:
I commented out the line above and the program continued taking photos of each face until:
['rubiks-color-resolver.py', '--rgb', '\'{"1": [49, 123, 46], "2": [253, 242, 251], "3": [84, 170, 68], "4": [235, 120, 78], "5": [217, 54, 68], "6": [254, 255, 253], "7": [237, 216, 98], "8": [213, 51, 66], "9": [231, 67, 88], "10": [88, 177, 85], "11": [253, 255, 252], "12": [235, 80, 110], "13": [253, 248, 253], "14": [222, 61, 81], "15": [218, 61, 82], "16": [48, 135, 64], "17": [240, 136, 98], "18": [241, 224, 121], "19": [45, 117, 52], "20": [51, 140, 62], "21": [253, 243, 151], "22": [183, 35, 47], "23": [54, 146, 67], "24": [253, 247, 152], "25": [172, 29, 38], "26": [252, 241, 253], "27": [253, 245, 154], "28": [253, 145, 74], "29": [23, 76, 154], "30": [11, 57, 129], "31": [253, 152, 81], "32": [253, 123, 59], "33": [205, 6, 34], "34": [127, 194, 45], "35": [253, 240, 56], "36": [251, 232, 217], "37": [253, 254, 252], "38": [253, 253, 168], "39": [253, 175, 137], "40": [253, 247, 253], "41": [35, 88, 192], "42": [41, 89, 191], "43": [234, 127, 96], "44": [232, 125, 95], "45": [230, 120, 92], "46": [102, 152, 19], "47": [253, 79, 53], "48": [253, 90, 65], "49": [253, 223, 30], "50": [253, 87, 52], "51": [40, 91, 161], "52": [253, 230, 205], "53": [241, 0, 44], "54": [46, 95, 169]}\'']
Traceback (most recent call last):
File "/usr/local/bin/rubiks-color-resolver.py", line 12, in <module>
resolve_colors(sys.argv)
File "/usr/local/lib/python3.7/dist-packages/rubikscolorresolver/solver.py", line 1042, in resolve_colors
for key, value in scan_data.items():
AttributeError: 'str' object has no attribute 'items'
Error: name 'std_err' is not defined
I seem to have the latest version of rubiks-color-resolver (1.0.0).
from rubiks-cube-tracker.
Change that to
if True:
For now to get you going
from rubiks-cube-tracker.
Good morning, BSG (British Standard Grey) day here in southern England.
Some progress in as much as the software takes a photo of each face and prints the result of the .split() function for each face.
Then the following error occurs:
Traceback (most recent call last):
File "/usr/local/bin/rubiks-color-resolver.py", line 12, in <module>
resolve_colors(sys.argv)
File "/usr/local/lib/python3.7/dist-packages/rubikscolorresolver/solver.py", line 1042, in resolve_colors
for key, value in scan_data.items():
AttributeError: 'str' object has no attribute 'items'
Error: name 'std_err' is not defined
I have what I think is the latest version (1.0.0) of rubiks-color-resolver. Just to be sure I removed all trace of it and re-installed with pip and that was successful.
Here is a sample of what the debug print for a face looks like:
START: Read Face Colors: left
Picture taken
['220, 58, 79', '242, 75, 103', '61, 133, 230', '66, 171, 77', '253, 254, 167', '77, 150, 240', '253, 253, 253', '102, 195, 99', '81, 150, 239']
Vals['220', '58', '79']
Vals['242', '75', '103']
Vals['61', '133', '230']
Vals['66', '171', '77']
Vals['253', '254', '167']
Vals['77', '150', '240']
Vals['253', '253', '253']
Vals['102', '195', '99']
Vals['81', '150', '239']
END: Read Face Colors
Then there is a long string which occurs once at the end of the face reading:
['rubiks-color-resolver.py', '--rgb', '\'{"1": [221, 56, 74], "2": [241, 70, 95], "3": [60, 129, 226], "4": [68, 169, 66], "5": [253, 254, 147], "6": [74, 145, 234], "7": [253, 253, 253], "8": [104, 193, 84], "9": [78, 145, 233], "10": [61, 133, 230], "11": [77, 150, 240], "12": [81, 150, 239], "13": [242, 75, 103], "14": [253, 254, 167], "15": [102, 195, 99], "16": [220, 58, 79], "17": [66, 171, 77], "18": [253, 253, 253], "19": [44, 129, 57], "20": [253, 253, 253], "21": [234, 75, 103], "22": [248, 240, 252], "23": [225, 66, 90], "24": [246, 94, 124], "25": [48, 134, 55], "26": [253, 171, 130], "27": [253, 254, 188], "28": [232, 77, 103], "29": [252, 239, 148], "30": [239, 231, 244], "31": [45, 107, 211], "32": [253, 251, 252], "33": [233, 127, 94], "34": [253, 253, 169], "35": [54, 148, 69], "36": [30, 61, 149], "37": [170, 212, 32], "38": [253, 214, 62], "39": [253, 218, 68], "40": [253, 254, 34], "41": [254, 150, 60], "42": [60, 93, 160], "43": [253, 237, 211], "44": [231, 0, 36], "45": [18, 56, 121], "46": [230, 214, 126], "47": [27, 72, 179], "48": [227, 68, 97], "49": [35, 119, 51], "50": [253, 249, 253], "51": [253, 253, 167], "52": [16, 51, 141], "53": [250, 152, 115], "54": [254, 255, 252]}\'']
I can't see any reference to 'std_err' in the code but either side of line 1042 reads:
scan_data = eval(rgb)
for key, value in scan_data.items():
scan_data[key] = tuple(value)
Just for reference, the left face looked like:
What I don't understand is that eval(rgb) seems to be returning a string to scan_data, whereas the format of the contents of rgb is that of a dictionary - at least to my untutored eye!
For example (from a different run) where I added a print statement "print('rgb =', rgb)" to get some debug data:
rgb = '{"1": [221, 5, 46], "2": [244, 6, 65], "3": [45, 120, 209], "4": [97, 180, 37], "5": [253, 254, 96], "6": [68, 136, 215], "7": [253, 251, 235], "8": [128, 200, 46], "9": [55, 120, 205], "10": [247, 250, 246], "11": [251, 254, 153], "12": [253, 189, 71], "13": [252, 242, 222], "14": [26, 72, 148], "15": [21, 65, 140], "16": [234, 83, 44], "17": [242, 88, 47], "18": [241, 82, 47], "19": [72, 135, 23], "20": [253, 251, 234], "21": [250, 10, 74], "22": [253, 238, 219], "23": [238, 6, 56], "24": [252, 27, 90], "25": [83, 153, 26], "26": [253, 148, 64], "27": [253, 254, 149], "28": [253, 254, 129], "29": [253, 247, 42], "30": [251, 221, 40], "31": [127, 202, 46], "32": [93, 173, 31], "33": [252, 226, 207], "34": [126, 199, 43], "35": [218, 3, 39], "36": [186, 8, 24], "37": [253, 218, 91], "38": [72, 129, 207], "39": [58, 116, 198], "40": [254, 147, 77], "41": [253, 183, 68], "42": [241, 13, 64], "43": [77, 147, 29], "44": [253, 237, 46], "45": [253, 244, 227], "46": [244, 209, 31], "47": [16, 60, 135], "48": [244, 9, 66], "49": [67, 137, 20], "50": [249, 250, 226], "51": [250, 254, 142], "52": [11, 47, 109], "53": [254, 125, 59], "54": [247, 250, 246]}'
Why doesn't eval(rgb) evaluate to dictionary?
from rubiks-cube-tracker.
I don't have this robot built to test this but replace the Projects/BricKuber/brickuber_lib.py
CameraReadFaceColors
method with the following code and give it another try. Post any Tracebacks here and we can go back and forth to get this chunk of code updated.
def CameraReadFaceColors(self, face):
debug_print_commands("START: Read Face Colors: " + str(face))
filename = '/tmp/BricKuber_{}_face.jpg'.format(face)
subprocess.run(['raspistill', '-w', '300', '-h', '300', '-t', '1', '--imxfx', 'cartoon', '-o', filename])
subprocess.run(['raspistill', '-w', '300', '-h', '300', '-t', '1', '--sharpness', '-100', '--awb', 'auto', '--imxfx', 'cartoon', '-o', filename])
subprocess.run(['raspistill', '-w', '300', '-h', '300', '-t', '1', '--imxfx', 'cartoon', '-o', filename])
debug_print_commands("Picture taken")
raw_result = subprocess.check_output(['rubiks-cube-tracker.py', '--filename', filename]).decode("utf-8")
# raw_result.stdout will be a JSON string that looks something like the following. The key is the
# square number and the value is a tuple of RGB ints.
# {
# "1": [234, 126, 92],
# "2": [253, 246, 253],
# "3": [253, 254, 252],
# "4": [232, 123, 89],
# "5": [34, 87, 189],
# "6": [253, 252, 159],
# "7": [230, 118, 87],
# "8": [37, 85, 185],
# "9": [253, 172, 131]
# }
raw_data = json.loads(raw_result.stdout)
for square, rgb in raw_data.items():
# BricKuber rgb_values index starts at 0 so subtract 1 from the square value
self.rgb_values[int(square) - 1] = rgb
debug_print_commands("END: Read Face Colors")
also you will need to add import json
up at the top of the file with the other import statements
from rubiks-cube-tracker.
Hmmm...
START: Read Face Colors: top
Picture taken
2022-10-10 15:23:32,458 __init__.py INFO: Analyze /tmp/BricKuber_top_face.jpg
Error: 'str' object has no attribute 'stdout'
So much changed in that last edit. I checked but it seems I cut & pasted it all OK.
from rubiks-cube-tracker.
On the json.loads line change that to:
raw_data = json.loads(raw_result)
from rubiks-cube-tracker.
OK, stab in the dark, i removed the .stdout from:
raw_data = json.loads(raw_result)
and the process ran to produce:
['rubiks-color-resolver.py', '--rgb', '\'{"1": [57, 127, 50], "2": [66, 155, 62], "3": [245, 247, 201], "4": [204, 39, 58], "5": [83, 173, 74], "6": [245, 248, 222], "7": [197, 37, 55], "8": [247, 248, 245], "9": [245, 248, 222], "10": [0, 0, 0], "11": [0, 0, 0], "12": [0, 0, 0], "13": [0, 0, 0], "14": [0, 0, 0], "15": [0, 0, 0], "16": [0, 0, 0], "17": [0, 0, 0], "18": [0, 0, 0], "19": [0, 0, 0], "20": [0, 0, 0], "21": [0, 0, 0], "22": [0, 0, 0], "23": [0, 0, 0], "24": [0, 0, 0], "25": [0, 0, 0], "26": [0, 0, 0], "27": [0, 0, 0], "28": [0, 0, 0], "29": [0, 0, 0], "30": [0, 0, 0], "31": [0, 0, 0], "32": [0, 0, 0], "33": [0, 0, 0], "34": [0, 0, 0], "35": [0, 0, 0], "36": [0, 0, 0], "37": [0, 0, 0], "38": [0, 0, 0], "39": [0, 0, 0], "40": [0, 0, 0], "41": [0, 0, 0], "42": [0, 0, 0], "43": [0, 0, 0], "44": [0, 0, 0], "45": [0, 0, 0], "46": [0, 0, 0], "47": [0, 0, 0], "48": [0, 0, 0], "49": [0, 0, 0], "50": [0, 0, 0], "51": [0, 0, 0], "52": [0, 0, 0], "53": [0, 0, 0], "54": [0, 0, 0]}\'']
but the down-stream code still fell over with:
Traceback (most recent call last):
File "/usr/local/bin/rubiks-color-resolver.py", line 12, in <module>
resolve_colors(sys.argv)
File "/usr/local/lib/python3.7/dist-packages/rubikscolorresolver/solver.py", line 1042, in resolve_colors
for key, value in scan_data.items():
AttributeError: 'str' object has no attribute 'items'
Error: name 'std_err' is not defined
scan_data from this run looks like:
scan_data = {"1": [247, 233, 240], "2": [253, 160, 100], "3": [54, 113, 210], "4": [250, 227, 91], "5": [247, 250, 247], "6": [109, 200, 94], "7": [203, 41, 60], "8": [46, 98, 196], "9": [246, 249, 225], "10": [0, 0, 0], "11": [0, 0, 0], "12": [0, 0, 0], "13": [0, 0, 0], "14": [0, 0, 0], "15": [0, 0, 0], "16": [0, 0, 0], "17": [0, 0, 0], "18": [0, 0, 0], "19": [0, 0, 0], "20": [0, 0, 0], "21": [0, 0, 0], "22": [0, 0, 0], "23": [0, 0, 0], "24": [0, 0, 0], "25": [0, 0, 0], "26": [0, 0, 0], "27": [0, 0, 0], "28": [0, 0, 0], "29": [0, 0, 0], "30": [0, 0, 0], "31": [0, 0, 0], "32": [0, 0, 0], "33": [0, 0, 0], "34": [0, 0, 0], "35": [0, 0, 0], "36": [0, 0, 0], "37": [0, 0, 0], "38": [0, 0, 0], "39": [0, 0, 0], "40": [0, 0, 0], "41": [0, 0, 0], "42": [0, 0, 0], "43": [0, 0, 0], "44": [0, 0, 0], "45": [0, 0, 0], "46": [0, 0, 0], "47": [0, 0, 0], "48": [0, 0, 0], "49": [0, 0, 0], "50": [0, 0, 0], "51": [0, 0, 0], "52": [0, 0, 0], "53": [0, 0, 0], "54": [0, 0, 0]}
which looks a lot like a dictionary to me, but with rubbish entries! Only the 1st face data looks right, then all after is zeros.
from rubiks-cube-tracker.
OK, real progress!!!
I reverted to the original copy of brickuber_lib.py and changed the following in
/usr/local/lib/python3.7/dist-packages/rubikscolorresolver/solver.py
# scan_data = eval(rgb)
scan_data = json.loads(eval(rgb))
print('scan_data =', scan_data) # my debug print statement
Having added import json at the top of the code.
Process ran to:
['rubiks-color-resolver.py', '--rgb', '\'{"1": [235, 211, 34], "2": [227, 229, 218], "3": [222, 4, 44], "4": [234, 218, 29], "5": [83, 159, 29], "6": [235, 7, 54], "7": [235, 211, 29], "8": [92, 166, 32], "9": [157, 201, 68], "10": [18, 74, 160], "11": [47, 100, 183], "12": [68, 112, 187], "13": [217, 6, 40], "14": [235, 239, 102], "15": [97, 177, 42], "16": [199, 8, 34], "17": [64, 145, 22], "18": [234, 232, 213], "19": [186, 7, 31], "20": [207, 2, 34], "21": [231, 236, 86], "22": [233, 222, 200], "23": [218, 7, 44], "24": [241, 181, 48], "25": [59, 119, 18], "26": [229, 231, 227], "27": [117, 184, 45], "28": [232, 22, 62], "29": [229, 233, 81], "30": [230, 220, 198], "31": [31, 80, 162], "32": [227, 229, 222], "33": [236, 84, 41], "34": [229, 233, 101], "35": [65, 139, 18], "36": [9, 42, 100], "37": [93, 170, 31], "38": [238, 196, 54], "39": [238, 205, 67], "40": [232, 234, 30], "41": [241, 157, 43], "42": [49, 85, 156], "43": [231, 223, 199], "44": [200, 2, 33], "45": [9, 47, 112], "46": [232, 72, 40], "47": [10, 49, 117], "48": [240, 158, 46], "49": [235, 211, 33], "50": [19, 60, 130], "51": [238, 187, 50], "52": [231, 216, 195], "53": [227, 229, 225], "54": [238, 187, 59]}\'']
scan_data = {'1': [235, 211, 34], '2': [227, 229, 218], '3': [222, 4, 44], '4': [234, 218, 29], '5': [83, 159, 29], '6': [235, 7, 54], '7': [235, 211, 29], '8': [92, 166, 32], '9': [157, 201, 68], '10': [18, 74, 160], '11': [47, 100, 183], '12': [68, 112, 187], '13': [217, 6, 40], '14': [235, 239, 102], '15': [97, 177, 42], '16': [199, 8, 34], '17': [64, 145, 22], '18': [234, 232, 213], '19': [186, 7, 31], '20': [207, 2, 34], '21': [231, 236, 86], '22': [233, 222, 200], '23': [218, 7, 44], '24': [241, 181, 48], '25': [59, 119, 18], '26': [229, 231, 227], '27': [117, 184, 45], '28': [232, 22, 62], '29': [229, 233, 81], '30': [230, 220, 198], '31': [31, 80, 162], '32': [227, 229, 222], '33': [236, 84, 41], '34': [229, 233, 101], '35': [65, 139, 18], '36': [9, 42, 100], '37': [93, 170, 31], '38': [238, 196, 54], '39': [238, 205, 67], '40': [232, 234, 30], '41': [241, 157, 43], '42': [49, 85, 156], '43': [231, 223, 199], '44': [200, 2, 33], '45': [9, 47, 112], '46': [232, 72, 40], '47': [10, 49, 117], '48': [240, 158, 46], '49': [235, 211, 33], '50': [19, 60, 130], '51': [238, 187, 50], '52': [231, 216, 195], '53': [227, 229, 225], '54': [238, 187, 59]}
Cube
Ye Wh Rd
Ye Gr Rd
Ye Gr Gr
Bu Bu Bu Rd Rd Ye Rd Ye Wh Gr OR OR
Rd Ye Gr Wh Rd OR Bu Wh OR Ye OR Bu
Rd Gr Wh Gr Wh Gr Ye Gr Bu Wh Rd Bu
OR Bu OR
Ye Bu OR
Wh Wh OR
LRFLUFLUUFLRDRBLUDFFLRFBURUBDBLDBRRBDDDFLUFURUBBLBDRFD
Error: name 'std_err' is not defined
So all the double quotes were converted to single quotes and the string was treated as a dictionary. Whoopee!
The final Error: must be somewhere in the kociemba code.
Very many thanks for all your help. I'll try and leave you in peace. :-)
Cheers, Chris
PS the BSG turned into a lovely, sunny autumn (fall) day.
from rubiks-cube-tracker.
I see what is happening...replace your file with this and give it another go
https://raw.githubusercontent.com/dwalton76/BrickPi3/master/Projects/BricKuber/brickuber_lib.py
from rubiks-cube-tracker.
ok this part
LRFLUFLUUFLRDRBLUDFFLRFBURUBDBLDBRRBDDDFLUFURUBBLBDRFD
Error: name 'std_err' is not defined
I think you are also running an older copy of rubiks-color-resolver so you need to uninstall/re-install that via
sudo find /usr -name rubikscolorresolver* | xargs rm -rf
sudo find /usr -name rubiks-color-resolver.py | xargs rm -rf
sudo pip install git+https://github.com/dwalton76/rubiks-color-resolver.git
from rubiks-cube-tracker.
No, I'm using the latest & greatest rubiks-color-resolver as I mentioned recently. However, using the brickuber_lib.py from your BricKuber repository gets me a long way down the line.
Cube
Bu Gr Rd
Ye OR Gr
OR Bu Rd
OR Rd Ye Gr Rd Gr Ye Ye Ye Bu Rd Ye
Gr Ye Ye OR Gr Bu OR Wh OR Wh Bu Wh
Bu Ye Wh Gr Gr Wh Rd Rd OR Bu Bu Wh
OR OR Gr
Bu Rd Wh
Rd Wh Wh
BFDLUFUBDLLLURUDDUFDFUFBFFRUUFBDRDRRUDLFLLBLRBDLRBRBBR
Using kociemba to compute an efficient solve solution.
Error: Error. Probably cubestring is invalid
The whole face scan operation is inordinately sensitive to light source and intensity.
But we're nearly there. Just tweaking of the illumination is required now I believe.
Many, many thanks for all your help and for the software.
Cheers & beers, Chris
from rubiks-cube-tracker.
For the RGB values you posted about 2 hours ago everything is good
For the one above where you got the Probably cubestring is invalid
, can you send me the RGB json string that was passed to rubiks-color-resolver.py? If you aren't sure what the values were just attach the /tmp/rubiks-color-resolver.html
file to the issue here...that is the debug output from the color resolver
from rubiks-cube-tracker.
Unfortunately I shut the RPi down and all the dumps which were only on a terminal are now lost along with a lot of the contents of /tmp.
I'm off to bed. Let me know if there is anything I can post tomorrow.
from rubiks-cube-tracker.
Did another quick run before retiring:
['rubiks-color-resolver.py', '--rgb', '{"1": [52, 113, 1], "2": [230, 1, 41], "3": [113, 194, 29], "4": [82, 157, 16], "5": [96, 181, 21], "6": [253, 159, 72], "7": [253, 233, 46], "8": [9, 72, 167], "9": [140, 210, 34], "19": [224, 98, 60], "20": [201, 38, 46], "21": [253, 239, 105], "22": [230, 107, 63], "23": [251, 237, 236], "24": [253, 163, 92], "25": [230, 107, 63], "26": [207, 41, 47], "27": [253, 244, 90], "46": [24, 53, 130], "47": [252, 241, 246], "48": [31, 85, 190], "49": [243, 227, 232], "50": [26, 72, 169], "51": [253, 247, 95], "52": [12, 50, 139], "53": [26, 71, 167], "54": [254, 254, 252], "28": [29, 63, 156], "29": [76, 171, 55], "30": [242, 63, 86], "31": [253, 246, 253], "32": [253, 170, 104], "33": [108, 198, 68], "34": [213, 38, 49], "35": [38, 96, 202], "36": [249, 77, 97], "37": [161, 27, 33], "38": [235, 128, 87], "39": [253, 248, 253], "40": [230, 219, 236], "41": [243, 226, 117], "42": [253, 239, 138], "43": [221, 101, 67], "44": [242, 223, 112], "45": [253, 247, 253], "10": [252, 219, 48], "11": [4, 56, 148], "12": [253, 136, 74], "13": [69, 144, 10], "14": [233, 1, 43], "15": [250, 6, 61], "16": [253, 232, 217], "17": [253, 242, 38], "18": [123, 193, 25]}']
Cube
Gr OR Gr
OR Gr Ye
Ye Bu Ye
OR Bu Gr OR Rd OR Bu Gr Ye Rd Ye Wh
Gr Rd Rd Ye Wh OR Wh OR Gr Rd Ye OR
Wh Gr Wh OR Rd Ye Rd Bu Rd Gr Wh Rd
Bu Wh Bu
Wh Bu Ye
Bu Bu Wh
URURUBBDBDUBFRULDLRLRBFRRLBDFDFDBDDFRDUULLFUFLBFLBRUFL
Using kociemba to compute an efficient solve solution.
Error: Error. Probably cubestring is invalid
The actual faces are:
Lots of misinterpreted colours especially Rd->Or, Or->Ye, Ye->Wh etc.
Bottom is completely correct but most other faces have misinterpreted colours.
Ah, the other thing you asked for was the rgb data from rubiks-color-resolver.html:
RGB Input
{'1': (52, 113, 1), '2': (230, 1, 41), '3': (113, 194, 29), '4': (82, 157, 16), '5': (96, 181, 21), '6': (253, 159, 72), '7': (253, 233, 46), '8': (9, 72, 167), '9': (140, 210, 34), '19': (224, 98, 60), '20': (201, 38, 46), '21': (253, 239, 105), '22': (230, 107, 63), '23': (251, 237, 236), '24': (253, 163, 92), '25': (230, 107, 63), '26': (207, 41, 47), '27': (253, 244, 90), '46': (24, 53, 130), '47': (252, 241, 246), '48': (31, 85, 190), '49': (243, 227, 232), '50': (26, 72, 169), '51': (253, 247, 95), '52': (12, 50, 139), '53': (26, 71, 167), '54': (254, 254, 252), '28': (29, 63, 156), '29': (76, 171, 55), '30': (242, 63, 86), '31': (253, 246, 253), '32': (253, 170, 104), '33': (108, 198, 68), '34': (213, 38, 49), '35': (38, 96, 202), '36': (249, 77, 97), '37': (161, 27, 33), '38': (235, 128, 87), '39': (253, 248, 253), '40': (230, 219, 236), '41': (243, 226, 117), '42': (253, 239, 138), '43': (221, 101, 67), '44': (242, 223, 112), '45': (253, 247, 253), '10': (252, 219, 48), '11': (4, 56, 148), '12': (253, 136, 74), '13': (69, 144, 10), '14': (233, 1, 43), '15': (250, 6, 61), '16': (253, 232, 217), '17': (253, 242, 38), '18': (123, 193, 25)}
gzipped .html file:
from rubiks-cube-tracker.
This is from the html file, these are the initial RGB values
Look at that "7, 19, 12" corner, 12 and 19 are both orange both in that data and in your pictures above. This tells us the robot is making a mistake in how it rotates the cube around to take pics of each side. Do this for me...hold the cube so that you are looking at the front face as shown in the pic above and turn the cube enough so that I can see the left/front sides at the same time and send me a pic of that (just from your cell phone, not the robot). Same thing for the front/right side.
from rubiks-cube-tracker.
I think I see what you mean. That L face is rotated 90 clockwise in the cube view (not the photo).
...and the R face is 180 out.
Looks like the self.SPIN_DIRECTION = 1 has changed polarity?
from rubiks-cube-tracker.
This is the section that needs tweaking
https://github.com/dwalton76/BrickPi3/blob/master/Projects/BricKuber/brickuber_lib.py#L330-L342
self.CameraReadFaceColors("top")
self.flip(True)
self.CameraReadFaceColors("front")
self.flip(True)
self.CameraReadFaceColors("bottom")
self.spin(90)
self.flip(True)
self.CameraReadFaceColors("right")
self.spin(-90)
self.flip(True)
self.CameraReadFaceColors("back")
self.flip(True)
self.CameraReadFaceColors("left")
self.CCO = [5, 1, 0]
To test your SPIN_POLARITY theory change the 90 above to -90 and vice versa. Then rescan and look at the pictures and see if they look right.
If that doesn't work you'll need experiment with adding/removing self.spin(90)
in various places above so that the cube is rotated correctly when we take the picture. Once that is ironed out we need to sanity check that self.CCO = [5, 1, 0]
line...that is the state of which side of the cube is facing which direction but I don't entirely follow the logic yet.
from rubiks-cube-tracker.
OK, I only changed the self.spin(+/-90) lines, ran the program and it said everything was OK and tried to apply the solution. But the cube was a jumble. So I reverted the changes and just changed the spin polarity line and got:
Error: Error. Probably cubestring is invalid
Just checking the faces with the cube layout diagram...
from rubiks-cube-tracker.
Hmmm... can't match any face with the cube layout!
My brain is beginning to hurt!
from rubiks-cube-tracker.
OK, I only changed the self.spin(+/-90) lines, ran the program and it said everything was OK
lets focus on that first...don't worry about if it can solve it just yet. After it takes the pictures pull the cube out of the robot and
- look at all of the images, are they rotated corrrectly?
- compare the cube vs
/tmp/rubiks-color-resolver.html
, does it look like the color solver got the colors correct?
Once we can answer yes to both of those questions then we just need to figure out what the self.CCO = ...
should be and then it should be able to solve it.
from rubiks-cube-tracker.
Reference point: self.spin(+/-90) reversed from issued code:
# self.spin(90)
self.spin(-90)
self.flip(True)
self.CameraReadFaceColors("right")
# self.spin(-90)
self.spin(90)
Images are not rotated correctly:
L cube face is rotated 90 counterclockwise reference cube layout.
R cube face is rotated 180 clockwise reference cube layout.
However all colours have been correctly interpreted.
from rubiks-cube-tracker.
from rubiks-cube-tracker.
In this chunk of code
self.release()
self.CameraReadFaceColors("top")
self.flip(True)
self.CameraReadFaceColors("front")
self.flip(True)
self.CameraReadFaceColors("bottom")
self.spin(90)
self.flip(True)
self.CameraReadFaceColors("right")
self.spin(-90)
self.flip(True)
self.CameraReadFaceColors("back")
self.flip(True)
self.CameraReadFaceColors("left")
- experiment with the spin calls until the "right" picture is rotated correct
- then double check the "back' picture to make sure it is rotated correctly, it will be impacted by whatever spins you add to get the "right" picture rotated correctly
- then double check the "left" picture to make sure it is rotated correctly
If they aren't rotated correctly but the color resolver got the colors correct anyway it was just lucky...it won't work consistently.
from rubiks-cube-tracker.
This way lies madness!
I labeled two faces so I knew where L & R were, then using the opposite spin to the issued code I watched the faces being presented to the camera. With the s/w in that configuration the correct faces were photographed according to the self.CameraReadFaceColors("?"). However the cube layout as presented is incorrect. The R face is rotated thru 180 & the L face is rotated thru -90. It's as if the software is numbering the squares incorrectly?
The weird thing is that the cube layout shown at the end of the resolver pass is not the same as the .html
but the cube layout is:
Cube
Bu Ye Wh
Wh Wh Wh
Wh OR Gr
OR Gr OR Gr Gr Ye Rd Rd Rd Bu Gr Ye
Wh OR OR Bu Gr Ye Rd Rd Bu Wh Bu OR
Wh Ye Wh Rd Ye Gr Ye Rd Ye Rd Rd Bu
Gr OR OR
Bu Ye Bu
OR Gr Bu
BDUUUUULFRRRRRBDRDFFDBFDRDFFLLBDBLFBLFLULLUDUBFDUBLRRB
For completeness here is the input to rubiks-color-resolver.py
['rubiks-color-resolver.py', '--rgb', '{"1": [225, 216, 233], "2": [240, 225, 120], "3": [24, 77, 187], "4": [226, 209, 105], "5": [244, 233, 241], "6": [253, 250, 253], "7": [230, 220, 237], "8": [243, 224, 123], "9": [252, 152, 112], "19": [49, 128, 33], "20": [65, 160, 48], "21": [253, 254, 126], "22": [17, 64, 167], "23": [73, 170, 56], "24": [253, 185, 116], "25": [209, 35, 45], "26": [254, 254, 252], "27": [102, 193, 62], "46": [53, 137, 33], "47": [253, 168, 103], "48": [253, 254, 132], "49": [20, 68, 168], "50": [253, 251, 105], "51": [49, 117, 214], "52": [212, 36, 47], "53": [82, 169, 48], "54": [44, 108, 207], "28": [223, 1, 35], "29": [246, 1, 55], "30": [253, 1, 72], "31": [253, 119, 67], "32": [250, 3, 60], "33": [23, 105, 200], "34": [253, 246, 60], "35": [250, 2, 60], "36": [160, 219, 47], "37": [249, 237, 244], "38": [67, 167, 52], "39": [253, 189, 125], "40": [253, 243, 250], "41": [42, 97, 198], "42": [246, 75, 91], "43": [16, 61, 160], "44": [227, 52, 63], "45": [40, 106, 207], "10": [227, 201, 106], "11": [45, 133, 49], "12": [253, 159, 116], "13": [239, 227, 241], "14": [248, 141, 95], "15": [253, 167, 114], "16": [238, 226, 238], "17": [251, 230, 123], "18": [253, 162, 115]}']
All colours were correctly identified according to the .html.
I'll leave the cube in this configuration in case you want more info.
from rubiks-cube-tracker.
I need my beauty sleep so I'm going to bed...
from rubiks-cube-tracker.
All colours were correctly identified according to the .html
na they are way off...scroll down to the bottom of the html file and you will see the final colors it picked
But that is way off when you compare it to the RGB values extracted from the pics:
I think the image of the Right side needs to be rotated another 180 degrees. Look at that 9, 21, 28 corner...that has an orange and a red square on the same corner but that is not possible since red/orange are on opposite sides of the cube from each other.
- if you were to rotate the right face -90 there would still be an orange and a red on the same corner
- if you were to rotate the right face +90 then the 9, 21, 28 corner would have two yellow squares so we know that isn't right
- if you were to rotate the right face 180 then 9, 21, 28 would be orange, yellow, green which make sense
Add a self.spin(180)
just before your self.CameraReadFaceColors("right")
call and then I think at least the right side would be rotated correctly.
from rubiks-cube-tracker.
Hold the front page! It solved a random cube!!!!!
Just a few remarks which may no longer be relevant:
I had no idea what the "Final Cube" was meant to represent. I was simply going by the "Initial RGB Values" which looked about right except for rotations.
After doing some 3-D gymnastics in my mind, I realised that, in order to present the faces as they would be in the flattened cube presentation, some extra spins were required. I added these to the code as follows:
self.CameraReadFaceColors("top")
self.flip(True)
self.CameraReadFaceColors("front")
self.flip(True)
self.CameraReadFaceColors("bottom")
self.spin(-90)
self.flip(True)
self.spin(180)
self.CameraReadFaceColors("right")
self.spin(-90)
self.flip(True)
self.spin(90)
self.CameraReadFaceColors("back")
self.spin(-90)
self.flip(True)
self.spin(90)
self.CameraReadFaceColors("left")
self.CCO = [5, 1, 0]
Note the extra spins after some flips.
BTW flip in this context means rotate the cube clockwise with respect to the current L-R axis wrt the R face. It's awkward to use L & R here as that should refer to the initial cube but I couldn't think of a better way to express it.
With this arrangement the code runs through to starting the kociemba solution. So I've lost the configuration I have been working with. :-(
However, I think the self. CCO = [5, 1, 0] is no longer correct because of the extra spins but I haven't yet worked out what that should be.
Later: I think that should now be [1, 5, 2] as the cube finishes up with the original L face uppermost.
Later still: No that CCO doesn't work so maybe I don't understand the meaning. Though I see in the code it represents [U, F, R] but from what perspective?
Later yet: Got it! CCO = [5, 3, 1] works AND the robot solves the cube!!!!!!
Incidentally I think there is probably a more efficient order to take the photos, in terms of spins, now that there are extras required to satisfy the flattened layout.
In the original Dexter/BricKuber supplied brickuber_lib.py there was a bunch of code to reorientate the faces - I think. :-)
The initial & final now look the same or thereabouts:
from rubiks-cube-tracker.
looks like everything is rotated correctly now, awesome. The Initial RGB values
are the RGB values we extracted for each square from the pictures but at this point the color resolver doesn't know which of the six cube colors each square is. The Final Cube
picture is where the color resolver has worked out what color each square is (hopefully correctly). So I often compare the two to quickly tell if it got everything right.
Incidentally I think there is probably a more efficient order to take the photos, in terms of spins
agreed...one that jumps out to me is to do top, front, bottom, back and then left/right or right/left. That would be something like
self.CameraReadFaceColors("top")
self.flip(True)
self.CameraReadFaceColors("front")
self.flip(True)
self.CameraReadFaceColors("bottom")
self.flip(True)
self.CameraReadFaceColors("back")
# this spin might need to be a -90 instead of +90
self.spin(90)
self.flip(True)
# not sure if left or right would be exposed here but it would be one of the two
self.CameraReadFaceColors("right or left?")
self.flip(True)
self.flip(True)
# might need a self.spin(180) here
self.CameraReadFaceColors("right or left?")
ok for the self.CCO value I put together some notes on how this works
# 0 is side U
# 1 is side F
# 2 is side R
# 3 is side D
# 4 is side B
# 5 is side L
#
# In self.CCO:
# - the first entry in self.CCO is the side that is facing up
# - the second entry in self.CCO is the side that is facing the front
# - the third entry in self.CCO is the side that is facing the right
If I had a cube in my hand (I'm at work so no rubiks cubes here) I could probably walk through your move sequence and figure this out but trying to do that in my head is making my head spin. The easiest way might be to stick a solved cube in the robot, let it scan all of the faces and use that to determine what self.CCO should be at the end of the scan. Or heck just put your scrambled cube in so that at the start the white center is up, green center is front and red center is to the right
and then at the end of the scan look at the center squares to tell what CCO should be.
from rubiks-cube-tracker.
That was a bit of a marathon but I do at least understand the logic of brickuber_lib.py better now.
Very many thanks for your help. I doubt I'd have cracked it by myself.
I'd be interested to know what your job is. I'm a retired software engineer. I started working with computers back in the age of steam i.e. vacuum tubes in 1960. I'll be 80 next July but, believe it or not, I'm still retained by an employer on a consultancy basis as I have knowledge of an almost defunct OS (OpenVMS) which some of my employer's clients still use. When I pop my clogs I don't know where they'll find that expertise elsewhere. :-)
Thanks again.
from rubiks-cube-tracker.
Incidentally while I was reading through some of the code comments I found a remark concerning self.SPIN_DIRECTION. The comment said that the NXT1 & EV3 robots required opposite spins but the code had self.SPIN_DIRECTION = 1 for both robot styles. I changed the code for EV3 to -1 and reverted all the spin 90s to their original signs and everything started to make sense. This parameter is used by the solver code too.
I've incorporated your notes on CCO into the code so I don't have the same headache when I next visit the code.
Now I must take an image copy of the SSD so I have a working copy to fall back on in case of a disaster.
Cheers & beers,
Chris
from rubiks-cube-tracker.
awesome, can you post your final Projects/BricKuber/brickuber_lib.py
here? I will submit a pull request to https://github.com/DexterInd/BrickPi3 to get it updated with all of the fixes we made...will save someone else a lot of headache in the future :)
I am also a software engineer, I work in the networking industry. I worked for Cisco Systems for ages where I wrote mostly C but then started doing the startup thing about 10 years ago and picked up python...I've been writing python fulltime since then. The rubiks cube software is just for fun...I built this robot
https://www.youtube.com/watch?v=3HjKxTlLDLw
and then had to write a ton of software to be able to figure out the state of the cube...that is where all of the rubiks-cube-tracker and rubiks-color-resolver software is used. Then I had to write a solver for 5x5x5 and larger cubes because there were not any open source solvers out there for anything larger than a 4x4x4. The solver was much much harder than I anticipated...had I known what I was getting into I probably would not have done it. I worked on the solver off/on for several years...basically trying to get it to find shorter and shorter solutions. Short of some massive breakthrough on path searching algorithms I think it is done at this point...I am out of ideas on things to find shorter solutions.
That is cool that you are still working. I am 46, hopefully I am still tinkering with python when I am 80 :)
from rubiks-cube-tracker.
The tape you have on the white center square....I have one of those same cubes and I am pretty sure the logo is a sticker you can pull off.
from rubiks-cube-tracker.
Ah, thanks for that. I'll have to see if I can peel that off.
I did most of my later work in C & C++ with the odd (really odd) excursion into Pascal. I tried to ignore Python but it is everywhere now. I can see the attraction of the language but it is still so fluid it seems to change almost by the day! One thing that baffles me is where do I find library definitions? It's all very well to say 'import x from y' but where are the specs for y let alone x!
I used to work in the aircraft industry many decades ago and really enjoyed writing real-time data acquisition code. That is where you learn to squeeze a quart into a pint pot and make every line of code work as efficiently as possible. Happy days!
Can you talk me through uploading the current state of brickuber_lib.py please?
from rubiks-cube-tracker.
If you gzip brickuber_lib.py
you should be able to drag-n-drop the brickuber_lib.py.gz
to the issue here
from rubiks-cube-tracker.
from rubiks-cube-tracker.
I opened two PRs against the BrickPi3 repo
Feel free to add some comments to that first one about the motor constant changes...they may ask for some more details on that.
from rubiks-cube-tracker.
Related Issues (11)
- Webcam issues HOT 2
- Raspberry pi camera HOT 9
- Identify the problem HOT 1
- Isn't working after 2019 update HOT 17
- run problem HOT 2
- This photo fails an assert HOT 5
- Typo? HOT 2
- brickuber_lib.py modified for RaspiOS Bullseye with libcamera-still
- confusing between red and orange HOT 10
- Can't seem to use webcam with raspberry pi 5's camera (module 2).
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubiks-cube-tracker.