0% found this document useful (0 votes)
104 views

Anh2016 Chapter DesignAndControlAutomaticChess

Uploaded by

UIoi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

Anh2016 Chapter DesignAndControlAutomaticChess

Uploaded by

UIoi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Design and Control Automatic

Chess-Playing Robot Arm

Nguyen Duy Anh, Luong Thanh Nhat and Tran Van Phan Nhan

Abstract This paper presents a 3DoF robot manipulator system which can play
chess physically with human. The system consists of three main parts: a computer
vision program written by Visual Studio to recognize chess moves, a chess program
to choose the best move to response and a robot arm to perform chess move on a
real chessboard. In this paper, the authors focus on analyzing mechanical design,
methods to detect chess moves and algorithm applied to control the SCARA robot
arm. Based on the design, a robot arm was manufactured and set up. Chess matches
between robot and human were held to experiment the operation of robot arm as
well as the result of the matches.

Keywords Chess robot  Chess program  SCARA

1 Introduction

Chess is a two-player strategy game played on chessboard. The question is: “What
will happened if the opponent is a robot?”. Nowadays, super computers can beat
chess grand masters, however, there must be one man who reads the result of
calculation from the computer, then, execute the move on chessboard [1].
Therefore, an autonomous chess-playing process has been being researched in the
world. In Vietnam, there have not been any researches about autonomous
chess-playing system, authors decided to manufacture a robot arm which can play
chess automatically and physically.

N.D. Anh (&)  L.T. Nhat  T. Van Phan Nhan


Faculty of Mechanical, HCMC University of Technology, 268 Ly Thuong Kiet Street,
Ward 14, District 10, Ho Chi Minh City, Vietnam
e-mail: [email protected]

© Springer International Publishing Switzerland 2016 485


V.H. Duy et al. (eds.), AETA 2015: Recent Advances in Electrical
Engineering and Related Sciences, Lecture Notes in Electrical Engineering 371,
DOI 10.1007/978-3-319-27247-4_41
486 N.D. Anh et al.

Opponent’s move
COMPUTER UNIT WEBCAM UNIT
(Execute: image processing , USB (Use Logitech C 170 to
playing chess program ) identify chess moves )

RS 232
Robot’s
move

%PWM,
Kp, Ki,Kd
MICROCONTROLLER POWER UNIT
UNIT (Use 3 DC servo
(Use STM32F4) and 1 RC servo)
Encoder

Fig. 1 System diagram

In the first part of project, SolidWorks was used to calculate and design struc-
ture, dimension of links, joints of robot arm. In the second part, one camera hung
above the chessboard and taking pictures to detect chess moves. A chess-playing
program written on Visual Studio will evaluate and find the best move for robot. In
the final part, a PID controller was used to control position of robot arm. A whole
system is briefly described in Fig. 1.

2 Mechanical Design

2.1 Kinematics

The kinematics model was built by the algorithm of Denavit Hartenberg; the DH
parameters are the relationships among the robot’s serial links. Base on require-
ments of the system, the SCARA type was used that has a schematic shown in
Fig. 2. The DH parameters according to the configuration of the SCARA are
presented in Table 1.
Considering Table 1 and Fig. 2, the forward kinematic equations are obtained as
follows:

x ¼ l2 cðh1 þ h2 Þ þ l1 ch1 ð1Þ

y ¼ l2 sðh1 þ h2 Þ þ l1 sh1 ð2Þ

z ¼ h1 þ h 2  d 3 ð3Þ

where cðh1 þ h2 Þ ¼ cosðh1 þ h2 Þ; sðh1 þ h2 Þ ¼ sinðh1 þ h2 Þ; sðh1 Þ ¼ sinðh1 Þ;


cðh1 Þ ¼ cosðh1 Þ
Design and Control Automatic Chess-Playing Robot Arm 487

Fig. 2 Kinematic diagram l1 l2


with geometric configuration
[2] Z1 Y1
X1 X2

h2
Y2
Z2

d3
X3

h1
Y0 Y3
Z0 Z3
X0

Table 1 DH parameters Link ai (mm) αi (°) θi (°) di (mm)


1 l1 0 h1 h1 þ h2
2 l2 180 h2 0
3 0 0 0 d3

And the inverse kinematics is calculated as follow:

d3 ¼ h 1 þ h2  z ð4Þ
 
ðx2 þ y2 Þ  ðl21 þ l22 Þ
h2 ¼  arccos ð5Þ
2  l1  l2
0 1 0 1
B x þy þ l21
 2  y  l1
2 2
l22 C B C
h1 ¼ arcsin@qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiA  arccos@qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiA ð6Þ
2 2 2 2
ð2xl1 Þ þ ð2yl1 Þ ð2xl1 Þ þ ð2yl1 Þ

where 130  h1  130 ; 160  h2  160 ; d3 : 0  250 mm

2.2 Robot Arm Design

Figure 3 describes that link I is driven by motor I through a closed coupling I, link
II is driven by motor II which is connected with link I by a closed coupling II.
Motor III controls the height position of the end-effector through a mixed trans-
mission between ball screw and timing belt. Figure 4 shows the 3D design of the
robot arm and Fig. 5 shows the gripper designed by SolidWorks.
488 N.D. Anh et al.

1. Motor I
3 4 5 6 7 8
2. Closed coupling I
n2 3. Link I
9
4. Closed coupling II
2
5. Motor II
10 6. Motor III
1 7. Link II
n3
8. Ball screw
n1
9.Timing belt trans-
mission
10. End-effector

Fig. 3 Schematic diagram of chess-playing robot arm

Fig. 4 3D design of the robot arm. 1 Base; 2 Link 1; 3 Link 2; 4 Link 3

Fig. 5 3D design of the gripper


Design and Control Automatic Chess-Playing Robot Arm 489

3 Algorithm for Detecting Chess Moves

Logitech C170 webcam was used to perceive the chess moves (Fig. 6) and con-
nected with the computer via USB port. The process (Fig. 7) began with camera
calibration to ensure the precision of capturing pictures, then, a picture of an empty
chessboard (chessboard without chess piece) was taken. After every chess move,
camera will capture an image and execute image subtraction to determine if the
chess piece was presented on each chess cell.
Pre-processing Image:
Two steps of pre-processing: Crop (Fig. 8) and Grayscale (Fig. 9) were executed to
improve image’s quality. Chess board is a square, but the image taken by camera is
in rectangular shape, therefore, unnecessary parts must be cropped to focus on 64
squares of the chessboard. In addition, images taken by camera are in RGB scale so
they have three different layers that will complicate the process, so, converting
those images into Grayscale which has only one layer is necessary (Fig. 10).

Fig. 6 Webcam C170 used in


experiment

Fig. 7 Detecting chess move Taking picture after each


diagram chess move

Pre-processing Image

Image Subtraction

Compare with Threshold

Divide into 64 squares

Determine
chessboard matrix

Output chess move


490 N.D. Anh et al.

Fig. 8 Cropped image in RGB scale

Fig. 9 Image in gray scale format

Fig. 10 Image taken after opponent’s move

3.1 Image Subtraction

This method was applied to find differences between two input pictures. After
subtraction, pixel value will be compared with threshold, the position of each chess
piece will be shown in a Binary picture (Fig. 11).
Design and Control Automatic Chess-Playing Robot Arm 491

Fig. 11 Binary image after subtraction

3.2 Determine Chessboard Matrix

Based on the results of Binary Image, a 8 × 8 chess board matrix will be created
respectively with 8 × 8 chess board, and chess cells that chess piece is standing on
will have a value of “1”, otherwise, the value is “0” [1] (Figs. 12 and 13).
Information combined from two matrices (before and after opponent’s move),
the chess move will be determined easily by a “delta matrix” (Fig. 14). In “Delta
matrix”, “−1” element describes the chess move beginning point, “1” element
describes the chess move ending point. Then, we compare the matrix with chess
board notation in Fig. 15 to record the move.
After image processing, the chess programming on computer will calculate and
compute chess move to response to the opponent. Chess programming uses a
library containing: opening moves and sample moves [3]. In addition, the program

Fig. 12 Chess board matrix before opponent’s move

Fig. 13 Chess board matrix after opponent’s move


492 N.D. Anh et al.

Fig. 14 Delta matrix after chess move

Fig. 15 Chess board notation

applied Min-max and Alpha-beta algorithm to choose the best move from all
possible moves [4]. The selected move will be sent to the microcontroller to control
robot arm grip and drop chess pieces on the real chessboard.

4 Control System

Control system diagram was shown in Fig. 16. Microcontroller receives chess
moves sent from PC via RS232, processes and control motors. Positions of motor
will response to microcontroller by encoder. Working range of robot arm was
limited by limit switches.
When design the control system, it was necessary to select the appropriate
actuators. In this case, DC servo motors were chosen because of its high accuracy
and easy control. The system needs a position control algorithm in order to help the
robot arm reach correct position. Because the motor’s parameters are not enough for
the simulation, PID algorithm with the Zeigler–Nichols II method using feedback
signal from encoder was applied to calculate and create the PWM signal to control
the position of the motor’s angle. When the system is turned on, it is necessary to
initialize PID parameters, enable microcontroller’s interrupt and move the robot
arm to “HOME” position in order to reset the encoder. Then, the system returns to
waiting state, waiting for the process enable bit in RS232 interrupt. When the
computer sends a process statement to microcontroller, the process is enabled, the
arm reaches each position from start to end in sequence through PID position
algorithm subroutine.
Design and Control Automatic Chess-Playing Robot Arm 493

Camera Limit switch

RS232 Microcontroller 5V power source


STM32F407 for microcontroller

24V power source


Driver AC Source
for motor

Motor

5V power source
Encoder
for encoder

Fig. 16 Control system block diagram

5 Experiment and Results

5.1 Robot Arm

According to the 3D design, authors manufactured entire robot arm and the gripper
to test the operating of system in real match. Robot’s material is Acrylic plastic
PMMA (Figs. 17 and 18).

Fig. 17 Experimental setup

Fig. 18 Gripper of robot arm


494 N.D. Anh et al.

Fig. 19 Robot model in


Mathlab

5.2 Trajectory Simulation Processing

The Figs. 19 and 20 show the straight trajectory of robot end-effector when pro-
cessing a move the Knight from B8 (261;−120;0) to C6 (357;−72;0) using
MATHLAB simulation. The move started from stand by position (24;185;250).

Fig. 20 End-effector’s trajectory


Design and Control Automatic Chess-Playing Robot Arm 495

Fig. 21 Image process interface designed by Visual Studio

5.3 Image Processing

In Fig. 21, there are three images, the first is empty chess board’s image, the next
two images are the chess board before and after opponent’s move. It can be seen
from the picture, white pawn was moved from E2 to E4 and the result of process is
written in the textbox. Image processing’s accuracy is secured if we provide low
noise lighting condition and place chess pieces within square area.

5.4 Testing System in Real Chess Match

The system include: standard FIDE chessboard, camera, robot manipulator, pro-
grams on computer. To secure lighting condition, an additional lamp was used and
placed above the chessboard (Fig. 17). Five chess games versus five different
random opponents were held and the results were shown in Table 2.
Gripper’s errors include impact between gripper and different chess pieces when
moving as well as the opening distance of gripper is not wide enough to release
chess piece. The position accuracy of robot arm is based on how it put chessmen
right in the square on the chessboard. If the footprint intersects with the borderline,

Table 2 Results of five matches


Match Result Total Total Causes of error moves
no. moves error Position Gripper Gripper do not
executed moves error of impact release chess
robot arm chess piece piece
Sum 159 8 2 5 1
Percentage (%) 5.03 1.26 3.14 0.63
496 N.D. Anh et al.

it will be known as error. Otherwise, if the footprint’s center and the center of
chessboard’s square are not coincident, it will be acceptable.

5.5 Assess the Result

After five matches, it can be seen that the working of system is stable, follow the
setting sequence: taking picture, image processing, choosing best move and moving
chess pieces on physical chessboard. There is no failure when system process
images and transmit data, however, the match will stop if the gripper do not release
chessman or chess piece was not placed inside chess cell. Accuracy of moving
chess pieces decrease after every move because of robot’s repeatability error and
vibration of the gripper when moving. These make error happened easily when
matches last longer than 30 moves.

6 Conclusion

The paper gives an overview of an automatic chess-playing robot which consists of


three main modules. The system was experimented with human opponents in real
matches and the results were really positive (high accuracy percentage, stable, etc.
…). The robot arm can be used for research, educational purpose and entertainment.
Module design makes it easy to be developed (both hardware and software) and
able to compete in rapid and blitz chess game. The paper also help authors get the
basic experience to expand their research on developing an autonomous system in
industry combining image processing and artificial intelligence for making deci-
sions. This opens up new opportunities to apply it to industrial applications where
the system can be improved to adapt to the changes of the objects that it’s currently
working on. Making it a highly automated system that is capable of taking the
appropriate action in most cases without human intervention.

References

1. Arda M, Kuşçu H, Öztürk E (2013) Obtain chess moves with image processing. In: Proceeding
of the Unitech Grabovo international scientific conference
2. Quoc LH (2005) Kỹ thuật người máy Phần 1: Robot công nghiệp. Vietnam National University
Publisher, Ho Chi Minh City
3. Tan NN, Quoc NX (2010) Thiết kế chương trình chơi cờ vua. Graduate thesis, Cao Thang
College
4. Khac VV, Cuong LBQ (2013) Robot chơi cờ tướng. Gaduate thesis, HCM City University of
Technology

You might also like