“It uses a 3D printed SCARA robot arm from free resources with my code to recognise the human moves and control the arm
I previously made a Cartesian chess playing robot arm - and wanted to make a 3d-printed SCARA arm play chess too.
It works like this:
The human, playing white, makes a move. This is detected by the visual recognition system. The robot then ponders and then makes its move.
And so on…
Perhaps the most novel thing in this robot is the code for move recognition.
Because the human’s move is recognised by a vision system, no special chess board hardware (such as reed switches, or whatever) is needed.
A USB or IP camera is mounted directly above the chessboard.
Most of the code runs on a Raspberry Pi (or other Linux or Windows), with Arduino code for inverse kinematics and stepper motor control.
The Hardware Build
The 3D printer files for the robot are freely available as specified in the links under “Code”. The pyBot arm is modified by me to have longer arm components and use a mini-gripper. Jjrobots gives a great description of hardware, and robot assembly. We do not use theirgripper, electronics or software.
So, we have a Raspberry Pi (or other Linux or Windows) connected to an Arduino via a printer cable. The Arduino has a Ramps 1.4 board sitting on it to drive the motors via A4988 motor driver boards.
The stepper motors give very high precision and repeatability.
As an alternative to the USB connection to the Arduino, the code supports Bluetooth (not BLE), using an HC-05.
The Software Which Moves The Robot
All the Raspberry Pi code is written in Python 3.
So, we then have code which will move pieces, take pieces, castle, support en passant, and so on.
The chess engine is Stockfish - which can beat any human! “Stockfish is one of the strongest chess engines in the world. It is also much stronger than the best human chess grandmasters.”
I use some code from chessfortherapy.co.uk to validate the human’s move and interact with Stockfish. My code for recognising the human’s move and moving the SCARA robot arm interfaces with that.
On the Arduino, Inverse kinematics code is used in order to move the various motors correctly such that chess pieces can be moved. This code is based on code which ftobler wrote for his Cartesian robot, and modified by me for the SCARA robot.
The Software for Recognising the Human’s Move
This is exactly the same code that I wrote for my Cartesian chess robot, so please see the description there.
The algorithms work best if the chessboard has a colour that is a long way from the colour of the pieces! In my robot, the pieces are off-white and matt black, and the chess board is hand-made using a colour printer onto thin card. It can be seen in the video.
The chessboard should well-lit and evenly lit with minimal shadows from the chess pieces. Light should not be reflected back into the camera from the board or pieces. A sturdy table is needed.
My code contains routines for easily calibrating the camera. Calibration for fish-eye distortion is provided, and is more likely to be needed for IP cameras. USB cameras are usually OK without it, if they are placed far enough away.
The robot is easily calibrated manually. We start every game with the arm sticking out to the left (as in the video) and this can be easily aligned by eye. The height can also be adjusted to the correct height.”