\section{Goal Alignment}
\label{p sec goal align}

After the approach, described in the section \ref{p sec approach}, is finished,
the robot is facing the ball, and the ball is at a short distance. In the stage
of goal alignment, the task is to ensure that from the robot's point of view
the ball lies between the goalposts. This means, that when the robot is
centered at the ball, the goalposts should lie on either side of the center of
the camera image. So the robot will first detect the goal and determine if that
is the case. If that is not the case, the robot will go around the ball in a
circle in the appropriate direction, until the ball is indeed between the
goalposts.

The walk in circle was implemented in the following way: the robot will step
several steps sideways, then will turn to ball, as described in the section
\ref{j sec turning to ball}, and finally will adjust the distance to the ball
by stepping forwards or backwards, so that the ball is neither too close nor
too far. The distance to the ball, similarly to the stage of the direct
approach, is not measured explicitly, but is approximated through the position
of the ball image in the camera frame. After performing these steps, the check
is performed, if the goal alignment is completed. Otherwise, the steps will be
repeated until alignment is achieved. The figure \ref{p figure goal-alignment}
depicts the successful completion of this stage.

\begin{figure}[ht]
  \includegraphics[width=\textwidth]{\fig goal-alignment}
  \caption{Successful goal alignment}
  \label{p figure goal-alignment}
\end{figure}
