We programmed a robotic arm to solve a 4x4 Sudoku puzzle by itself (ROS in Python). The robot can be stopped anytime by the user using a built-in command interface.
An algorithm to solve a sudoku puzzle was inspired by the paper: A Pencil-and-Paper Algorithm for Solving Sudoku Puzzles.
You can find the algorithm written in Python here: Sudoku algorithm.
A 4x4 sudoku board used in this project (24” x 24”)
The picture taken by the robotic arm would be processed using adaptive thresholding techniques in OpenCV.
Sudoku board taken from the robotic arm
We then find the contour of the Sudoku board from the processed image and apply perspective transformation on the contour to get a perfect-square image of the Sudoku grid.
Processed image after adaptive thresholding and perspective transformation
Finally, we crop out each digit and apply k-NN algorithm in OpenCV to predict the digits.
Final image processing result
Using the Sudoku algorithm above, we’ll find a solution for this puzzle.
A solved Sudoku puzzle
In this project, the arm will move to the center position above the Sudoku board to take a good picture of the board. After processing the picture and solving the Sudoku puzzle, the arm would then move to each empty cell and write the solution.
The arm is writing digits on the board
The arm has solved the puzzle
Check out the main function to see how the arm moves.