18 Robot Soccer
calculate the exact ball position in meters from the screen coordinates in pixels and the current camera position/orientation.
Measurement
distance (cm)
80
60
40
20
|
|
|
|
|
|
height (pixels) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
40 |
60 |
80 |
Schematic Diagram
Figure 18.5: Relation between object height and distance
The distance values were found through a series of measurements, for each camera position and for each image line. In order to reduce this effort, we only used three different camera positions (up, middle, down for the tilting camera arrangement, or left, middle, right for the panning camera arrangement), which resulted in three different lookup tables.
Depending on the robot’s current camera orientation, the appropriate table is used for distance translation. The resulting relative distances are then translated into global coordinates using polar coordinates.
An example output picture on the robot LCD can be seen in Figure 18.6. The lines indicate the position of the detected ball in the picture, while its global position on the field is displayed in centimeters on the right-hand side.
Figure 18.6: LCD output after ball detection
Trajectory Planning
This simple image analysis algorithm is very efficient and does not slow down the overall system too much. This is essential, since the same controller doing image processing also has to handle sensor readings, motor control, and timer interrupts as well. We achieve a frame rate of 3.3 fps for detecting the ball when no ball is in the image and of 4.2 fps when the ball has been detected in the previous frame, by using coherence. The use of a FIFO buffer for reading images from the camera (not used here) can significantly increase the frame rate.
18.6 Trajectory Planning
Once the ball position has been determined, the robot executes an approach behavior, which should drive it into a position to kick the ball forward or even into the opponent’s goal. For this, a trajectory has to be generated. The robot knows its own position and orientation by dead reckoning; the ball position has been determined either by the robot’s local search behavior or by communicating with other robots in its team.
18.6.1 Driving Straight and Circle Arcs
The start position and orientation of this trajectory is given by the robot’s current position, the end position is the ball position, and the end orientation is the line between the ball and the opponent’s goal. A convenient way to generate a smooth trajectory for given start and end points with orientations are Hermite splines. However, since the robot might have to drive around the ball in order to kick it toward the opponent’s goal, we use a case distinction to add “viapoints” in the trajectory (see Figure 18.7). These trajectory points guide the robot around the ball, letting it pass not too close, but maintaining a smooth trajectory.
If robot drove directly to ball:
|
Would it kick ball towards |
|
yes |
own goal? |
|
|
no |
|
|
|
|
|
|
If robot drove directly to ball: |
|
|
|
Would it kick ball directly |
|
|
|
into opponent goal? |
|
|
|
yes |
|
|
no |
|
|
|
Is robot in |
|
|
|
own half? |
|
|
|
yes |
no |
drive behind |
drive directly |
drive directly |
|
drive behind |
the ball |
to the ball |
to the ball |
|
the ball |
|
|
|
|
|
|
Figure 18.7: Ball approach strategy
18 Robot Soccer
In this algorithm, driving directly means to approach the ball without viapoints on the path of the robot. If such a trajectory is not possible (for example for the ball lying between the robot and its own goal), the algorithm inserts a via-point in order to avoid an own goal. This makes the robot pass the ball on a specified side before approaching it. If the robot is in its own half, it is sufficient to drive to the ball and kick it toward the other team's half. When a player is already in the opposing team's half, however, it is necessary to approach the ball with the correct heading in order to kick it directly toward the opponent’s goal.
y
(b)(c)
(a)
x
(e)
(d)
Figure 18.8: Ball approach cases
The different driving actions are displayed in Figure 18.8. The robot drives either directly to the ball (Figure 18.8 a, c, e) or onto a curve (either linear and circular segments or a spline curve) including via-points to approach the ball from the correct side (Figure 18.8 b, d).
Drive directly to the ball (Figure 18.8 a, b):
With localx and localy being the local coordinates of the ball seen from the robot, the angle to reach the ball can be set directly as:
|
D |
atan |
§localy· |
|
©localx---------------¹ |
|
|
|
With l being the distance between the robot and the ball, the distance to drive in a curve is given by:
d l D sin D
Drive around the ball (Figure 18.8 c, d, e):
If a robot is looking toward the ball but at the same time facing its own goal, it can drive along a circular path with a fixed radius that goes through the ball. The radius of this circle is chosen arbitrarily and was defined to be 5cm. The circle is placed in such a way that the tangent at the position of the ball also goes through the opponent’s goal. The robot turns on the spot until it faces this
Trajectory Planning
circle, drives to it in a straight line, and drives behind the ball on the circular
path (Figure 18.9). |
|
|
Compute turning angle Jfor turning on the spot: |
J D E |
Circle angle Ebetween new robot heading and ball: |
E E E |
Angle to be driven on circular path: |
2·E |
Angle Egoal heading from ball to x-axis: |
|
E |
|
atan |
§ |
bally |
· |
|
|
|
-------------------------------- |
|
|
1 |
|
©length ballx¹ |
|
Angle E2: ball heading from robot to x-axis:
E2 |
atan |
§bally |
roboty· |
©ball---------------------------------x |
robotx¹ |
Angle Dfrom robot orientation to ball heading (Mis robot orientation):
D M E
x |
roboty |
|
|
|
|
bally |
|
|
|
|
E |
E |
length- |
length- |
|
|
|
ballx |
robotx |
|
|
E |
|
|
|
|
|
D |
|
Figure 18.9: Calculating a circular path toward the ball
18.6.2 Driving Spline Curves
The simplest driving trajectory is to combine linear segments with circle arc segments. An interesting alternative is the use of splines. They can generate a smooth path and avoid turning on the spot, therefore they will generate a faster path.
18 Robot Soccer
Given the robot position Pk and its heading DPk as well as the ball position Pk+1 and the robot’s destination heading DPk+1 (facing toward the opponent’s goal from the current ball position), it is possible to calculate a spline which for every fraction u of the way from the current robot position to the ball position describes the desired location of the robot.
The Hermite blending functions H0 .. H3 with parameter u are defined as follows:
H0 |
2u3 3u2 1 |
H1 |
2u3 3u2 |
H2 |
u3 |
3u2 u |
H3 |
u3 |
u2 |
The current robot position is then defined by:
P u pkH0 u pk 1H1 u DpkH2 u DPk 1H3 u
Figure 18.10: Spline driving simulation
A PID controller is used to calculate the linear and rotational speed of the robot at every point of its way to the ball, trying to get it as close to the spline curve as possible. The robot’s speed is constantly updated by a background process that is invoked 100 times per second. If the ball can no longer be detected (for example if the robot had to drive around it and lost it out of sight), the robot keeps driving to the end of the original curve. An updated driving command is issued as soon as the search behavior recognizes the (moving) ball at a different global position.
This strategy was first designed and tested on the EyeSim simulator (see Figure 18.10), before running on the actual robot. Since the spline trajectory