Ping-pong player prototype

9
IEEE Robotics & Automation Magazine DECEMBER 2003 44 M ost of the Ping-Pong robotic systems on the market consist of a machine capable of sending balls with a given frequency, velocity, and spin to the human player; no real game is estab- lished between the player and the robot. There have been several attempts to develop Ping-Pong player robots. In most of them, the performance measured was poor. The success rate of striking an incoming ball in some of these prototypes is around 50%. In this article, a low-cost robot capable of playing Ping-Pong against a human opponent is presented. The article begins with a general description of the prototype. In the subse- quent sections, the three main subsystems of the robot are described: the vision system, the mechanical structure, and the control system. Previous Prototypes Toshiba in Japan built a seven-degree-of-freedom (7-DOF) articulated robot for the purpose of playing Ping-Pong. Each of its joints has its own controller (Motorola MC68020). The vision system consists of two charged coupled device (CCD) cameras. The robot is prepared to play against a wall and is able to return the ball up to four consecutive times [1]. Rus- sell Anderson of Bell Laboratories developed a Ping-Pong player robot as the culmination of a series of projects of Bell Laboratories. The mechanical part of the robot is composed of a commercial robot arm (PUMA 260). The position of the ball is calculated using the information collected by four video cameras. The control of the system is programmed in Motorola MC68020 processors [2]. The Swiss Federal Insti- tute of Technology built a Ping-Pong player robot consisting of a 3-DOF mechanical arm and a 3-DOF wrist. The senso- ry system consists of a stereoscopic vision system (two cam- eras). The control of the system is implemented using several Motorola MC68020 and MC68000 microprocessors [3]. The most recent Ping-Pong robot was built in the University of Wollon- gong. It is a 2-DOF cartesian mecha- nism that moves a bat. The bat has also two-revolution DOF to provide the orientation. The robot and its two cameras are controlled by a network of transputers to speed up the overall system operation [4]. System Configuration The presented prototype system has a 3-D vision system that uses only one camera and one acquisition module. The vision system is based on the detection of the ball and the shadow it casts over the table. This procedure presents a great simplicity with respect to stereoscopic vision systems that use two cam- eras, because it has only one acquisition module and, conse- quently, only one image to process. Processing is accomplished using an IBM PC-compatible computer with real-time processing of 25 images per second. The processing and segmentation of the image algorithms have been specially optimized using low-level programming and the Multimedia Extension System (MMX) instructions of the Intel micro- processors. This allows parallel processing of the image. The robot has two bats joined to a 2-DOF structure. Each bat has three additional DOF that allow the robot to send the A PC-Based, Low-Cost, Ping-Pong Robot © PHOTODISC BY L. ACOSTA, J.J. RODRIGO, JUAN A. MÉNDEZ, G.N. MARICHAL, AND M. SIGUT 1070-9932/03/$17.00©2003 IEEE

Transcript of Ping-pong player prototype

IEEE Robotics & Automation Magazine DECEMBER 200344

Most of the Ping-Pong robotic systems on themarket consist of a machine capable of sendingballs with a given frequency, velocity, and spinto the human player; no real game is estab-lished between the player and the robot. There

have been several attempts to develop Ping-Pong player robots.In most of them, the performancemeasured was poor. The success rate ofstriking an incoming ball in some ofthese prototypes is around 50%.

In this article, a low-cost robotcapable of playing Ping-Pongagainst a human opponent is presented. The article beginswith a general description of the prototype. In the subse-quent sections, the three main subsystems of the robot aredescribed: the vision system, the mechanical structure, andthe control system.

Previous PrototypesToshiba in Japan built a seven-degree-of-freedom (7-DOF)articulated robot for the purpose of playing Ping-Pong. Eachof its joints has its own controller (Motorola MC68020). Thevision system consists of two charged coupled device (CCD)cameras. The robot is prepared to play against a wall and isable to return the ball up to four consecutive times [1]. Rus-sell Anderson of Bell Laboratories developed a Ping-Pongplayer robot as the culmination of a series of projects of BellLaboratories. The mechanical part of the robot is composedof a commercial robot arm (PUMA 260). The position ofthe ball is calculated using the information collected by fourvideo cameras. The control of the system is programmed in

Motorola MC68020 processors [2]. The Swiss Federal Insti-tute of Technology built a Ping-Pong player robot consistingof a 3-DOF mechanical arm and a 3-DOF wrist. The senso-ry system consists of a stereoscopic vision system (two cam-eras). The control of the system is implemented using severalMotorola MC68020 and MC68000 microprocessors [3]. The

most recent Ping-Pong robot wasbuilt in the University of Wollon-gong. It is a 2-DOF cartesian mecha-nism that moves a bat. The bat hasalso two-revolution DOF to providethe orientation. The robot and its

two cameras are controlled by a network of transputers tospeed up the overall system operation [4].

System ConfigurationThe presented prototype system has a 3-D vision system thatuses only one camera and one acquisition module. The visionsystem is based on the detection of the ball and the shadow itcasts over the table. This procedure presents a great simplicitywith respect to stereoscopic vision systems that use two cam-eras, because it has only one acquisition module and, conse-quently, only one image to process. Processing isaccomplished using an IBM PC-compatible computer withreal-time processing of 25 images per second. The processingand segmentation of the image algorithms have been speciallyoptimized using low-level programming and the MultimediaExtension System (MMX) instructions of the Intel micro-processors. This allows parallel processing of the image.

The robot has two bats joined to a 2-DOF structure. Eachbat has three additional DOF that allow the robot to send the

A PC-Based, Low-Cost,Ping-Pong Robot

© PHOTODISC

BY L. ACOSTA, J.J. RODRIGO, JUAN A. MÉNDEZ, G.N. MARICHAL,

AND M. SIGUT

1070-9932/03/$17.00©2003 IEEE

ball to the desired point on the table. To achieve this, therobot uses a sensory system based on a video camera and acontrol system implemented in a PC computer. With con-trolled conditions (velocity below 5 m/s and small spin), theprototype presented here is able to return incoming balls witha success rate near 90%.

Another aspect of the prototype system that differentiates it from the rest of similar systems is that it is a low-cost prototype. Most of the components are standard and can befound in the market (PC computer, acquisition card, etc.).Moreover, the mechanical structure of the robot arm has beenconstructed using nonindustrial components. The cost reduc-tion of this prototype when compared with the ones men-tioned above can go beyond the 10:1 factor.

The mechanical structure of the robot is shown in Figure1: the table, the video camera with its support, and the robotthat is built on two rails. These rails allow the lateral displace-ment of the bats. Observe that the dimensions of the robotbats are similar to the ones of a Ping-Pong standard bat. Thelight focus placed just over the table (not displayed in the fig-ure) is an important element for the operation of the system.

The system can be subdivided into three independentthough interconnected modules, as shown in Figure 2.

◆ Vision System: This is the robot sensory system, whichallows one to see the ball and its shadow. This subsystemconsists of a CCD camera, an image-acquisition system,and a series of information-processing algorithms.

◆ Mechanical Structure: The mechanical structure consistsof a robot arm that hits the ball. This robot arm has apair of bats, similar to a Ping-Pong racquet. Everyrobot axis is controlled in order to move it to thedesired position.

◆ Control System: This subsystem receives sensory infor-mation from the vision system, processes data, andmoves the robot to the right position to hit the ball. Itis also responsible for the game strategy developed bythe robot. This is achieved by controlling the orienta-tion of the bat when hitting the ball.

Vision SystemThe task of the vision system is to estimate the ball position ateach instant and to predict the future trajectory for the ball.The robot uses this information to hit the ball and play agame with the opponent [5].

Usually, when the coordinates of an object in the spacemust be calculated, stereoscopic vision is used. This consists ofsetting two cameras separated by a certain distance betweenthemselves in order to obtain two different images of the sameobject. Thus, the object’s real position can be mathematicallycalculated. To implement this system, two image-acquisitionsystems are necessary. Furthermore, an external synchronismmechanism is provided so that both cameras capture theimages in the same instant. As an alternative solution tostereoscopic vision, the robot proposed here uses a monocam-era scheme with only one acquisition system. The algorithmemployed is based on the detection of the ball and the shadow

it projects on the table. These two points are used as refer-ences to compute the spatial coordinates of the ball by meansof triangulation. To do that, the available information consistsof the coordinates of the ball and the shadow in the image(actually, the image pixels where they are located). From thisinformation, the spatial coordinates of the ball are estimated.

Hardware ComponentsThe hardware for image acquisition consists of a small colorCCD video camera with phase alternating line (PAL) videooutput and a resolution of 768 × 576 pixels in two fieldslocated in a known place over the table. The acquisition isdone by means of a standard image-acquisition card basedon the chip BT878. This card provides great flexibilitywhen designing the capture algorithms because it is possibleto separate the different color components of the image inthree independent memory buffers. These images are cap-tured and copied to a specified address at the main memory.In this way, they are accessible to the rest of the routines ofthe vision system.

The BT878 chip of the acquisition board supplies theimage information decomposed into luminance (Y) andtwo chrominance components (U and V). This information

DECEMBER 2003 IEEE Robotics & Automation Magazine 45

Video Camera

Bat

Ball

Shadow

Figure 1. Robot physical structure and game space.

ControlSystem

MechanicalStructure

Ping-PongGame

VisionSystem

Figure 2. Subsystems of the ping-pong player.

is translated into red-green-blue (RGB) colors. From theRGB representation, a conversion to intensity, hue, andsaturation (IHS) is performed [6]. Thus, the pixels compari-son to detect the ball can be carried out using the H and Scomponents.

The sampling rate is fixed at 25 frames per second (f/s).The reason for this rate is that the first prototype was imple-mented in a Pentium 166 MMX, and higher rates were diffi-cult to obtain. To evaluate the computational effort neededto implement the algorithm to estimate the ball location,several considerations should be made. First, the algorithmworks with data stored in main memory, so there is no dataflow between secondary storage elements and main memory.Furthermore, the algorithm is running in high-priorityprocesses, and no other application is active when runningthe algorithm. With this, it can be assured that the bottle-neck in the implementation of these routines is the computa-tional time of the algor ithm. Thus, with advancedprocessors, it is possible to achieve a sampling rate of 50 f/seasily. On the other hand, high-velocity cameras couldincrease the performance of the system but assume a highercost of the prototype.

Correction of Lens DeformationAs a first step for the computation of the spatial coordinates ofthe ball, it is necessary to correct the lens deformation toobtain a “flat” image. To do this, a neural network (NN) isused to obtain the mapping between the coordinates of theoriginal image and the flat image. The NN used is a multilay-er perceptron with three layers. The number of neurons inthe hidden layer is ten, the learning rate chosen is 0.16, andthe momentum is 0.7. The NN was trained with a backprop-agation algorithm. The input to the NN are the coordinatesof the original image, while the output are the coordinates inthe flat image. To train the network, a calibration pattern wasgenerated consisting of a grid of equidistant points. The NNwas trained so that when the points of the distorted image areentered in the NN, the output is the original pattern withoutdistortion. The training of the NN consisted of 200,000 itera-tions with 60 different points. The final error obtained wassmaller than 0.5%.

Ball and Shadow IdentificationOnce the image is captured and located on a memory buffer(divided into its I, H, and S components), a search algorithmover the 384 × 288 pixels is used to locate the ball. The loca-tion of the ball is based on the fact that the color of the ball isdifferent from the color of the environment (red or blue ball).The robot is operating in a light-controlled environment. Asmentioned previously, there is a light focus located at a pre-fixed position over the table. The light focus produces theshadow used to detect the spatial coordinates of the ball. Inthese conditions, the image quality is high enough to avoidproblems in the segmentation process.

The segmentation of the image was divided into two sub-processes: color concordance and ball search.

Color ConcordanceTo identify pixels that may belong to the ball, color thresholdtechniques are employed. Those pixels in a range of coloraround the ball’s color are marked. This search is done com-paring the value of the H and S for each pixel with the thresh-old values specified. This process is computationally verydemanding because it is necessary to go through the 110592(384 × 288) pixels of the image. This routine has been com-pletely coded in assembly language using the extended regis-ters of the Pentium II processor of Intel (32-b register) and theMMX extensions. The MMX is a set of 57 instructionsdesigned to handle multimedia applications. It is implementedas part of the CPU of the new microprocessors. Differentcomparisons have been made, and it can be inferred that theMMX optimized algorithm is 3.3 times faster than its equiva-lent in high-level C language without MMX optimization.

Ball SearchThe marked pixels are grouped into objects using the well-known Rosenfeld and Kak algorithm [7]. This algorithmstarts with two consecutive pixels, C i-1 and C i, belonging tothe perimeter of the object. Then a clockwise search of thenext marked pixel around the pixel C i is done. The startingpoint of this search is the previous pixel C i-1. With the appli-cation of this procedure, the perimeter of all the objects witha color similar to the ball’s color is obtained. To avoid noisepixels caused by objects with the same color as the ball, thoseobjects smaller than a given size are rejected. On the otherhand, the robot works with a composite video signal. Hence,the salt-and-pepper noise, typical of radio frequency signalswith small signal/noise rate, is negligible.

For each detected object, its size and roundness factor(defined as perimeter2/area) are calculated. The object identi-fied as the ball is that with the roundness factor closer to 4π .The coordinates of the ball are obtained by calculating thecenter of gravity of this object.

The shadow location algorithm is similar to the one of theball location. In this case, to reduce the computational time,the search region is constrained to a cone in the table andunder the ball.

Estimation of Ball CoordinatesThe preceding algorithm for the ball and shadow locationreturns the ball (ub, vb ) and shadow location (us, v s ) into theimage. The procedure to compute the spatial coordinates ofthe ball is as follows:

◆ calculation of the shadow coordinates◆ computation of the spatial coordinates of the ball.Before describing this process in detail, the following nota-

tions are introduced:(xb, yb, zb ): spatial coordinates of the ball in the game area(xs, ys, zs ): spatial coordinates of the shadow in the game area(x l, y l, zl): spatial coordinates of the light focus in the

game area(xc , yc , zc ): spatial coordinates of the camera in the game

area

IEEE Robotics & Automation Magazine DECEMBER 200346

(ub, vb ): coordinates of the ball in the image(us, v s ): coordinates of the ball’s shadow in the image(u f , v f , w f ): coordinates of the focus of the camera.

Calculation of the Shadow CoordinatesThe shadow has a constant and known zs as it is projectedover the table (see Figure 3). Then it is only necessary to cal-culate its (xs, ys ) coordinates. The information available is theposition of the shadow into the image (us, v s ). To solve thisproblem, a feedforward multilayer NN is used. The NNreceives (us, v s ) as inputs and provides the spatial coordinatesof the shadow (xs, ys ) as outputs. The NN has three layers,with eight neurons in the hidden layer. The learning rate is0.12, and the momentum is 0.7. The training algorithm is abackpropagation algorithm, and the training pairs are generat-ed from known points of the table. The error of the shadowcoordinates (xs, ys, zs ) provided by the NN is less than 5%.

Computation of the Spatial Coordinates of the BallAt this point, the real coordinates of the shadow (xs, ys, zs ),the position of the camera (xc , yc , zc ), and the light focus(x l, y l, zl) are known. It is important to take into accountthat two different reference systems have been used in theprevious computations. One reference system is on the table(X, Y, Z). Another reference system (U, V, W) is located inthe image plane of the camera (U, V). As the camera has afixed position, however, it is possible to convert the coordi-nates from one system to another.

The idea for calculating the ball’s coordinates is that theball is in the point of intersection between two straight lines.The first straight line is the one defined by points (xs, ys, zs )and (x l, y l, zl) (see Figure 3). The second straight line isdefined by the points’ coordinates (u f , v f , w f ) and (ub, vb , 0),both referred to the reference system (X, Y, Z). These straightlines have a unique intersection point. To obtain the coordi-nates of the ball, it is only necessary to solve a system of fourequations (with rank 3) and three unknowns (xb, yb, zb ).

Mechanical StructureThe chosen solution for building the robot consisted of astructure with a body, as shown in Figure 4, and a wrist wherethe bat is joined. The body consists of one prismatic articula-tion (d1) and a revolution one (θ2). The wrist has 2 DOF (θ3

and θ4) and one prismatic articulation to hit the ball (d5).

Displacement (d1) and Revolution (θ2) JointsThe displacement of the structure is achieved by using adc motor with a driving belt where the structure is cou-pled (see Figure 4). The angle displacement in θ2 is easilyimplemented by means of a dc motor joined in the middleof the bat structure.

Lateral Rotation Joint (θ3)Each one of the bats has an independent lateral rotation. Eachone has a microservo placed on the back and holds on to thecarbon tube, as shown in Figure 5. The bats are held on to the

DECEMBER 2003 IEEE Robotics & Automation Magazine 47

Video Camera (xc, yc, zc)Light Focus

(xl, yl, zl)

Ball (xb, yb, zb)

Shadow (xs, ys, zs)Z

Y

X

(us, vs)

(ub, vb)

(uf, vf, wf)

UW

V

Figure 3. Spatial and image coordinates of ball and shadow.

Up-DownRotationServo

Figure 5. Mechanism of the bats’ lateral rotation.

d5

d1

θ3

θ2

θ4

Figure 4. Structure of the ping-pong robot body.

carbon tube by means of a hinge that only allows the lateralmovement of the bat, which is controlled by the microservo.

Up-Down Rotation Joint (θ4)The up-down rotation movement is accomplished using aservo. This servo rotates the carbon stick where the bats areattached. This stick is held on to the structure by means oftwo bearings. Figure 6 shows this joint.

Beating Joint (d5)A servo is responsible for the “hit-the-ball” movement. Thespatial precision in the movement is not critical. The tempo-rary precision to synchronize the movement with the impactof the ball over the bat is very important, however. Thismovement must begin some tenths of a second earlier. In theprototype developed, the intensity of the shot has been takenconstant for every incoming ball. To return the ball to thedesired position on the table, the variables θ3 and θ4 are con-trolled. In Figure 7, the beating articulation is shown.

Controlling the StructureThe task of this system is to be able to play with a humanopponent. The main rule is that the robot must hit the ball sothat it bounces on the table. Depending on the orientation ofthe bat, the robot would be able to place the ball in thedesired position. This control system is implemented bymeans of two different control levels: low-level control (d1

and θ2) and expert control (θ3, and θ4).

Low-Level ControlThe objective of this subsystem is to place the bat in the cor-rect position and to activate the servo to hit the ball. Thecoordinates of the ball in the bat plane is the target position forthe bat (d1ref and θ2ref). The control problem is to place thecenter of the bat in these coordinates to intercept the ball. Themanipulated variables to move the bat are u1 and u2, whoseassociated output variables are d1 and θ2, respectively (see Fig-ure 4). These manipulated variables represent the force and thetorque applied on the corresponding dc motors. To estimatethe point (d1ref, θ2ref), a prediction of the trajectory that theball follows is done. For this prediction, it is necessary to calcu-late, at least, the position of the ball in two different instants.

The ball trajectory has been modeled using the parabolicthrow formulas, adding one term corresponding to the fric-tion of the ball with the air (friction force = µ∗velocity2, µisthe viscous friction coefficient). µ has been obtained empiri-cally from real-time trajectories, and the mean value obtainedis µ = 0.0014.

To move the bat to (d1ref and θ2ref), a predictive controller isused (see Figure 8). To design the controller, the system is mod-eled as a two-link robot arm. The first joint is prismatic, and thesecond is a revolutionary one (see Figure 9). This method uses alinearization of the model around the desired (or nominal) tra-jectory for the arm. The torque applied to the link has two con-tributions: a direct contribution, calculated from the inversedynamics equations; and a feedback contribution, where a linear

IEEE Robotics & Automation Magazine DECEMBER 200348

Lateral Rotation Servo

Figure 6. Up-down rotation of the bats.

(a)

(b)

Beating Servo

Beating Servo

Figure 7. Beating articulation.

controller, using the linearized model of the plant, tries to cor-rect the deviations from the nominal trajectory. The nonlinearcontrol problem of the robot arm is then reduced to a linearcontrol problem with respect to a nominal trajectory [9].

Then, the command applied to the system is given by

uk = UN,k + δuk. (1)

The input to the system uk = [u1k u2k]T are the appliedtorques to the system, and δuk are the deviations with respectto the nominal torque UN,k . These nominal torques arecomputed using the inverse dynamics equations (by using theNewton-Euler recursive algorithm), and they are the com-mands needed to reach the next point of the planned trajec-tory (nominal). This linear approximation is valid for thetrajectory deviations with respect to the nominal one,obtained by means of a trajectory planner. δuk are the feed-back torques computed by the predictive control algorithm.This algorithm uses a linear model of the system. To get thelinearized model of the Ping-Pong robot arm, the followinglocal linearization at each time instant is computed as

δxk+1 = A δxk + B δuk (2)

where x = [d1 θ2]T is the state of the system. With thismodel, a predictive controller with interpolation is used tocompute the feedback command contribution δu. The tech-nique consists of doing an interpolation between the optimalsolution and a solution with guarantee of feasibility (alwayssatisfies the constraints) as follows:

δu = (1 − α) · uLQ + α · ufeasible, 0 ≤ α ≤ 1. (3)

The value α is computed doing a minimizationwith respect to δ u of the cost function

T =∞∑

k=0

(δx t

kQδ xk + δu tkRδ uk

)(4)

with constraints |uk| ≤ umax.

In Figure 10, the real-time evolution of d1 andθ2 can be seen during a game. Observe the correc-tions in the desired trajectory (dashed line) as moreinformation is processed.

Expert Control:Game Strategy PlanningEvery time the robot hits the ball, the expertmodule determines the target point on the tablewhere the ball bounces. A bat-orientation sub-module calculates the torques u3 and u4 (whichproduces the change in θ3 and θ4) that place theball in the target point. To estimate the trajectoryafter the impact, it has been assumed that theenergy loss after the impact is about 30%. Withthis, and considering the rule of the reflectionangles, an estimation of the trajectory of the ball

DECEMBER 2003 IEEE Robotics & Automation Magazine 49

TrajectoryPlanning

InverseDynamics

Control

Perturbations

Robot Arm

LinearController

xNk UNk uk xk

δuk

δxk

Figure 8. Adaptive perturbation controller.

d1

θ2

Figure 9. Modeling of the ping-pong robot arm.

Figure 10. Response of the system between two successive hits (solidline: displacement d1 and angle θ2; dashed line: desired trajectory).

d1(m

)T

heta

2 (D

egre

es)

0.8

0.6

0.4

0.20.2 10

10

0

−10

−20

Time (s)

0.2 10

Time (s)

Ball Hit

Ball Hit

can be obtained. The energy loss factor is a variable that theexpert module corrects during the game.

The strategy used in the game determines the desiredreturn point for the ball. The constraint that should be takeninto account is that the ball must bounce on the table. Therobot receives information of the game and changes strategyaccording to this information and to the history of the game(see Figure 11). The problem is to define a game strategy sothat the performance of the robot increases by means of theacquired experience [10].

In order to choose the target point, the expert modulecombines two facts. First, the ball return reliability is consid-ered. It is assumed that, with respect to the perpendiculardirection of the bat, the return angle of the ball is the same asthe angle of incidence. This assumption is corrected, takinginto account the following results: the greater the incidenceangle or the velocity of the ball, the greater the expectederror in the return angle. The reason for this is that when thetangential velocity increases, the sliding of the ball is greater,thus increasing the error in the return angle. It can bedefined as a reliability as

R(θ) ={

cos(aθv), if |aθv| < π/20, otherwise

(5)

where ν is the velocity module, θ is the angle of incidence ofthe ball with respect to the perpendicular direction of the bat,and a is a parameter that defines the width of the angle inter-val with reliability bigger than zero. This interval is called thereliability interval. Initially, a is 0.3, so that return angles high-er than 60º for balls at 5 m/s have nearly zero reliability.

The second fact taken into account to determine the targetpoint is that each point on the table has a priority degree. Forthis, N regions are defined consisting of rectangles, Z i , dis-tributed along the table and not overlapped. The priority Pi

of each Z i zone is fixed according to the game strategy. Inorder to decide what zone the ball is returned to, the algo-rithm tries those zones with higher Pi . Initially, the Z i zoneswith higher priority are the ones in the center of the table. Inthis way, the robot starts playing with a more secure strategy(see Figure 12).

The procedure to decide where to send the ball combinesthe reliability index with the priority. Once the direction, thevelocity, and the reception point (d1ref, θ2ref) are known, thereliability interval is calculated. Then, the set J of all the Z i

zones, whose center is into the reliability interval, is obtained as

J = {Z i, i ∈ 1, . . . , N |R(θ i) > 0} (6)

where θ i is the return angle for the center of theith zone. A new variable called reliability conve-nience, Q i , is defined to combine both the relia-bility and the priority of each zone. The Q i isobtained as the product of the normalized priorityand the reliability of the Z i zone center

Q i = Pi

P JR(θ i)∀ i ∈ J (7)

where PJ = ∑i∈ J Pi . The zone that is taken as

the target zone, k, is that with the maximum valuefor the sum of Q i plus a random value pi takenfrom a Cauchy distribution

k = arg maxi∈ J

{Q i + pi}. (8)

The reason for this random term is to allow therobot to occasionally send the ball to an unpre-dictable zone (but always with reliability biggerthan zero). The target point is the center of theresulting k zone.

According to the experience, the robot will self-adjust the parameters of the game through theexpert module. Thus, an opponent fails when theball bounce in the zone Z i produces an increase inthe priority degree of that zone. The differencebetween the real bounce point and the predictedone is used to correct the energy loss percentage andthe parameter a. Also, if the score is unsatisfactoryfor the robot, adaptive modification of the gamestrategy is done. In this case, the reliability interval isaugmented and the convenience degree of the zones

IEEE Robotics & Automation Magazine DECEMBER 200350

Figure 11. General structure of the expert module subsystem.

Figure 12. Convenience degree, Vi, of the Zi areas: (a) Initial configuration(Vi is higher in the center of the table). (b) Modification of Vi when playingwith an opponent with problems with the backhand return (Vi is higher inthe right side). (c) Aggressive game (Vi is higher close to the edges).

Real-TimeImages

Velocity andIncidenceAngle Bat

OrientationModule

U3

U4Ping-Pong

Robot

Energy Loss FactorTarget Point

ExpertModule

ScoreUpdate

Score

VisionSystem

(Xb, Yb, Zb)

Con

veni

ence

Deg

ree +

− (a) (b) (c)

close to the edges of the table is increased, thusresulting in a more aggressive game (Figure 12). Thescore of the game is monitored through an inspec-tion of the ball coordinates’ evolution, The flow-chart in Figure 13 shows the score update process.

Playing a Real GameA prototype capable of playing with a humanopponent has been built (http://www.pingpong.cyc.ull.es). The performance of the robot has beenevaluated in a real game against human opponents.It is worth pointing out some interesting results.The prototype is capable of returning balls with asuccess rate near 90% when playing under con-trolled conditions. These conditions are ball veloci-ty below 5 m/s and small spin effects. There arethree main causes that produce a failure in thereturn of the ball:

◆ When the velocity is higher than 15 m/s,and assuming a frame sampling of 25 f/s,the computer is unable to capture andprocess two images and, consequently, aprediction of the trajectory is not available.Also, for high-velocity balls, the structurehas more difficulty reaching the intercep-tion point on time.

◆ An error in the time instant when the beat-ing joint is activated produces a trajectorydifferent than that predicted. This may bethe cause for an unsuccessful return.

◆ If the ball goes out of the camera vision,then the probability to intercept the ball isvery low. This occurs when the opponenthits the ball with excessive force.

The objective of the proposed experiments is toestimate the rate of successful return balls in areal game. The return is considered successfulwhen the robot hits the ball and places it on thetable. Obviously, this probability depends on thehuman player level. Ten exper iments withhobby player opponents have been made. Theexperiment to compute the percentage of suc-cessful balls is as follows:

◆ P experiments are carried out.◆ For each experiment i, the number of balls returned by

the robot until it fails is stored (N i).◆ The percentage of successful returned balls is computed

as

S =

P∑

i=1N i

P∑

i=1N i + P

× 100.

In the experiments carried out, the robot was able to play a gamewith a human opponent with a success rate greater than 80%. InFigure 14, a view of the prototype during a game is shown.

DECEMBER 2003 IEEE Robotics & Automation Magazine 5151

Figure 13. Algorithm for score monitoring.

Robot Return Successful.Estimate Ball Coordinates ofthe Following Frames.

START

Ball Hit

Wait for Ball toReappear in the Image.

Robot ReturnFailed. IncreaseOpponent Score.

Detect the Coordinates (xb, yb)of the Bounce Point.

Predict TrajectoryUsing SuccessiveFrames.Start Low-LevelControl Routines

Robot ReturnFailed. IncreaseOpponent Score

Opponent ReturnFailed. Increase

Robot Score.

Opponent ReturnFailed. Increase

Robot Score

YES

YES

YES

YES

NO

NO

NO

NO

Time Elapsed Since itDisappeared Is Higher

than 100 ms?

Is (xb, yb) into theGame Area?

Change in ybDirection OccuredBefore 150 ms?

Does the BallReach zb = 0?

Figure 14. View of the robot during a game.

ConclusionThis article presented a low-cost Ping-Pong player robot. Theprototype was developed to play against a human opponentusing a vision system to detect the ball. This system has 5 DOFto place the bat in the desired point in the plane of the struc-ture, orientate it in the space, and hit the ball. The prototypehas been designed with lightweight and resistant materials inorder to increase the response time and accurateness of the shot.

One important feature of this system is that it uses onlyone camera to detect the ball, thus reducing the computation-al time and hardware requirements. To detect the location ofthe ball, the robot combines the information about the balland about the shadow it casts on the table. Before the robothits the ball, it makes a prediction of the trajectory that theball follows. This information is sent to the control subsystemand is used to place the bat in the correct position and withthe adequate orientation. This is done through a two-levelcontrol system. The task of the lowest level is to move thecenter of the bat to the right position to intercept the ball.

The expert module control defines the game strategy. Thisis done by orientating the bat in order to return the ball tothe desired position on the table. The performance measuredin the prototype developed was satisfactory in the response ofthe structure and in the percentage of successful shots. Severalexperiments with different human opponents have been per-formed. In these experiments, the success rate in returningballs was greater than 80%. In standard conditions (velocitybelow 5 m/s and no spin), the success rate is near 90%.

AcknowledgmentsThis work was supported by the Comisión Interministerial deCiencia y Tecnología of the Spanish Government under theProject DPI2001-3681.

KeywordsMechatronics, real-time systems, stereovision, control, neuralnetworks.

References[1] J. Hartley, “Toshiba progress towards sensory control in real time,”

Indust. Robot, vol. 14, no 1, pp. 50–52, 1987.[2] R.L. Anderson, A Robot Ping-Pong Player: Experiments in Real Time Con-

trol. Cambridge, MA: MIT Press, 1987.[3] H. Fassler, H.A. Vasteras, and J.W. Zurich, “A robot ping pong player:

Optimized mechanics, high performance 3D vision, and intelligent sen-sor control,” in Robotersysteme. Berlin: Spring-Verlag, 1990, pp. 161–170.

[4] F. Naghdy, J. Wyatt, and S. Tran, “A transputer-based architecture forcontrol of a robot ping pong player,” in Parallel Computing andTransputers. New York: IOS Press, 1993, pp. 311–317.

[5] G.D. Hager, W.-C. Chang, and A.S. Morse, “Robot hand-eye coordi-nation based on estereo vision,” IEEE Control Syst. Mag., vol. 15, pp.30–39, Jan. 1995.

[6] E.R. Davies, Machine Vision. New York: Academic, 1997.[7] A. Rosenfeld and A. Kak, Digital Picture Processing, vol. 1–2. New York:

Academic Press, 1982.[8] L. Sciviacco and B. Siciliano, Modelling and Control of Robot Manipulators.

Berlin: Springer Verlag, 2000.[9] S. Torres, J.A. Méndez, L. Acosta, M. Sigut, G.N. Marichal, and L. Moreno,

“A predictive control algorithm with interpolation for a robot manipulator

with constraints,” in Proc. IEEE Conf. Control Applications, Mexico, 2001, pp.536–541.

[10] K.P. Valavanis and G.N. Saridis, Intelligent Robotic Systems: Theory, Designand Applications. Norwell, MA: Kluwer, 1992.

L. Acosta was born in La Palma, Canary Islands. He is a pro-fessor in systems engineering and automation and dean of theComputer Science Faculty of the University of La Laguna,Spain. In 1994, he received the Best Young Research awardfrom the government of Canary Islands. He is the director ofthe doctoral theses of J.J. Rodrigo, J.A. Méndez, M. Sigut, andG.N. Marichal. His primary areas of research include controlsystems and robotics. He is currently involved in projects relat-ed to the development of an autonomous service robot.

J.J. Rodrigo received the M.S. degree in 1997 in computerscience from the University of La Laguna. He is currently alecturer and researcher in the Department of Fisica Funda-mental y Experimental, Electronica y Sistemas. He combineshis teaching duties in industrial automation and robotics withthe development of his doctoral thesis in robotics. His prima-ry area of research is robotics.

Juan A. Méndez received the M.S. degree in 1992 in appliedphysics and the Ph.D. degree in computer science from the Uni-versity of La Laguna. In 1999, he received the Best YoungResearch award from the government of Canary Islands. He iscurrently a lecturer and researcher in the Department of FisicaFundamental y Experimental, Electronica y Sistemas. He teachescourses of control engineering and robotics. His research interestsare in model predictive control and autonomous robotics.

G.N. Marichal received the Ph.D. degree in computer sciences atLa Laguna University, Spain, in 1999. He is currently an associateprofessor at La Laguna University. His research interests are ingenetic algorithms, neural networks, neuro-fuzzy systems, androbotics. He is a member of the following symposium scientificcommittees: NC2000, ISA2000, NF2002, or ICAIS2002.

M. Sigut was born in Tenerife in 1973. She received a degreein applied physics from the University of La Laguna, Spain, in1996. She is an associate professor in the Department ofPhysics, Electronics and Systems of La Laguna University. Shecombines her teaching duties in control, industrial automation,and robotics with the development of her doctoral thesis relatedto the control of a large-scale structure. Her primary areas ofresearch include control, robotics, and automation. She has par-ticipated in a project financed by the Canarian governmentrelated to the construction of an autonomous robot. At thistime, she is also taking part in another project financed by thecentral government related to robotics applications.

Address for Correspondence: L. Acosta, Computadoras yControl Group, University of La Laguna, Spain. E-mail:[email protected].

IEEE Robotics & Automation Magazine DECEMBER 200352