The Solver Log
After going through the proposal with Deko, we uploaded the proposal to the wiki page. Our mechanical design prototype is almost done. We have learned that the Raspberry Pi works with Python so we just have to learn how the GUI for the Raspberry Pi operates.
Due to a misunderstanding in the Gantt chart as far as the dates being the start of the week versus the end of the week, I (Jordan) had to do two weeks worth of work. Oscar also has decided to do two weeks worth of work while Alex has decided to shorten a different task by a week to make up for this mistake.
Jordan: This week I figured out how the Raspberry Pi worked and found a solving algorithm. I found a tutorial on the Raspberry Pi website on how to install NOOBS. The tutorial said I needed to format the SD card that came with the Pi. I plugged the SD card into my computer but after a lot of problem solving, I discovered that my computer's SD card reader could not read SDHC cards. I was told by Deko to purchase a SD to USB converter. I found one on Amazon and purchased it on my own money. At the time I thought I needed this device every time I wanted to edit code on the Pi. It turns out I did not need it at all because the SD card was already loaded with all of the necessary programs. My next task was to get the Raspberry Pi display to work so that I could edit code. Luckily, I have all I need in my room to get the Pi to work. I needed a mini-USB to USB cable, a USB to outlet plug, an HDMI cord, a monitor/TV with an HDMI in port, a USB mouse, and a USB keyboard. I downloaded Raspbian onto the Pi. I learned through the Pi's GUI that the algorithms can be in python, java, or other less commonly used languages. When we went into lab on Wednesday, Deko gave us a box that had a mini-USB to outlet plug and other useful items. I had been researching solving algorithms on the internet at first to see if there were more algorithms in python or java. I have prior knowledge in java but no knowledge of python. I found a couple of algorithms in python so as a group we decided that the project will be written in python. I found one algorithm and downloaded the source code. The problem with this code is that it needs something called setuptools, which is a python file. We tried to download it onto a school computer but it did not work. We found another algorithm that purely prints out the steps needed to solve a given cube, which will be good enough for now. The next step is to convert this algorithm in a way that the steps can be a list that can be transferred to the motors and the input can be given in the form of a list of colors.
Oscar: I have spent this week primarily learning the ropes of Raspberry Pi in order to understand how we will use it in the project. I have watched a variety of tutorials online and have tinkered with the Pi in order to learn my way around. I have also spent time refreshing my knowledge on Python as it will be the language we will program everything in. Jordan and I have found a variety source codes to use as a guide for our own solving algorithm. We were able to download two main ones, one specifically that recognizes the position of the cube and then tells you the steps needed on how to solve it. We both realized we can use it to come up with a way to convert the text of steps into commands to the motors used to turn the cube. I have also started to dig into how I will tackle the color recognition part of the project. The main potential obstacle will be having the Pi able to distinguish between certain colors from the pixels. A solution could be to have the cube well lit so the camera can be consistent with its detection of specific colors. The camera can then take the middle pixel of each square on each side of the cube and then convert that to RGB values. As soon as the budget is cleared, I can begin to use the camera to test this method.
Alex: This week has been spent finishing the CAD files and finalizing the final parts list. Earlier in the week, I printed the gripper I created in inventor and powered it with a personal micro servo, which seems like it will work. This week as well had some design changes, with the decision to switch from stepper motors to servos due to the fact the gripper servo wires prevent continuous rotation anyways and the control circuitry to power the stepper motors while keeping within the budget. Now that we have switched over, a lot of the mounts now have to be redesigned. Still to finish with the CAD this weekend is to redesign the gripper base to accomodate the servo mounts instead of the stepper mounts as well as design a camera mount and a holder for the Pi. We should be able to start printing all the parts on Monday.
- Downloaded kociemba.py, a solving algorithm, using pip
- Command Prompt gave an error, and even with debugging, the error would not go away
- Found a new Solving Algorithm called pycuber
- Successfully downloaded pycuber straight onto the Raspberry Pi with little issue
- Tested the Solving Algoithm
- Pycuber displays a grid of numbers detailing the colors on each cubie
- Used the Python Shell to solve the given cube and output a list of moves it took to solve the cube
- Complications this week
- Needing to share the Raspberry Pi with Oscar
- Having an issue with 90% of the solving algorithms I tried to use
- Inputting a specific cube into the program instead of a random cube
- Downloaded OpenCV, an open source computer vision library.
- Will be used to allow the raspberry pi recognize different colors and sides of the cube efficiently.
- Began looking at more implementations of color recognition using an arducam
- Will try to use the camera to track colors on a side of the cube and save the configuration of each side of the cube
- If tracking fails, will focus on taking a picture and using the pixels to determine the colors.
- Not having the Raspberry Pi when needed due to having to share.
- Parts came in two days ago so no physical trials could be done until late in the week.
- Configuring OpenCV to run on the Raspberry Pi
- Purchased parts
- Modified the CAD files to accommodate the dimensions of parts
- Printed the third iteration of the gripper and integrated the parts into it. After a few more alterations to the files, we should be ready to print everything.
- Parts got here Wednesday, so I wasn't able to get the necessary dimensions until then.
- Print failed first time.
- I don't have any #5 Machine screws yet to assemble the grippers.
- The microservos don't come with enough screws to mount them so I will need to get some or find another way to mount the gear to the servo.
- Discovered a way to input a set of cubies into the solving algorithm by looking into the code a little deeper
- Downloaded all the necessary programs onto the raspberry pi to control the motors used for the Solver
- Found some examples in which the Raspberry Pi is used to control motors that I will base my work off of
- Testing of the camera has commenced.
- Started tinkering with the openCV library
- Started planning how to write code to accurately recognize colors
- K-Means algorithm
- Converting RGB to HSV
- Minor issue getting the openCV library to run
- Wrote a program that takes in a move and moves the motors in the right way to turn the rubik's cube
- Still need to
- Write the class to grab/release the servos
- Import the list of moves and do them one by one
- Reinstalled OpenCV after complications with importing it.
- Looked into getting the camera to recognize different color values.
- Discussed details of vertical and horizontal positions of the servos with Alex
- Alex will now work on finding the exact positions so that we can rotate the cube efficiently
- Wrote code to take the list of moves and do them one by one
- Code written for recognizing color from an existing photo
- Does not completely work, need to configure it to better mesh with our current setup
- More research being done into how to better execute the code and make sure the camera recognizes the right colors
- Basically finished the Motor Control
- Adjusted all of the horizontal and vertical positions on the servos with Alex
- Spent a lot of time checking each position using a sample python code
- Created code that should be able to recognize the colors on the squares of a cube face.
- Camera takes pictures of cube face and selects pixels in each of the 9 squares on the face.
- Code reads the colors RGB values of the pixels, passes the values through conditionals and assigns the square an integer corresponding to its likely color.
- Integers stored in cube face object and code repeats for each face.
- Issues include dealing with the light in the room and the consistency of recognizing the right colors. Will probably decide to use HSV later on. The position of the cube in the frame is something that needs to be fixed. Holding physical trials when the motors and grippers are completed will help with this issue.
- Touched up the Motor Control
- Discussed dividing up the code with Oscar
- Figured out better ranges of values for each color
- Discussed using an algorithm to help recognize the colors instead of a template
- Wrote some code for Oscar's color algorithm