Repository navigation
Home
Welcome to the ChessPlayingRobot wiki!
In this wiki you will read how this project is build up, what has been done in this project so far and go more in depth of the readme.md text.
Introduction The chess playing robot is a project from the Western University of Applied Sciences (HVL) that was given to me as a summerjob. The goal was to make the robot play chess on a DGT board versus a human. I were given a DGT-chessboard and a UR5e robotarm to work with, all conveniently located within the university's well-equipped lab. In addition to working on the robotic arm's control and maneuverability, I was also tasked with designing a suitable gripper specifically tailored to handle chess pieces efficiently. This gripper is intended to be versatile enough to pick up any chess piece, regardless of its size or height, ensuring smooth and seamless gameplay during matches.
This wiki will cover the nessesary components to give a understandable picture on how to create a project like this.
Getting started This project will take place in a linux computer. ROS only works with linux and its much better when you are going to work with robotarms and such things. The programming language is Python, in the VScode application.
DGT board Get the DGT-board : https://digitalgametechnology.com/products/home-use-e-boards. To get the communication between Python and the dgt chess board you can check out:
https://github.com/niklasf/python-asyncdgt/blob/master/README.rst. The connection code dgt = asyncdgt.auto_connect(loop, ["/dev/ttyACM*"]), this get's the board status. Remember to: import asyncdgt and àsyncio`.
For VScode, there is some requirements you have to install through the python terminal: pip install pyee==0.1.0, pip install pyserial==2.7, pip install wheel==0.24.0
For the UR5e robot Connecting the UR5e to python can be a bit tricky. You are going to connect to the same WIFI as the robotarm is connected to. In my code-set, I have my spesific ip adress, so that will have to change.
The gripper information will be found at this webpage:
https://sdurobotics.gitlab.io/ur_rtde/guides/guides.html#use-with-robotiq-gripper. And for the robotarm itself, you can find all the commands for movement, and get.TCPPosition to get.ActualJoints at this webpage:
https://sdurobotics.gitlab.io/ur_rtde/api/api.html To get the tcp position for the robot (tcp = tool centre point) you have to implement all the important code parts. First you need the robotiq_gripper_control.py, robotiq_gripper.py and robotiq_preamble.py. If you are going to move or get anything of information from the ur5e-robotarm you need:
from rtde_control import RTDEControlInterface as RTDEControl
from rtde_receive import RTDEReceiveInterface as RTDEReceive
from robotiq_gripper_control import RobotiqGripper
and in the code you are writing you need:
rtde_c = RTDEControl("172.31.1.144")
rtde_r = RTDEReceive("172.31.1.144")
gripper = RobotiqGripper(self.rtde_c)
and for the actuall get the TCP: tcpPos = rtde_r.getTargetTCPPose()
Chess engine This is the chess engine github profile which I got the engine for my project from: https://github.com/ScierKnave/chess_bot. This github gives a engine that does play chess against you, except you have to type in the different moves. This is the API for the chess library: https://python-chess.readthedocs.io/en/latest/core.html The API for the chess library explain everything you need to know about how to get UCI or how to push a move and everything chessrelated to the chessboard and chess. Classes info Here's some information about the different classes, and about what their purpose is.
The MainTestFile.py is where the program runs from. This is where you call the URClass.py and MainforChessengine.py and get the program to run.
Under the different classes is beeing described:
MainTestFile Start's the game.
URClass.py This class, URClass.py is used for the UR5-e robot arm. You controll the starting position, which is where it's ready to make the next move, and the code for all the 64-squares at the chessboard. The robot is controlled with TCP, tool-centre-point, to every position. The 'moverob()' function is where you want to put the start-square and the end-square when the robot is making a move. Example Nc3 -> from-square = b1, to-square = c3. B1 and c3 will be put in as parametre in the function. 'moverob('b1', 'c3'). The designations are something that repeats itself, for example 'Nc3' is a "san" value and 'b1c3' is a "uci" value which is important to understand the code.
MainforChessengine.py This is where the chessengine talks with the DGT board. The move that is been played will be sent to this class and the engine will make the best or worst move in return. The startGame() function is located in this class. This is where the move you made will be pushed on the viritual chessboard.
ChessEngine.py This the part you dont touch. This is the chessengine that calculate the best move, depends on the depth/difficulity you are playing on. High depth makes the engine better, but also takes longer time to answer with a good move.
testChess.py This class is mainly used for converting the move that has been made, into san-value. For instance if you move the pawn from e2 to e4 it will return the san- value 'e4'. When the dgt-board detects a change in the pattern it will scan the current state and save the previous state. The only task for this class is to return one value which is the san-value. There is also declared a viritual chessboard in this class. This chessboard are going to copy every move that is beeing made so it can have track of check's, en passant's, checkmate's and these sorts of things. This comes with the 'import chess' library.
Getuci.py Converts the board status to 'uci'. It need to compare two status in order for it to return a UCI. This is set to always white in the class, because it's work under progress. The function in this class is named get_uci() and takes two parametre, but in the starting point it took three, and the third was the color ("b" or "w"). I found it a little difficult to pass the color variable into this, but for a better programmer I dont think it will be an issue.
robotiq_gripper_control.py Necessary for the robot-gripper controll.
robotiq_preamble.py Necessary for the UR5e gripper.