checkpoint
[bachelor-thesis/written-stuff.git] / Ausarbeitung / implementation.tex
index 6acf6d9..3247aec 100644 (file)
@@ -1,10 +1,9 @@
 \chapter{Implementation}
-
-\todo{?}
+\todo{more?}
 This chapter describes the implementation that was used for the aforementioned
 experiments. It consists of the measuring programs themselves, which use the
 Wiselib Roomba Control, and are written in C++. Additionally, there are several
-Bash scripts to help with the analysis of the measured data.
+Bash and Perl scripts to help with the analysis of the measured data.
 
 All code used for this thesis resides in the Wiselib source tree\footnote{see
 \url{https://github.com/ibr-alg/wiselib/}, or the \acs{CDROM} attached at the
@@ -25,18 +24,18 @@ the target values for the Roomba movement himself, in automatic mode, the
 application uses a list of pre-programmed values for the target values, so the
 user only has to input the measured data.
 
-All measured data is written to a log file in the current directory, whose name
+All measured data is written to a log file in the current directory whose name
 is based on the type of experiment performed. Every line in that log file
-describes one measurement made by the user, and consists of key-value pairs
-linked together with equality signs and separated of each other by whitespace.
-In particular, the data on each line are (with key name, in the order of
-appearance on the line):
+describes one measurement made by the user, and consists of pairs of the form
+\code{key=value}, separated of by whitespace. In particular, the data on each
+line are (with key name, in the order of appearance on the line):
 \begin{enumerate}
-  \item\texttt{svn:} the SVN or Git revision the program was compiled from
+  \setlength{\itemsep}{1pt}
+  \item\texttt{svn:} the \ac{SVN} or Git revision the program was compiled from
     (statically compiled into the program)
   \item\texttt{roomba\_id:} the ID of the Roomba the measurement was performed
     with (given by the user)
-  \item\texttt{ground\_type} the ground type used for measurement:
+  \item\texttt{ground\_type:} the ground type used for measurement:
     \magicvalue{iz250flur} for laminated floor, \magicvalue{seminarraum}
     for carpet floor (given by the user)
   \item\texttt{diff\_ticks\_left:} the difference of encoder counts between the
@@ -57,11 +56,12 @@ appearance on the line):
     (packet~ID~\magicvalue{0x16})
   \item\texttt{batt\_voltage:} the current going out of the Roomba's battery in
     mA (packet~ID~\magicvalue{0x17})
-  \item\texttt{move:} \magicvalue{straight} for straight moves,
-    \magicvalue{turn} for turn moves
+  \item\texttt{move:} movement type; \magicvalue{straight} for straight moves,
+    \magicvalue{turn} for turn moves (given by the user while selecting the
+    experiment type)
   \newcounter{logitems}\setcounter{logitems}{\value{enumi}+1}
 \end{enumerate}
-For straight moves (\magicvalue{move=straight}) follows:
+For straight moves (\magicvalue{move=straight}) follow:
 \begin{enumerate}[start=\value{logitems}]
   \item\texttt{input\_distance}: the target distance in mm sent to the Roomba
     via the \ac{ROI} \cmd{Drive} command (given by the user in manual mode,
@@ -76,7 +76,7 @@ For straight moves (\magicvalue{move=straight}) follows:
   \item\texttt{deviation\_orientation:} originally, the shift in orientation of
     the Roomba. Not used anymore.
 \end{enumerate}
-For straight moves (\magicvalue{move=turn}) follows:
+For turn moves (\magicvalue{move=turn}) follow:
 \begin{enumerate}[start=\value{logitems}]
   \item\texttt{turn\_angle:} the turn angle in degree sent to the Roomba via the
     \ac{ROI} \cmd{Drive} command (given by the user in manual mode, or
@@ -93,29 +93,63 @@ For straight moves (\magicvalue{move=turn}) follows:
   \includegraphics[width=\textwidth]{images/Implementation-Diagram.pdf}
   \caption[File structure of the measuring implementation]{Simplified file
     structure of the measuring implementation\label{fig:impl:struct}\\
-    yellow: general files used for all three experiments; green: files for
-    Experiment~1; blue: files for Experiment~2; red: files for Experiment~3}
+    yellow: common files used for all three experiments; green: files for
+    Experiment~1; blue: files for Experiment~2; red: files for Experiment~3.\\
+    An arrow from node $x$ to node $y$ means ``$y$ depends from $x$''.}
 \end{figure}
 
 Figure~\ref{fig:impl:struct} shows the file layout of the measuring
 implementation. It reuses components whereever possible, and therefore
-consists of three parts specific for the three performed experiments (see
-Sections~\ref{sec:exp1}, \ref{sec:exp2} and~\ref{sec:exp3}), as well as a
-general part, which contains the elements of the implementation common to the
-other three parts.
-
-\subsection{General part}
-The files \file{stuff.cc}, \file{stuff.h},
-\file{target\_value\_input\_dialog.cc} and \file{target\_value\_input\_dialog.h}
-build up the general part of the implementation. These are the files shown with
-a yellow background in Figure~\ref{fig:impl:struct}, and are included in all
-other three parts of the implementation.
+consists of three parts (green, blue, red) specific for the three performed
+experiments (see Sections~\ref{sec:exp1}, \ref{sec:exp2} and~\ref{sec:exp3}), as
+well as a common part (yellow), which contains the elements of the
+implementation shared by the other three parts.
+
+\subsection{Common part}
+% no \file{} here please, we don't want "stuff.{cc,h}" in index...
+The files \code{stuff.\{cc,h\}} and \code{target\_value\_input\_dialog.\{cc,h\}}
+build up the general part of the implementation (shown with a yellow background
+in Figure~\ref{fig:impl:struct}). These are included in all other three parts of
+the implementation.
 
 \paragraph{\file{stuff.cc} and \file{stuff.h}}
-Both of these files contain global functions for logging text to a file,
-according to the format described above. Also there
+Both of these files contain global helper functions and variables,
+implementation-specific data structures and all kinds of convenient typedefs. In
+particular, there are functions for formatting and logging messages to a log
+file, according to the format described above. While \file{stuff.h} contains the
+declarations and typedefs, \file{stuff.cc} contains the appropriate definitions.
+Besides, since \file{stuff.h} is included indirectly in most other source files,
+it also includes the Wiselib headers needed for Roomba control.
+
+\paragraph{\file{target\_value\_input\_dialog.cc} and
+\file{target\_value\_input\_dialog.h}}
+These files contain the class \code{TargetValueInputDialog}
+\index{TargetValueInputDialog}, an implementation of a dialog box that allows
+the user to input a measured angle (although the names mention a ``target
+value'', it does that probably only to increase the confusion\ldots). This is a
+typical Qt dialog which contains an input box with adjacent spin box for
+entering the measured value, OK and Cancel buttons, and also information about
+the target orientation and the current real orientation.
+
+When the dialog is displayed, it obtains the orientation as it was before the
+last movement, and the target angle, and sets the input box to the specified
+target value. When the input box is changed, the dialog calculates the new
+orientation from the last orientation and the value in the input box, and
+displays this new orientation. This way, the user can simply enter the measured
+angle by increasing or decreasing the value by operating the spin box, and
+adjusting the value until the displayed orientation reflects the real
+orientation of the Roomba.
+
+To achieve this, the class uses the Qt signal-slot
+mechanism~\cite{qt-signalslots}, and connects the \code{intValueChanged(int)}
+signal of the input box to the method \code{turn\_dialog\_value\_changed(int)},
+which performs the calculation and display of the new value.
 
 \subsection{Implementation for Experiment~1}
+The implementation for Experiment~1 is used to build the application
+\prog{roomba\_test}. Its main part is constituted by the file \file{main.cc},
+which uses the global definitions of \file{stuff.h} and the dialog box from
+
 \subsection{Implementation for Experiment~2}
 \subsection{Implementation for Experiment~3}
 
@@ -123,11 +157,6 @@ three single applications with same base: roomba\_test (main.cc),
 mean\_correction\_test (mean\_correction.cc), soft\_start\_test
 (soft\_start.cc).
 
-user interface: Qt.
-
-manual tests (user is asked for new values every time) or automated tests (user
-only asked for measured values).
-
 1) open UART connection
 
 2) register state callback for getting roomba sensor data
@@ -136,8 +165,7 @@ only asked for measured values).
 
 4) drive() / turn() use wiselib::ControlledMotion<OsModel,
 wiselib::RoombaModel> for moving specified angle/distance; and ask for measured
-values and write to external log file, including battery status, roomba/wiselib
-internal angles/distances (ticks), svn revision, floor type, roomba ID
+values and write to log
 
 additionally, mean correction test uses
 CorrectedMeanMotion from corrected\_mean\_motion.h, implements same concept like
This page took 0.032514 seconds and 4 git commands to generate.