checkpoint, including makeindex stylefile for index section headers
[bachelor-thesis/written-stuff.git] / Ausarbeitung / roomba.tex
1 \section{iRobot Roomba}
2 Originally, the \definition{Roomba} is an autonomous vacuum cleaning robot,
3 manufactured by the US-based company \definition{iRobot}. The 500 series
4 currently represents the third generation of iRobot's cleaning robots, and the
5 first generation of robots controllable over an external interface.
6
7 \subsection{Hardware design}
8 \begin{SCfigure}
9 \centering
10 \includegraphics[width=.5\textwidth]{images/Roomba-Diagram.pdf}
11 \caption[Diagram of the Roomba 500 series]{Diagram of the Roomba 500 series,
12 view from below\label{fig:roomba-diagram} \\
13 1:~front~caster, 2:~battery, 3:~side~brush, 4:~main~wheels, 5:~main~brush,
14 6:~vacuum~bin, 7:~front~bumper, 8:~cliff~sensors}
15 \end{SCfigure}
16
17 The Roomba lives in a cylindrical case with diameter of about 34~cm and height
18 of about 8~cm, so it can crawl easily under furniture for cleaning.
19 Figure~\ref{fig:roomba-diagram} shows a diagram of the Roomba seen from below.
20
21 The top side features several buttons which vary between the different models,
22 most notably the ``Clean'' and ``Spot'' buttons for manual control of the
23 cleaning routine, and the ``Dock'' button to send the Roomba to its home base.
24 The cover on the top side can be removed, and covers the connector for
25 the \ac{ROI} which is discussed in Section~\ref{sec:roi}.
26
27 On the side, a socket for a coaxial \acs{DC} power connector can be found, which
28 is used for external charging.
29
30 \paragraph{Wheels}
31 The Roomba has two rubberized main wheels which are positioned slightly behind
32 the centerline, so the Roomba leans forward due to gravity, and a small caster
33 on the front to prevent it from sliding on the floor. The space between the
34 cmainenter of the main wheels (the \definition{wheel base}) is 230~mm. The main
35 wheels can be controlled over two independent motors, each one allowing to turn
36 the connected wheel with a minimum of 10~mm/s and a maximum of 500~mm/s in each
37 direction. One of the main wheel motors consumes about 300~mA in their slowest
38 rotation speed, and about 1000~mA when driving with normal speed. Each wheel is
39 also equipped with a drop sensor that tells if the respective wheel has dropped
40 into a hole or similar, and does not reach the ground anymore. These sensors are
41 realized with a spring pushing the wheel towards the ground, with the spring
42 force adjusted to the Roomba's weight, and a micro switch which triggers if the
43 wheel drops below a specified level. Furthermore, both wheels feature rotating,
44 toothed discs, which in conjunction with an LED and a photo-electric resistor
45 act as an optical interrupter. This system can be used to measure the wheel's
46 current speed by counting the optical interruptions the wheel causes while
47 moving.
48
49 \paragraph{Brushes}
50 In addition to the wheel motors, the Roomba has a motor which operates the
51 vacuum brush, and a small motor on the front connected to a side brush, to allow
52 cleaning of room corners.
53
54 \paragraph{Bumper shield}
55 Since the main movement direction in normal operation is forward, the front of
56 the Roomba consists of a crecent-shaped bumper shield which contains several
57 sensors. This bumper\index{Roomba!bumper} is spring-loaded and on the one
58 hand absorbs shock to reduce damage, on the other hand, it allows the Roomba to
59 detect obstacles in front of it, both via infrared sensors as well as by
60 mechanical means. There are two sensors for mechanical bump detection, located
61 30° to the left and to the right of the bumper's center, each implemented as
62 photo-electrical interruptors. Additionally, six infrared sensors are unevenly
63 distributed over the bumper, facing away from it in a star-like manner. Each one
64 of them allows the Roomba to recognize objects in a maxmimum distance of 10~cm.
65 Finally, the bumper shield contains four infrared sensors facing downwards,
66 acting as cliff sensors \index{Roomba!cliff sensor} to recognize steps or
67 similar chasms which could be dangerous for the Roomba to drive towards.
68
69 The back part of the Roomba contains the main vacuum brush\index{Roomba!vacuum
70 brush}, and the reservoir for holding dirt. Both of them can be removed, though
71 the removal of the main brush reduces the Roomba's weight and slightly
72 unbalances the Roomba so the springs used for the wheel drop sensors are not in
73 balance anymore and push the Roomba upwards, so it tilts more to the front when
74 accelerating forwards. There is also a sensor on the underside
75 \index{Roomba!dirt sensor} for detecting particularly dirty regions of the
76 floor, which is implemented as a capacitive touch sensor.
77
78 \paragraph{Battery}
79 The battery\index{Roomba!battery} is placed in the front part behind the bumper,
80 it is a rechargeable \ac{NiMH} battery and holds a capacity of 3300~mAh which
81 lasts for about 90 to 120 minutes under normal operation. The Roomba can also
82 find its home base and charge itself when it has finished cleaning or runs out
83 of energy by using a special infrared sensor mounted on top of the Roomba. This
84 sensor can see in all directions and is able to detect the home base by looking
85 for a special infrared signal the home base\index{Roomba!home base} emits. The
86 same principle is used for so-called ``virtual walls''\index{virtual wall} which
87 can be placed by the user in regions the Roomba should not move into.
88
89 \subsection{Behaviour}
90 \paragraph{Original Behaviour}
91 The Roomba normally follows its own, non-customizable algorithm to detect dirt
92 and clean rooms. It is kind of a random walk\index{random walk}, controlled by
93 the internal logic, which tries to keep the Roomba away from dangers like
94 stairs and walls (by evaluating the cliff and bump sensors), and direct it to
95 the more dusty regions of the room (by using the dirt sensor). The random walk
96 concept allows a more or less complete coverage of the room, given the time for
97 cleaning is large enough, while at the same only needing very little information
98 about the environment. Of course, that concept is not very efficient when it
99 comes to cleaning rooms, but cleaning time is not neccessarily the constraining
100 factor, and the robot still saves the human some time.
101
102 \paragraph{Roomba Open Interface}
103 \label{sec:roi}
104 However, robots of the Roomba 500 series are also easily controllable over a
105 serial port, which provides a two-way communication at 5~V~\acs{TTL} levels over
106 a 7-pin mini-\acs{DIN} connector, with a speed of either 19,200 or 115,200 Baud,
107 in mode \acused{8N1} \ac{8N1} (\acl{8N1}). Over this serial port, the Roomba
108 speaks a specified protocol, called the \acused{ROI}\definition{Roomba Open
109 Interface} (\acs{ROI})~\cite{irobot-oi}, which allows the user to interact with
110 the robot's internal logic, reading its sensor values, and control its movements
111 and cleaning behaviour.
112
113 After starting the communication with the Roomba by sending the \cmd{Start}
114 command, the robot is in a state called \definition{Passive mode}. In this mode,
115 the user cannot control the robot by himself, but the internal logic defines
116 icants behaviour. However, the user is able to read the internal sensors. The
117 \ac{ROI} then allows the user to set the Roomba into two different modes:
118 \begin{itemize}
119 \item In \definition{Safe mode}, the Roomba monitors the wheel drop, cliff
120 and internal charger sensors, and reverts into Passive mode if safety
121 conditions occur, so the Roomba is not harmed.
122 \item In \definition{Full mode}, the user has full control over the Roomba,
123 and has to take care not to harm the Roomba by evaluating the wheel drop,
124 cliff and internal charger sensors by himself.
125 \end{itemize}
126
127 In particular, every command is assigned an \ac{opcode} of one byte length,
128 followed by a fixed amount of bytes as parameters which depend on the opcode.
129 For example, to start the communication with the Roomba, the \cmd{Start}
130 command has to be sent, which has the \opcode{0x80} and takes no parameters. The
131 \cmd{Safe} command to put the Roomba into safe mode has \opcode{0x83}, and like
132 the \cmd{Full} command with \opcode{0x84}, it takes no parameters.
133
134 For example, to start the communication with the Roomba and set it into Safe
135 mode, one would send the following bytes over the serial interface:
136 \begin{verbatim}
137 0x80, // Start command
138 0x83 // Safe command
139 \end{verbatim}
140 Then, additional commands can be sent over the \ac{ROI}, like actuator commands
141 for controlling the Roomba's driving behaviour.
142
143 \paragraph{Actuator commands}
144 The \ac{ROI} specifies various actuator commands to control the Roomba's wheels,
145 brushes and \ac{LED} displays, and let the Roomba play tunes. However, the
146 central command needed for the experiments in this thesis is the \cmd{Drive}
147 command, \opcode{0x89}, which takes 4 additional bytes as parameter: the first
148 two bytes specify the velocity that the Roomba's centerpoint should travel with
149 while driving, and the third and fourth bytes specify the radius of the arc the
150 Roomba's centerpoint should describe. The Roomba then calculates the required
151 right and left wheel velocities internally without further interference of the
152 user.
153
154 The velocity is interpreted in mm/s, the value can range from -500~mm/s to
155 500~mm/s, with negative values implying backwards movement. The radius is
156 interpreted in mm, ranging from -2000~mm to 2000~mm. Negative values make the
157 Roomba turn toward the right, whereas positive values make it turn toward the
158 left. There are also four special values for the radius: \magicvalue{1} makes
159 the Roomba turn on the spot in counter-clockwise direction, \magicvalue{-1}
160 makes the Roomba turn on the spot in clockwise direction, and
161 \magicvalue{0x7fff} and \magicvalue{0x8000} make it drive straight.
162
163 For example, to drive straight with a velocity of 1000~mm, one would send the
164 following bytes over the serial interface:
165 \begin{verbatim}
166 0x89, // Drive command
167 0x03, 0xe8 // parameter velocity: 0x03e8 == 1000
168 0x80, 0x00 // parameter radius: special value "straight"
169 \end{verbatim}
170
171 A little disadvantage of the \ac{ROI} \cmd{Drive} command is that the robot is
172 modeled without a time awareness. In the previous example, the Roomba would keep
173 on driving until it runs out of energy, or a safety condition occurs which
174 causes the Roomba to revert into Passive mode, or a new \cmd{Drive} command with
175 the velocity parameter set to zero is sent. Thus, if the user wants to drive a
176 specific distance, he has to calculate the time the robot needs to travel that
177 distance, measure the time, and stop the robot after that time interval has
178 passed. When using inaccurate timers or the system controlling the Roomba is
179 overloaded, this can lead to errors in movement. Because of that, it is
180 appropriate to monitor the Roomba's movement, for example with its internal
181 sensors.
182
183 \paragraph{Input commands}
184 The Roomba~500 series features a total of 49 different sensor values. Among the
185 sensors mentioned above, there are also some internal values concerning battery
186 charge, capacity, and temperature, motor currents, and even some more (or less)
187 useful variables like the characters read from the infrared remote control, the
188 current \ac{ROI} mode or the currently playing song. Anyway, there is also the
189 possibility to query the travelled distance, the turned angle and the internal
190 encoder counts ("`ticks"') for the left and right wheel. Each sensor value is 1
191 or 2 bytes long and is assigned a specific \definition{packet ID}. Some packet
192 IDs also describe groups of multiple sensor values sent together.
193
194 Sensor values can be retrieved either by explicit polling or by enabling a
195 stream of values that is sent every 15~ms. Explicit polling works through the
196 \cmd{Sensors} command (\opcode{0x8e}), which takes the packet ID of a single
197 sensor as parameter, or through the \cmd{Query List} (\opcode{0x95}) command,
198 which takes multiple packet IDs headed by the total number of requested packets
199 as parameter. Both of these functions send back the requested values directly.
200
201 By using the \cmd{Stream} command (\opcode{0x94}), it is possible to receive
202 the requested sensor values every 15~ms. This is very convenient for real-time
203 behaviour, when the sensor values have to be evaluated very often. As the
204 \cmd{Query List} command, the \cmd{Stream} command takes the total number of
205 packet IDs followed by the requested packet IDs as parameter. It sends back the
206 sensor values in packets using the following format:\\
207 \verb|0x13|, $n, p_1, v(p_1), p_2, v(p_2), \ldots, p_n, v(p_n), c$\\
208 where:
209 \begin{description}
210 \item[$n$] is the number of bytes sent back, excluding $n$ and $c$,
211 \item[$p_i$] is a requested packet ID, $i = 1, \ldots, n$
212 \item[$v(p_i)$] is the value of the packet with the packet ID $p_i$
213 \item[$c$] is a checksum, with
214 $\sum_{i=1}^n\left(p_1 + v(p_1)\right) + c + n \equiv 0 \mod 256$
215 \end{description}
216 Example: The following byte sequence requests data from the left cliff
217 signal (packet~ID \magicvalue{0x1d}) and virtual wall sensor (packet~ID
218 \magicvalue{0x0d}):~\cite{irobot-oi}
219 \begin{verbatim}
220 0x94, // Stream command
221 0x02, // parameter: 2 packets following
222 0x1d, 0x0d // parameter: request packets 0x1d and 0x0d
223 \end{verbatim}
224 The Roomba then would return a packet with the following format every
225 15~ms:\label{sec:roi-stream-packet}~\cite{irobot-oi}
226 \begin{verbatim}
227 0x13, // Header byte
228 0x05, // 5 bytes following, except checksum
229 0x1d, // Packet ID 0x1d following
230 0x02, 0x19, // Data for Packet ID 0x1d (2 byte)
231 0x0d, // Packet ID 0x1d following
232 0x00, // Data for Packet ID 0x0d (1 byte)
233 0xb6 // checksum: 0x5 + 0x1d + 0x2 + 0x19 + 0xd + 0x0 + 0xb6 = 0x100
234 \end{verbatim}
235
236 \paragraph{Latency}
237 On the connection, there is a certain latency between the time the command is
238 sent to the Roomba and the time the Roomba receives this command and carries out
239 the motion. At 19,200 baud, mode \ac{8N1}, the transfer of a 5-byte \cmd{Drive}
240 command needs $(5 \times 9) \div 19200 = 2.3$~ms. The time the Roomba
241 logic needs to process the command is not mentioned in the \ac{ROI}
242 Specification, and there was no way to measure it sufficiently. It is however
243 short enough that a human would describe it as ``instant''.
244
245 The same latency of course also exists in the opposite directions when the
246 Roomba is sending sensor data to the user. However, the sensor data are sent by
247 the Roomba every 15~ms (which is the internal speed at which the data is
248 updated from the sensors) and according to the wheel's maximum velocity of
249 500~mm/s (which means that a sensor data packet is received every $0.03$~mm when
250 driving at this speed), this is acceptible for real-time evaluation of the data.
251
252
253 In our setup, an iRobot Roomba~530 is used as an instance of an autonomous,
254 mobile robot to conduct the experiments described afterwards. For that, the
255 Roomba's movements are controlled over a netbook mounted on top of the Roomba
256 (cf.~Figure~\ref{fig:roombasetup}), which is running Wiselib code. The Wiselib
257 code in turn uses the \ac{ROI} and especially the \cmd{Stream} and \cmd{Drive}
258 command to control the Roomba.
This page took 0.053514 seconds and 5 git commands to generate.