\section{Robot architecture}
\subsection{Tools}
\emph{LeJOS}~\cite{lejos_team_lejos_2015}

\emph{XText}

\emph{eclipse}

\emph{Antlr}

\emph{Xtend}

\subsection{Design patterns}
\subsubsection{Producer-Consumer}
Ultimately we want to only program one robot. The fact that the one robot
contains multiple control bricks is something that needs to be abstracted away
from. As will be discussed in Section~\ref{sec:mapping} the first brick, from
now on \emph{Consumer}, has the direct control over all the motors. However the
second brick, from now on \emph{Producer}, controls no motors. Both the
\emph{Consumer} and the \emph{Producer} control $4$ sensors. Because of this
configuration the \emph{Producer} only needs to send its sensor data to the
\emph{Consumer}. There is no need to communicate anything back since the
\emph{Producer} can not respond in any physical way. An option could be to
distribute the processing power but due to the strength of the bricks and the
limitation of the bluetooth this is very hard or even impossible to achieve.

\subsubsection{Subsumption}
As the higher level architecture we use a slightly adapted version of the
subsumption architecture first described by Brooks~\cite{brooks_robust_1986}.
We use the pre-implemented architecture from the \emph{LeJOS} where with the
use of a \texttt{suppressed} flag in every behaviour we can start and interrupt
the behaviour. Our version is a little bit adapted from the original
subsumption behaviour because in our implementation the robot can finish the
designated task even if the behaviour does not want control anymore. For
example when the left light sensor detects that the robot is driving of the
planet a right turn of $90$ degrees may be initiated. This right turn will be
completed even when the left light sensor is not detecting a dangerous value.
The suppressed flag can take three states. \texttt{IDLE}, \texttt{IN\_ACTION}
and \texttt{SUPPRESSED}. By default all behaviours have the \texttt{IDLE}
state. When a behaviour is started the state will change to \texttt{IN\_ACTION}
and when a behaviour finished the state will be reset to \texttt{IDLE}. When a
behaviour needs to be interrupted the state is set to \texttt{SUPPRESSED} and
since the behaviour is always monitoring the state it will shutdown as soon as
possible and reset the state.

\subsection{Mapping of the sensors and actuators}\label{sec:mapping}
The actuators are all plugged into the \emph{Consumer} to achieve the maximum
safety in case the \emph{Bluetooth} connection fails between the
\emph{Consumer} and the \emph{Producer} and one of the actuators is moving.
All the safety-critical sensors for movement are placed on the \emph{Consumer}
brick too. All other sensors are placed on the \emph{Producer} brick. Any
increased latency on those sensors will not danger the safety. The final
mapping is described in \autoref{tab:mapping}.

\begin{table}[H]
	\centering
	\begin{tabular}{lll}
		\toprule
			& \emph{Consumer} & \emph{Producer}\\
		\midrule
		\multirow{2}{*}{Actuators} & Left motor\\
			& Right motor & \\
			& Measurement motor\\
		\midrule
		\multirow{4}{*}{Sensors} & Left light sensor & Color sensor\\
			& Right light sensor & Front ultrasone sensor\\
			& Back ultrasone sensor & Left touch sensor\\
			& Gyro sensor & Right touch sensor\\
		\bottomrule
	\end{tabular}
	\caption{Proposed mapping of the sensors and actuators}\label{tab:mapping}
\end{table}

\subsection{Domain Specific Language}


\subsection{Code Structure}