1 \chapter{Implementation
}
4 This chapter describes the implementation that was used for the aforementioned
5 experiments. It consists of the measuring programs themselves, which use the
6 Wiselib Roomba Control, and are written in C++. Additionally, there are several
7 Bash scripts to help with the analysis of the measured data.
9 All code used for this thesis resides in the Wiselib source tree
\footnote{see
10 \url{https://github.com/ibr-alg/wiselib/
}, or the
\acs{CDROM
} attached at the
11 end of this book
} in the directory
\filepath{apps/pc
\_apps/roomba
\_tests}.
14 \label{sec:impl:measuring
}
16 The measuring implementation is a set of programs running on a x86-compatible
17 Linux system which uses the Wiselib to control a Roomba attached to the system
18 over a serial interface. It features a graphical user interface using the
19 Qt application framework. Basically, it carries out a movement with specified
20 parameters (velocity, and destination or angle, depending on the experiment),
21 then prompts the user to measure and input the actual destination or angle the
22 Roomba has moved after it has finished the movement. In this context, the user
23 can choose between two operation modes. In the manual mode, the user can control
24 the target values for the Roomba movement himself, in automatic mode, the
25 application uses a list of pre-programmed values for the target values, so the
26 user only has to input the measured data.
28 All measured data is written to a log file in the current directory, whose name
29 is based on the type of experiment performed. Every line in that log file
30 describes one measurement made by the user, and consists of key-value pairs
31 linked together with equality signs and separated of each other by whitespace.
32 In particular, the data on each line are (with key name, in the order of
33 appearance on the line):
35 \item\texttt{svn:
} the SVN or Git revision the program was compiled from
36 (statically compiled into the program)
37 \item\texttt{roomba
\_id:
} the ID of the Roomba the measurement was performed
38 with (given by the user)
39 \item\texttt{ground
\_type} the ground type used for measurement:
40 \magicvalue{iz250flur
} for laminated floor,
\magicvalue{seminarraum
}
41 for carpet floor (given by the user)
42 \item\texttt{diff
\_ticks\_left:
} the difference of encoder counts between the
43 beginning and the end of the movement, on the Roomba's left wheel
44 (packet~ID
\magicvalue{0x2b} in the
\ac{ROI
} Specification)
45 \item\texttt{diff
\_ticks\_right:
} the difference of encoder counts between the
46 beginning and the end of the movement, on the Roomba's right wheel
47 (packet~ID
\magicvalue{0x2c} in the
\ac{ROI
} Specification)
48 \item\texttt{raw
\_ticks\_left:
} the absolute value of the encoder count of the
49 Roomba's left wheel (packet~ID
\magicvalue{0x2b})
50 \item\texttt{raw
\_ticks\_right:
} the absolute value of the encoder count of
51 the Roomba's right wheel (packet~ID
\magicvalue{0x2c})
52 \item\texttt{batt
\_charge:
} the charge of the Roomba's battery in mAh
53 (packet~ID~
\magicvalue{0x19})
54 \item\texttt{batt
\_capacity:
} the capacity of the Roomba's battery in mAh
55 (packet~ID~
\magicvalue{0x1a})
56 \item\texttt{batt
\_voltage:
} the applied voltage of the Roomba's battery in mV
57 (packet~ID~
\magicvalue{0x16})
58 \item\texttt{batt
\_voltage:
} the current going out of the Roomba's battery in
59 mA (packet~ID~
\magicvalue{0x17})
60 \item\texttt{move:
} \magicvalue{straight
} for straight moves,
61 \magicvalue{turn
} for turn moves
62 \newcounter{logitems
}\setcounter{logitems
}{\value{enumi
}+
1}
64 For straight moves (
\magicvalue{move=straight
}) follows:
65 \begin{enumerate
}[start=
\value{logitems
}]
66 \item\texttt{input
\_distance}: the target distance in mm sent to the Roomba
67 via the
\ac{ROI
} \cmd{Drive
} command (given by the user in manual mode,
68 or determined by the program in automatic mode)
69 \item\texttt{velocity:
} (the velocity in mm/s sent to the Roomba over the
70 \ac{ROI
} \cmd{Drive
} command (given by the user in manual mode, or
71 determined by the program in automatic mode)
72 \item\texttt{measured
\_x:
} the actual covered distance in mm in the Roomba's
73 original viewing direction (measured by the user)
74 \item\texttt{measured
\_y:
} originally, the distance shift perpendicular to the
75 viewing direction of the Roomba. Not used anymore.
76 \item\texttt{deviation
\_orientation:
} originally, the shift in orientation of
77 the Roomba. Not used anymore.
79 For straight moves (
\magicvalue{move=turn
}) follows:
80 \begin{enumerate
}[start=
\value{logitems
}]
81 \item\texttt{turn
\_angle:
} the turn angle in degree sent to the Roomba via the
82 \ac{ROI
} \cmd{Drive
} command (given by the user in manual mode, or
83 determined by the program in automatic mode)
84 \item\texttt{measured
\_angle:
} the actual turned angle of the Roomba in degree
85 (measured by the user)
86 \item\texttt{velocity:
} (the velocity in mm/s sent to the Roomba over the
87 \ac{ROI
} \cmd{Drive
} command (given by the user in manual mode, or
88 determined by the program in automatic mode)
93 \includegraphics[width=
\textwidth]{images/Implementation-Diagram.pdf
}
94 \caption[File structure of the measuring implementation
]{Simplified file
95 structure of the measuring implementation
\label{fig:impl:struct
}\\
96 yellow: general files used for all three experiments; green: files for
97 Experiment~
1; blue: files for Experiment~
2; red: files for Experiment~
3}
100 Figure~
\ref{fig:impl:struct
} shows the file layout of the measuring
101 implementation. It reuses components whereever possible, and therefore
102 consists of three parts specific for the three performed experiments (see
103 Sections~
\ref{sec:exp1
},
\ref{sec:exp2
} and~
\ref{sec:exp3
}), as well as a
104 general part, which contains the elements of the implementation common to the
107 \subsection{General part
}
108 The files
\file{stuff.cc
},
\file{stuff.h
},
109 \file{target
\_value\_input\_dialog.cc
} and
\file{target
\_value\_input\_dialog.h
}
110 build up the general part of the implementation. These are the files shown with
111 a yellow background in Figure~
\ref{fig:impl:struct
}, and are included in all
112 other three parts of the implementation.
114 \paragraph{\file{stuff.cc
} and
\file{stuff.h
}}
115 Both of these files contain global functions for logging text to a file,
116 according to the format described above. Also there
118 \subsection{Implementation for Experiment~
1}
119 \subsection{Implementation for Experiment~
2}
120 \subsection{Implementation for Experiment~
3}
122 three single applications with same base: roomba
\_test (main.cc),
123 mean
\_correction\_test (mean
\_correction.cc), soft
\_start\_test
128 manual tests (user is asked for new values every time) or automated tests (user
129 only asked for measured values).
131 1) open UART connection
133 2) register state callback for getting roomba sensor data
135 3) while(input values or cancel)
{ drive() / turn()
}
137 4) drive() / turn() use wiselib::ControlledMotion<OsModel,
138 wiselib::RoombaModel> for moving specified angle/distance; and ask for measured
139 values and write to external log file, including battery status, roomba/wiselib
140 internal angles/distances (ticks), svn revision, floor type, roomba ID
142 additionally, mean correction test uses
143 CorrectedMeanMotion from corrected
\_mean\_motion.h, implements same concept like
144 wiselib::ControlledMotion and takes care of target value by using the
145 calculated fit function .
147 additionally, soft start/stop test uses
148 SoftStartMotion from soft
\_start\_motion.h, implements same
149 concept like wiselib::ControlledMotion and takes care of increasing/decreasing
153 \label{sec:impl:eval
}
156 bash/perl scripts in wiselib/trunk/pc
\_apps/roomba
\_tests/logs, using gnuplot
158 graph.sh: create
3d plots (input value, input velocity, measured value) from
159 original behvaiour data, including fit function calculated by GNU R statistics
160 software, for
{carpet floor, laminate floor
} $
\times$
{drive straight, turn on
163 graph-mean.sh: do the same for mean correction data, including fit function from
166 graph-soft.sh: do the same for soft start/stop data, including fit function from
169 graph-mean-soft.sh:
3d plot with mean correction and soft start/stop data, for
172 graph-errorlines.sh: create
2d plots input value -> measured value, with
173 multiple velocities in each graph. also split graphs up for
{carpet floor,
174 laminate floor
} $
\times$
{drive straight, turn on spot
}. no fit function.