34
Designing and implementing a skill for shooting at 3D targets for Tech United Eindhoven soccer robots Commissioned by Tech United Eindhoven 2015 Antoine de Bock Coach: Ferry Schoenmakers Supervisor: Ren´ e van de Molengraft TU/e - Mechanical Engineering Eindhoven, October 9, 2015

Designing and implementing a skill for shooting at 3D ... and implementing a skill for shooting at 3D targets for Tech United Eindhoven soccer robots ... The force and velocity vectors

Embed Size (px)

Citation preview

Designing and implementing a skill forshooting at 3D targets for Tech United

Eindhoven soccer robots

Commissioned by Tech United Eindhoven2015

Antoine de Bock

Coach: Ferry Schoenmakers

Supervisor: Rene van de Molengraft

TU/e - Mechanical EngineeringEindhoven, October 9, 2015

Contents

List of symbols 1

1 Introduction 2

2 Theoretical model 42.1 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Ball trajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Control model 6

4 Experiment 1: Ball trajectory 104.1 Measurement equipment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.2 Hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.3 Measurement setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.4 Measurement plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.5 Data acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.6 Result analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.7 Kalman analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

5 Experiment 2: Control model 145.1 Hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.2 Measurement plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.3 Result analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6 Implementation 21

7 Conclusion 24

8 Improvements 25

9 Recommendations 26

A Appendix 1: Matlab scripts 27A.1 Hypothesis experiment 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27A.2 Inverting correlations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2

List of symbols

Quantity symbol Explanation Unit symbol

α0 Initial angle of ball Degrees [◦]C Capacitance Farad [F ]d Horizontal distance Meter [m]D Vertical offset Meter [m]F Force vector Newton [N ]g Gravitational constant Meter per square second [m

s2]

h Height Meter [m]K Kick effort [−]l Distance Meter [m]L Lever setting [−]mb Mass of the ball Kilograms [kg]R Radius Meter [m]t Time [s]T Time period [s]v Velocity vector Meter per second [m

s]

v0 Initial absolute speed of the ball Meter per second [ms

]V Voltage [V ]

1

1 Introduction

The Tech United Eindhoven team was started with an objective: to create a team of soccerrobots that can compete with and beat the human world soccer champions by 2050. Theserobots, called turtles, play a match autonomously. They can see other players and oppo-nents and communicate the location of the ball to each other. They have task managersand strategies and find their own way of putting the ball in the goal.

In this project, the process of inventing, creating and implementing an new skill will bediscussed. The final goal is to have the robot shoot through holes without human interac-tion. To keep things modular and widely employable this goal will be subdivided in threeparts. All three will be discussed and implemented separately .

1) The robots shoot a ball by pushing a lever against it at high speed. The positionwhere this lever hits the ball in vertical direction can be adjusted. A lob shot is thus possi-ble and shooting in 3D is not a completely new thing. The robots can’t, however, aim at aspecific target in space yet. They are set up to aim at the projected position on the field ofthe object. Next, the speed at which the ball is shot can be controlled manually. This feedforward needs to be automated. By conducting experiments, a model between parametersand ball trajectory should be found. This should then be related and implemented on therobot, the control model.

2) All of the turtles have a kinect camera. This is a camera developed by Microsoftalong-with an app programming interface. Tech United Eindhoven has already developedthe technology to track the motion of the ball with this camera. What needs to be doneis to find the target at which the ball is shot. This can be a hole, goal junction or anotherturtle. For now, the target will be a hole. Now that the actual trajectory of the ball andits target are known, the shot can be evaluated. The robot will have to see if the ball hitthe target, and if not, by how far and in which direction it missed.

3) This information can then be used to adapt the feed forward. In fact, it’s a sort ofautomated calibration. The robot can alter its rotation around the vertical axis, move theshooting lever and alter the so-called kick effort, which is used to control the speed of theball. The robots will thus actually learn from their own shots. This will be the subject ofchapter three, intelligent optimizing of feed forward.

The fourth chapter will discuss the results of this project and to which extents the goalhas been achieved. In the last chapter, conclusions, recommendations will be discussed.

A schematic overview of the project is show in figure 1.1. Some layout decisions weremade for this report. Vectors will be bold. When expressing coordinates the Cartesianway, the x-direction will be in the width of the field, y in the length of the field and z inthe vertical direction.

2

Figure 1.1: A schematic overview of the project.

3

2 Theoretical model

To be able to shoot in three dimensions using feed forward, knowledge about the robotand physics is needed. First, a theoretical model of the ball trajectory is introduced,which then needs to be validated with experiments, and if needed adapted to unforeseencircumstances.

2.1 Constraints

Things that constrain the ability of the robot to shoot through the holes are the ranges ofvelocity and angle at which the ball can be shot, friction, spin and distance to the holes.The trajectory of the ball must cross the target. The angle of the speed of the ball at themoment of the shot can be fixed for example, the kick effort can then be increased untilthe ball hits the target. This is basically the way it’s done now. This is probably not thebest approach, because the vertical speed can be very high when the ball hits the target.This means that there is little error margin. Therefore it is decided that the vertical speedshould be zero when the ball hits the target. The angle at which the ball hits the targetis also zero and there is room for play. When the robot makes an error in determiningits position, the ball will probably still reach its target because its path near the target ishorizontal.

2.2 Ball trajectory

To find a theoretical model for the trajectory of the ball, the force and velocity vectors aredrawn, see figure 2.1. It is assumed that the ball behaves as a point mass.

z

r

Fg

Fd

v0

α0

Figure 2.1: The force and velocity vectors concerning the ball.

Where Fg, Fd and v are the gravitional force, drag and velocity respectively. After a shortstudy, it was found that friction does not seem to have a significant impact on the speed ofthe ball ([1], section 3. Parabola). If it’s also assumed that there is no or negligible spin,the equilibrium of forces can be simplified to equation 2.1.

4

dvzdt

= −g (2.1)

This equation can be integrated twice to obtain equation 2.2.

vz = vz,0 − g · t→ z(t) = vz,0 · t−1

2· g · t2 (2.2)

Where z is the vertical position of the center of the ball. At t = 0, the ball is still in itsstarting position, meaning z(t = 0) = 0. Now, r is taken to be the horizontal distancefrom the center of the ball to the target. Because of the assumptions, the speed in thisdirections is constant and we can state 2.3.

r(t) = vr,0 · t→ t(r) =r

vr,0(2.3)

Equation 2.3 can then be substituted back into 2.2 to obtain equation 2.4.

z(r) = − g

2 · v2r,0· r2 +

vz,0vr,0· r (2.4)

The top of this parabola, with coordinates (rt, zt), can easily be found by differentiatingto r (2.5), and finding the root of this function.

dz

dr= − g

v2r,0· rt +

vz,0vr,0

= 0

rt =vr,0 · vz,0

g

(2.5)

This can then in turn be substituted into 2.4 to find the highest point zt, see 2.6.

zt =v2z,02 · g

(2.6)

From this, vz,0 can be extracted as a function of zt. In combination with 2.5, vr,0 can alsobe found as a function of rt and zt, resulting in the velocity vector v0, 2.7.

v0 =

[ √g·rt√2·zt√

2 · g · zt

](2.7)

From this vector, the angle α0 and velocity v0 = ||v0|| under which the ball is shot can bedetermined, 2.8. Now, when the target is known, the starting conditions can be calculated.These can in turn be controlled with the kick effort and lever setting (which will be calledK and L from here on).

[α0

v0

]=

atan(

2·ztrt

)√(

2·ztrt

+ 2 · zt)· g

(2.8)

5

It is also obvious that tan(α0) = vz,0vr,0

and cos(α0) = vr,0v0

, so now the equation of motion 2.4

can be expressed in terms of α0 and v0. The results is shown in equation 2.9.

z(r, α0, v0) = − g

2 · v20 · (cos(α0))2 · r

2 + tan(α0) · r (2.9)

3 Control model

The speed at which the lever moves is controlled with the value of K. This can be chosento be between 0 and 1. Before the shot, a capacitor is charged to its max load. Whenthe shot is triggered, this energy is released with PWM (pulse width modulation), whichmeans periodically switching the voltage on and off. The average voltage can be calculatedwith the root-mean-square definition ([2]), see equation 3.1.

V 2rms =

1

T·∫ T

0

V (t)2 · dt (3.1)

Where T is the period. The uptime t1 can easily be calculated with the value of K and isequal to t1 = K · T . For the square PWM signal equation 3.2 holds.

V (t) =

{Vp, 0 < t < K · T0, K · T < t < T

(3.2)

Where Vp is the voltage during uptime, also called pulse voltage. Substituting 3.2 into 3.1yields equation 3.3.

V 2rms = K · V 2

p (3.3)

This effective voltage is substituted into the definition of the work done by the capacitor.If this is made equal to the kinetic energy of the ball when shot, equation 3.4 is obtained.

Ecapacitor = Ekin

1

2· C · V 2 =

1

2·mb · v20

1

2· C ·K · V 2

p =1

2·m · v20

(3.4)

From which the dependence on K can be found, 3.5.

v0 =

√C · V 2

p ·Km

v0 ∼√K

(3.5)

6

This is a rough estimation, because before the lever can transfer all its energy to the ballit either loses touch of the ball or hits the stop.

The ball and the levers intersection point can be found by calculating the intersectionof two circles, one for the ball and one for the orbit the lever makes. The cap on the leverwhich hits the ball is spherical, just as the ball itself. Two spheres hitting each other meansthe force is directed perpendicular to their surfaces, see 3.1.

F Ball

Cap

Figure 3.1: Graphical illustration of the direction of the force of two hitting spheres.

A graphical representation of the whole setup with measures is displayed in 3.2.

7

Figure 3.2: A graphical representation of the shooting setup.

Where D is the vertical offset of the lever from its lowest position, d the horizontal distancebetween the pivot point of the lever and the center of the ball, h the height of the lever, lthe distance between the pivot point and the cap on the lever (see 3.3) and R the radius ofthe ball. The angle between the green arrow and the red dashed line is the shooting angleα0.

Cap

h l

Figure 3.3: Graphical illustration of the lever.

Where the gray lines are used to mark the dimensions. Now, the relations can be derived.

8

The sets of equations for the two circles are subtracted from each other, see equation 3.6.For the dimensions used, refer back to figure 3.2.

l2 = r2 + (z − (l +D))2 = r2 + z2 − 2 · z · (l +D) + l2 + 2 · l ·D +D2

R2 = (r − d)2 + (z −R)2 = r2 − 2 · d · r + d2 + z2 − 2 · z ·R +R2-

l2 −R2 = −2 · z · (l +D) + 2 · l ·D +D2 + 2 · d · r − d2 + 2 · z ·R + l2 −R2

(3.6)

The last equation describes the intersection as a function of r and z. From this, r, as afunction of z, is extracted and substituted back into the first of the equations 3.6. Thisresults in a solution for z independent on r. This solution can then in turn be substitutedback into the solution for r. Of course, there are two intersections. The solution thatsatisfies the conditions r < d and z < R is chosen. When the intersection is found, theangle α0 can easily be found as a function of D, 3.7. When D = Dmax, the angle is theflattest, corresponding to L = 0 and vice versa. All the needed dimensions can be lookedup in the Siemens NX assembly of the turtles. MATLAB is used (A.1) to plot the resultsas a function of L 3.4.

α0 = atan

(R− zsold− rsol

)(3.7)

9

Figure 3.4: Angle α0 as a function of lever setting L.

It can clearly be seen the relation is nearly linear, resulting in the approximated relation3.8.

α0 = L · α0,max (3.8)

At the point where the ball loses touch of the lever, the lever will have a different anglethan when it first hits the ball, making α0 a bit unpredictable. This approach will howevergive a good indication of the angle of the ball as a response to the height of the lever. Itis also assumed that the static friction can be neglected because the ball is lifted off theground, eliminating normal force of the ball on the ground.

4 Experiment 1: Ball trajectory

The theoretical model established for the path of the ball is merely dependent on gravity.In this experiment that model is tested and validated. The data for experiments 1 and 2where collected in one go as they overlap, but the experiments are described separately.

4.1 Measurement equipment

� Casio Exilim F1

10

� Pressure gauge for ball

4.2 Hypothesis

The expectation is that the path of the ball will fit equation 2.4 or simply put, is parabolic.Effects of drag and spin will not be noticeable at the speeds at which the robot shoots. Itis also logically assumed that these effects, if even, would occur at higher speeds. If theeffects are negligible, they are expected to be even less present at low speeds.

4.3 Measurement setup

To let the turtle be able to shoot at full power it should be set up to shoot from the rightfar corner of the field to the left. The robot will shoot in the y-direction, perpendicularto the axis of the camera lens. Four orange landmarks are place in the vertical planebehind the field. The distance between them was carefully measured, so a pixel-to-metertranslation can be done from the images. The valve of the ball is always placed downwardsand the text on the ball is always placed towards the camera. Also, using the pressuregauge, the ball’s pressure is set to exactly 6.0 kg/cm2. The location of the ball is markedon the field with black tape so it can be positioned with precision every measurement. Thecamera is placed on a tripod, perpendicular to the movement of the ball (ie. facing in thex direction). The tripod is then taped to the surface it’s standing on to make sure everyshot is recorded under the exact same angles and distance. For clarity, see image 4.1. Theframes are shot with the camera at a resolution of 1920 x 1080 pixels and a frame-rate of29 frames per second.

Figure 4.1: The measurement setup.

4.4 Measurement plan

It’s important to know how the angle and speed are set on the robot. It has two parametersfor this, K and L. Both of these values range between 0 and 1. The K and L are set to

11

their max (= 1). This should give the ball a decent angle and speed. Next, five movie clipsare shot.

4.5 Data acquisition

Before the images can be used to extract data, they need to be preprocessed. That isbecause every camera has some lens distortion and fish eye effect. If these parameters areknown, the image can be adjusted to it as to obtain the actual image. The MATLABvision toolbox has a camera calibration app for this ([4]). 30 pictures are taken from acheckerboard at different angles, MATLAB can then detect the lines and squares whichshould be straight and estimates the instrinsic, extrinsic and lens distortion parameters.Then MATLAB can undistort every image before analyzing. As mentioned previously, theorange markers are used to convert pixels to meters. The first movie clip is opened inMATLAB and the first frame is shown. The four markers are then clicked and the clickedpositions will be returned in pixels. Now the distance is divided by the amount of pixels.Next, the position of the ball needs to be traced in every single frame. MATLAB has aspecific tool for this, configureKalmanFilter. What this tool basically does, is measuringand predicting the position of the ball at the same time ([5]). This will be discussed moreelaborately in section 4.7. Next, the traced paths are converted to meters and outliers aremanually filtered out.

4.6 Result analysis

When analyzing the results it became clear that not the full range of L was used. It has tobe translated to an encoder value on the robot. The wrong range of values was taken for thisencoder. This means the experiment had to be done all over using the correct range. Onaccident, the wrong resolution was set on the camera, rendering Kalman analysis useless.So instead of using Kalman, the position of the ball was clicked in every frame. UsingMATLAB’s cftool the collected five datasets are fitted to a polynomial function of degree2. One of these fits is shown in 4.2.

12

Figure 4.2: A parabolic fit through the measured data.

As can be seen, part of the trajectory is missing. This is because this was outside ofthe camera angle. To still provide the prove needed for the hypothesis the experiment isrepeated for K = 0.50 and L = 0.66, see figure 4.3.

Figure 4.3: A parabolic fit through the measured data.

It should be kept in mind that at smaller shooting angles, the noise relatively gets bigger.Looking at the goodness fit parameters though, it can with confidence be stated that themodel is accurate, as will also become apparent in the next experiment.

13

4.7 Kalman analysis

The Kalman filter provides a recursive solution, meaning that every measurement is com-bined with the previous state of the system to calculate the new state ([7]). In this example,the position of the ball would be the state and the frame would be the measurement. TheKalman filtering function in MATLAB can assume a parabolic function which is exactlywhat is needed. The implementation in vision tracking is divided in three parts, initial-ization, prediction and correction. Initialization is easy because the starting position ofthe ball is fixed and known. In the prediction part, the filter is used to predict the rela-tive position of the ball whereas in the correction phase the actual location of the ball islocated. This actual location is used to correct the predicted value and help estimate thenext position. However, during post processing, the ball was still occasionally spotted onrandom positions. To solve this, a region of interest, or ROI, was introduced. This way,if the balls estimated position is outside of this region, the frame is discarded. When arelative displacement of the ball is found, the ROI is also translated with this same vector.Because the recursive nature of the filter, the position thereafter can still be tracked fine.

5 Experiment 2: Control model

To be able to predict the trajectory, more specific the begin conditions, α0 and v0, whichdetermine the trajectory, an experiment needs to be done. The lever is a beam which canbe moved in vertical direction, so the height of the pivot point can be set. The kick effortis a direct measure for the speed of the ball. The setup for the experiment is the same asfor the previous experiment and therefore it won’t be repeated.

5.1 Hypothesis

As explained in section 3 the expectation is that v0 ∼√K and α0 ∼ L.

5.2 Measurement plan

The code running on the robots was adapted, so the kick effort and lever setting can befreely chosen. To test the behavior, many different sets of settings have to be tested. Everycombination is tested 5 times and recorded with a camera so outliers can be filtered out.The set of combinations tested can be found in table 5.1.

14

K L

0.25 0.340.25 0.660.25 1.000.34 0.340.34 0.660.34 1.000.50 0.340.50 0.660.50 1.000.66 0.340.66 0.660.66 1.001.00 0.341.00 0.661.00 1.000.84 0.340.84 0.660.84 0.840.84 1.00

Table 5.1: Combinations of K and L tested.

5.3 Result analysis

Because of the conclusion of the previous experiment, every trajectory is now consideredto be parabolic. Because the shot is taken from right to left and there is an offset in the Zdirection, the data needs to be altered a little more. The (known and fixed) starting heightis subtracted from all measured values for Z. Next, a parabola is fitted through the pointsand the right intersection with the R axis, called Rr,2, is calculated. Next the values of Rare manipulated so they go up from R = 0, see 5.1.

R = Rr,2 −R (5.1)

Now, again, a parabola is fitted through these points. This time, we get a parabola withits origin in (0; 0) going from left to right, see 5.2.

z(r) = a · r2 + b · r (5.2)

Where the constants a and b are estimated with the least squares method by MATLAB.Remembering from equation 2.4, these constants must satisfy 5.3.

15

a = − g

2 · vr,0

b =vz,0vr,0

(5.3)

Knowing that v0 = |v0|=√v2r,0 + v2z,0, this results in equations 5.4 for v0(a, b) and α0(a, b).

α0 = atan(b)

v0 =

√−g

(2 · a) · (1 + b2)

(5.4)

Now, every measurement can be analyzed to obtain the starting angle and speed.

A very prominent effect of the Kalman algorithm is that at low shooting angles the noisein the path found is often higher than the actual gained height of the ball, see 5.1.

Figure 5.1: The noise is higher than the zmax of the ball

Therefore, recordings with a lever setting of below 0.34 where disregarded, which still leaves80 measurements to build a model on. Another effect is the dent in the path when the ballpasses the window left from the BECKHOFF sign, seen in figure 5.2. The light passingthrough that window changes the shadow on the ball drastically, changing the measuredlocation.

16

Figure 5.2: Dent caused by difference in lighting.

Again, the Kalman analysis could not be used in the end, so in every frame the ballsposition was clicked. The assumed models are fitted with MATLAB and plotted in 5.3.

17

Figure 5.3: The measurement data and the fitted models by MATLAB.

It can very clearly be seen that there is a wide spread between the measurement datamutually. Besides the fact that the model does not fit as nice on all of the data, this doesnot seem to be the right approach. It gives to think that v0 is not solely dependent on Kand α0 not solely on L. Instead, MATLAB is used to autonomously find suitable models forv0(K,L) and α0(K,L), evaluating the parameters with linear regression using stepwiselm.This model includes at most a second order cross relation. The results, shown in equation5.5, turn out to be a second order cross relation for v0 and a linear cross relation in K andL for α0. This turns out to provide a very good fit.

v0 = c1 + c2 ·K + c3 · L+ c4 ·K · L+ c5 ·K2 + c6 · L2

α0 = c7 + c8 ·K + c9 · L+ c10 ·K · L(5.5)

It can be seen from these relations that the starting speed is quadratically related to thelever setting. The most likely reason for this is that the stroke of the lever gets biggerfor higher settings of L. However, the constants c2 and c5, which define the dependencyon K and K2 respectively, are still way higher than the constant c6, which defines thedependency on L2. Also see tables 5.2 and 5.3 to demonstrate this. The model can beplotted along with the data, showing its accuracy (5.4).

18

Figure 5.4: The fitted model with the measurement data19

Where the data is plotted in blue dots and the model in red. Looking at the fitnessparameters a(tables 5.2 and 5.3) it can be stated that the model is accurate. To give abetter idea, a measurement is shown along with the predicted path for the K and L whichwere manually set in figure 5.5.

Figure 5.5: A measurement with the corresponding plotted model.

v0 ∼ 1 +K · L+K2 + L2

Number of observations: 80, Error degrees of freedom: 74Root Mean Squared Error: 0.162R-squared: 0.982, Adjusted R-Squared 0.981F-statistic vs. constant model: 820, p-value = 2.82e-63

20

Estimate SE tStat pValue

Intercept 5.9344 0.25726 23.068 1.5848e-35K 12.335 0.59113 20.867 9.9531e-33L -1.0218 0.52527 -1.9453 0.055537K · L -0.69996 0.29365 -2.3837 0.019707K2 -5.4223 0.41026 -13.217 3.655e-21L2 -0.069095 0.35704 -0.19352 0.84708

Table 5.2: The fitness parameters for the fitted model for v0

α0 ∼ 1 +K · LNumber of observations: 80, Error degrees of freedom: 76Root Mean Squared Error: 1.02R-squared: 0.992, Adjusted R-Squared 0.991F-statistic vs. constant model: 3.05e+03, p-value = 4.48e-79

Estimate SE tStat pValue

Intercept -3.7256 0.95129 -3.9164 0.00019475K 6.2665 1.3427 4.667 1.2874e-05L 46.293 1.3211 35.041 1.1607e-48K · L -7.3564 1.8566 -3.9623 0.00016616

Table 5.3: The fitness parameters for the fitted model for α0

6 Implementation

In the previous chapter, models for α0(K,L) and v0(K,L) were established. However,when the target is known, α0 and v0 can be calculated. So what is actually needed are theinverse relations. That will be discussed in this chapter. Now, let’s start with extractingK from the equation of α0 (5.5). K becomes a function of L and α0 this way, see 6.1.

K = −c7 − α0 + c9 · Lc8 + c10 · L

(6.1)

This parametric value of K can be substituted into v0 (5.5) to obtain equation 6.2.

v0 = c1 + c3 · L+ c6 · L2 − c2 · (c7 − α0 + c9 · L)

c8 + c10 · L+

c5 · (c7 − α0 + c9 · L)2

(c8 + c10 · L)2− c4 · L · (c7 − α0 + c9 · L)

c8 + c10 · L

(6.2)

21

The next logical step would be to subtract v0 on both sides and multiply everything by(c8 + c10 · L)2 to get rid of the fractions and obtain equation 6.3.

0 = c6 · c210 · L4 + 2 · c6 · c8 · c10 · L3−

c4 · c9 · c10 · L3 + c3 · c210 · L3+

2 · c3 · c8 · c10 · L2 − c4 · c8 · c9 · L2−

c4 · c7 · c10 · L2 − c2 · c9 · c10 · L2 − c210 · v0 · L2+

α0 · c4 · c10 · L2 + c6 · c28 · L2 + c5 · c29 · L2+

c1 · c210 · L2 − 2 · c8 · c10 · v0 · L+

2 · c5 · c7 · c9 · L+ 2 · c1 · c8 · c10 · L−

c4 · c7 · c8 · L− c2 · c8 · c9 · L− c2 · c7 · c10 · L−

2 · α0 · c5 · c9 · L+ α0 · c4 · c8 · L+

α0 · c2 · c10 · L+ c3 · c28 · L− c2 · c7 · c8−

2 · α0 · c5 · c7 − c28 · v0 + α0 · c2 · c8 + c5 · c27+

c1 · c28 + α20 · c5

(6.3)

The solution for L then becomes the root of a fourth order polynomial with the conditionthat 0 ≤ L ≤ 1. The calculation of this is provided and pretty straightforward ([8]). ForL it was found that there is always exactly one solution. The derivation of K(α0, v0) isanalogous and won’t be repeated here. To see how this was implemented in the code, referto A.2. The C code on the robot is analogous to this.

References

[1] Guillaume Dupeux, Caroline Cohen, Anne Le Goff, David Qur, Christophe Clanet,Football curves - Journal of Fluids and Structures, volume 27, issue 5, 2011

[2] http://www.electronics-tutorials.ws/accircuits/rms-voltage.html, 6-10-2015

[3] http://masteringelectronicsdesign.com/how-to-derive-the-rms-value-of-pulse-and-square-waveforms,6-10-2015

[4] http://nl.mathworks.com/videos/camera-calibration-with-matlab-81233.

html, 5-10-2015

22

[5] http://nl.mathworks.com/help/vision/ref/configurekalmanfilter.html, 5-10-2015

[6] M. Grewal, A. Andrews, Kalman Filtering:Theory and Practice Using MATLAB, 2008,page 1

[7] Erik Cuevas, Daniel Zaldivar, Raul Rojas Kalman filter for vision tracking, 2005 page1, 13-15

[8] Bety Neta, Changbum Chun Basins of attraction for several optimal fourth order meth-ods for multiple roots, 2014, page(s) 40 - 43

23

7 Conclusion

The implemented skill on the robot did its job fine when tested. The result is shown infigure 7.1, showing that it worked!

Figure 7.1: The robot shooting at its target.

From the project, a few things can be concluded. Firstly, it can be stated that the trajectoryof the ball is merely subject to gravity. From that, a simple model can be constituteddepending on only gravity and two initial conditions, namely the initial angle and speedof the ball. These initial conditions can be calculated accordingly to the target. The bestway to do this, is to have the ball hit the target horizontally, because that way the marginfor the error is the biggest. The initialization can then in turn successfully be translatedto the corresponding settings on the robot. To do this, experiments have to be done. Anestablished implicit model can be fitted very accurately to the measurement data. Thismodel can be implemented on the robot and is able to run live without any interaction andpreprocessing of input parameters. A very interesting conclusion is also that the startingspeed and angle of the ball are both related to both of the settings on the robot. The leversetting was assumed to be related to only the starting angle, but seemed to have quadraticinfluence on the starting speed. The kick effort has an influence on the starting angle,which is linear.

24

8 Improvements

A few things in this project could have been handled with more care. Some may be obvi-ous, like setting the correct resolution on the camera, and some won’t be.

Take for example the Kalman filter. A specific region of interest was introduced. Weknow that when the detected location is outside this region, the measurement is consid-ered incorrect and the whole frame is discarded. However, every position is predictedaccording to the previous measurement. So the frame may be discarded, but the foundlocation is still used to find the next. A way to have MATLAB really forget about themeasurement and not just delete the data should be introduced.

Another thing is the leveling of the camera. A live stream to the PC should be set up,where MATLAB is constantly undistorting the frames using the calculated lens param-eters. The leveling around the Z-axis could then be done more accurately, because youcould zoom in on the orange makers and level the camera around the Z-axis. For the Xand Y axes a level should be used.

Also, the background of the camera’s view should be one color, preferably one with themost contrast with the ball. If the lighting would also be more equal, this would providefor more accurate measurements. The effect of lighting of the ball is significant, as wasshown in figure 5.2.

The frame rate of the camera could be set to a higher value or the shutter time couldbe decreased. This would be practical to fight blurriness, enabling the Kalman filter tomore accurately detect the ball. And of course there is the simple reason that more datais collected if the frame rate is higher.

The control model for the value of L could be more precise. Before the ball even startsmoving, the lever already penetrated the ball. So with impulse equations more accuratepredictions could have been done than with the simple model implemented currently.

25

9 Recommendations

To fully enable the robot to work shoot autonomously, the kinect camera should be in-tegrated. It could be used to track the target, which can of course be more than just ahole, like in this case. For example, a nice feature would be to detect the location of theopponent keeper relatively to the goal. The junction of the goal it is the less closest tocould be determined. This location could then be set as the target.

Next, the kinect camera on the robot should also be used to track the motion of theball and determine if the target was hit or not. If the target is missed, this informationcould then be used to alter the control model on the robot, allowing live auto calibration.The robots won’t make the same mistake over and over again during a game and becomea little smarter. The next sensible step is to have several robots look at the shot beingmade. The trajectory is then tracked by more perceivers which can share the informationwith the shooting robot.

When the robot shoots from one far corner to the other, the lever can’t deliver enoughenergy to the ball to actually make it. One of three things could be done. The robot couldfor example be altered to be able to deliver more power. A more efficient way would be toallow that the ball hits the target after it’s been at its highest point. This would requirethe accuracy issues discussed in the previous chapter to be solved. When the target is stilltoo far away, the ball trajectory could be devised so that it hits the target after a bounceon the ground.

26

A Appendix 1: Matlab scripts

A.1 Hypothesis experiment 1

clear all; close all; clc;

R value = 0.115;l value = 0.245;h value = 0.227;d value = 0.172;D min = 0.035;D max = 0.1263;

syms l R r d z D h y1 Lc1 = rˆ2 + (z - (D + h))ˆ2;c2 = (r - d)ˆ2 + (z - R)ˆ2;

intersection = c1 - c2 - lˆ2 + Rˆ2;intersection = expand(intersection);[r sol, params, conds] = solve(intersection == 0, r, ...

'returnConditions', true);

[z sol, params, conds] = solve(subs(c1, r, r sol) == lˆ2, z, ...'returnConditions', true);

z sol = simplify(z sol);z sol = z sol(2); % Satisfies the conditions r < d and z < R

r sol = subs(r sol, z, z sol);alpha0 = atan((R - z sol) / (d - r sol)) / pi * 180;alpha0 = simplify(alpha0);

L value = 0:0.01:1;alpha0 plot = subs(alpha0, [R, l, h, d, D], [R value, l value, ...

h value, d value, D min + (1 - L) * (D max - D min)]);alpha0 plot = double(subs(alpha0 plot, L, L value));

figureplot(L value, alpha0 plot);grid;xlabel('Lever setting [-]');ylabel('Angle of ball at start of shot [degrees]');axis([-0.2 1.2 -0.2 * 45 1.2 * 45]);

figure; grid; hold on;L = 0.5;D value = D min + (1 - L) *(D max - D min);alpha0 value = double(subs(alpha0, [R, l, h, d, D], [R value, ...

l value, h value, d value, D value])) / 180 * pi;circle(0, D value + h value, l value);

27

circle(d value, R value, R value);legend('Orbit of lever', 'Ball');quiver(0, D value + h value, 0, -l value * 1.11, 'k');quiver(d value, R value, 0, R value * 1.11, 'k');text(0, D value + 1/2 * h value, ' \leftarrow l');text(d value, 1.5 * R value, ' \leftarrow R');plot(0, D value + h value, '.k');text(0, D value + h value, ' \leftarrow \{0; h + D\}');plot(d value, R value, '.k');text(d value, R value, ' \leftarrow \{d; R\}');Rt = double(subs(r sol, [R, l, h, d, D], [R value, l value, ...

h value, d value, D value]));Zt = double(subs(z sol, [R, l, h, d, D], [R value, l value, ...

h value, d value, D value]));plot(Rt, Zt, '.');start = [Rt; Zt];stop = [Rt + R value * sin(alpha0 value); Zt + R value ...

* cos(alpha0 value)];quiver(Rt, Zt, R value * cos(alpha0 value), R value ...

* sin(alpha0 value), 'k');plot([0.2 * Rt 2.5 * Rt], [Zt Zt], '--r');text(Rt + 0.06, Zt + 0.015, '\alpha 0');axis([-0.2 * (d value + R value) 1.2 * (d value + R value) ...

-0.2 *(D value + h value) 1.2 * (D value + h value)]);xlabel('Longtitudinal direction r [m]');ylabel('Vertical direction z [m]');

A.2 Inverting correlations

classdef findKL < handleproperties (Access = public)

syms K,L,Kf,Lf,alpha0,v0,alpha0f,v0f;

c1 value,c2 value,c3 value,c4 value,c5 value,c6 value,c7 value,c8 value,c9 value,c10 value;

end

28

methods (Static)function obj = findKL()

syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 K L;

obj.c1 value = 5.93435941246473;obj.c2 value = 12.3352632002752;obj.c3 value = -1.02182056160660;obj.c4 value = -0.699959551801971;obj.c5 value = -5.42232569462746;obj.c6 value = -0.0690949663377961;obj.c7 value = -3.7256;obj.c8 value = 6.2665;obj.c9 value = 46.293;obj.c10 value = -7.3564;

obj.findCorrelation();

obj.alpha0f = matlabFunction(subs(c7 + c8 * K + c9 * L + c10 * K ...

* L, [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10], [obj.c1 value ...obj.c2 value obj.c3 value obj.c4 value obj.c5 value obj.c6 value ...obj.c7 value obj.c8 value obj.c9 value obj.c10 value]));

obj.v0f = matlabFunction(subs(c1 + c2 * K + c3 * L + c4 * K * L ...+ c5 * Kˆ2 + c6 * Lˆ2, [c1, c2, c3, c4, c5, c6, c7, c8, c9, ...c10], [obj.c1 value obj.c2 value obj.c3 value obj.c4 value ...obj.c5 value obj.c6 value obj.c7 value obj.c8 value obj.c9 value ...obj.c10 value]));

obj.findKL functions();end

end

methodsfunction findCorrelation(obj)

syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 K L alpha0 v0 alpha0f v0f;

alpha0f = c7 + c8 * K + c9 * L + c10 * K * L;v0f = c1 + c2 * K + c3 * L + c4 * K * L + c5 * Kˆ2 + c6 * Lˆ2;

[K sol, params, conds] = solve(alpha0f == alpha0, K, ...'ReturnConditions', true);

K sol[L alpha0 v0, params, conds] = solve(subs(v0f, K, K sol) == v0, ...

L, 'ReturnConditions', true);L alpha0 v0

[L sol, params, conds] = solve(c7 + c8 * K + c9 * L + c10 * K * ...L == alpha0, L, 'ReturnConditions', true);

L solconds[K alpha0 v0, params, conds] = solve(subs(v0f, L, L sol) == v0, ...

29

K, 'ReturnConditions', true);K alpha0 v0

end

function findKL functions(obj)syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10;

obj.findRoots();

obj.Kf = matlabFunction(subs(obj.K, [c1, c2, c3, c4, c5, c6, c7, ...c8, c9, c10], [obj.c1 value obj.c2 value obj.c3 value ...obj.c4 value obj.c5 value obj.c6 value obj.c7 value obj.c8 value ...obj.c9 value obj.c10 value]));

obj.Lf = matlabFunction(subs(obj.L, [c1, c2, c3, c4, c5, c6, c7, ...c8, c9, c10], [obj.c1 value obj.c2 value obj.c3 value ...obj.c4 value obj.c5 value obj.c6 value obj.c7 value obj.c8 value ...obj.c9 value obj.c10 value]));

end

function findRoots(obj)syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 alpha0 v0;

A = c5*c10ˆ2; %% These are the terms of K calculated aboveB = 2*c5*c9*c10 - c4*c8*c10 + c2*c10ˆ2;C = 2*c2*c9*c10 + alpha0*c4*c10 - c4*c8*c9 - c4*c7*c10 - c3*c8*c10 ...

+ c6*c8ˆ2 + c5*c9ˆ2 + c1*c10ˆ2 - c10ˆ2*v0;D = -2*c9*c10*v0 + 2*c6*c7*c8 + 2*c1*c9*c10 - 2*alpha0*c6*c8 + ...

alpha0*c4*c9 + alpha0*c3*c10 + c2*c9ˆ2 - c4*c7*c9 - c3*c8*c9 ...- c3*c7*c10;

E = -2*alpha0*c6*c7 + alpha0*c3*c9 - c3*c7*c9 + c6*c7ˆ2 + c1*c9ˆ2 ...+ alpha0ˆ2*c6 - c9ˆ2*v0;

obj.K = obj.RootOf(A, B, C, D, E, 4);

A = c6*c10ˆ2;B = 2*c6*c8*c10 - c4*c9*c10 + c3*c10ˆ2;C = 2*c3*c8*c10 - c4*c8*c9 - c4*c7*c10 - c2*c9*c10 - c10ˆ2*v0 + ...

alpha0*c4*c10 + c6*c8ˆ2 + c5*c9ˆ2 + c1*c10ˆ2;D = -2*c8*c10*v0 + 2*c5*c7*c9 + 2*c1*c8*c10 - c4*c7*c8 - c2*c8*c9 ...

- c2*c7*c10 - 2*alpha0*c5*c9 + alpha0*c4*c8 + alpha0*c2*c10 ...+ c3*c8ˆ2;

E = -c2*c7*c8 - 2*alpha0*c5*c7 - c8ˆ2*v0 + alpha0*c2*c8 + c5*c7ˆ2 ...+ c1*c8ˆ2 + alpha0ˆ2*c5;

obj.L = obj.RootOf(A, B, C, D, E, 1);end

function rootOf = RootOf(obj, A, B, C, D, E, i)p = (8 * A * C - 3 * Bˆ2) / (8 * Aˆ2);q = (Bˆ3 - 4 * A * B * C + 8 * Aˆ2 * D) / (8 * Aˆ3);delta0 = Cˆ2 - 3 * B * D + 12 * A * E;

30

delta1 = 2 * Cˆ3 - 9 * B * C * D + 27 * Bˆ2 * E + 27 * A * Dˆ2 ...- 72 * A * C * E;

Q = ((delta1 + sqrt(delta1ˆ2 - 4 * delta0ˆ3)) / 2)ˆ(1/3);S = 1/2 * sqrt(-2/3 * p + 1 / (3 * A) * (Q + delta0 / Q));z(1) = -B / (4 * A) + S + 1/2 * sqrt(-4 * Sˆ2 - 2 * p - q / S);z(2) = -B / (4 * A) + S - 1/2 * sqrt(-4 * Sˆ2 - 2 * p - q / S);z(3) = -B / (4 * A) - S + 1/2 * sqrt(-4 * Sˆ2 - 2 * p + q / S);z(4) = -B / (4 * A) - S - 1/2 * sqrt(-4 * Sˆ2 - 2 * p + q / S);

rootOf = z(i);end

endend

31