checkpoint
[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-American 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 to reveal 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 center line, so the Roomba tilts 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 center 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 crescent-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 interrupters. 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 maximum 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 it. This leads to the effect that the springs used for the wheel drop
73 sensors are not in balance anymore and push the Roomba upwards, so it tilts more
74 to the front when accelerating forwards. There is also a sensor on the underside
75 \index{Roomba!dirt sensor} for detecting particularly dirty regions of the
76 floor. It 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 is about
83 to run out
84 of energy. Therefore, it uses a special infrared sensor mounted on top of the
85 Roomba, which can see in all directions and is able to detect the home
86 base by looking
87 for a special infrared signal the home base\index{Roomba!home base} emits. The
88 same principle is used for so-called ``virtual walls''\index{virtual wall} which
89 can be placed by the user in regions the Roomba should not move into.
90
91 \subsection{Behavior}
92 \paragraph{Original Behavior}
93 The Roomba normally follows its own, non-customizable algorithm to detect dirt
94 and clean rooms. It is kind of a random walk\index{random walk}, controlled by
95 the internal logic, which tries to keep the Roomba away from dangers like
96 stairs and walls (by evaluating the cliff and bump sensors), and direct it to
97 the more dusty regions of the room (by using the dirt sensor). The random walk
98 concept allows a more or less complete coverage of the room, given the time for
99 cleaning is large enough, while at the same only needing very little information
100 about the environment. Of course, that concept is not very efficient when it
101 comes to cleaning rooms, but cleaning time is not necessarily the constraining
102 factor, and the robot still saves the human some time.
103
104 \paragraph{Roomba Open Interface}
105 \label{sec:roi}
106 However, robots of the Roomba 500 series are also easily controllable over a
107 serial port, which provides a two-way communication at 5~V~\acs{TTL} levels over
108 a 7-pin mini-\acs{DIN} connector, with a speed of either 19,200 or 115,200 Baud,
109 in mode \acused{8N1} \ac{8N1} (\acl{8N1}). Over this serial port, the Roomba
110 speaks a specified protocol, called the \acused{ROI}\definition{Roomba Open
111 Interface} (\acs{ROI})~\cite{irobot-oi}, which allows the user to interact with
112 the robot's internal logic, reading its sensor values, and control its movements
113 and cleaning behavior.
114
115 After starting the communication with the Roomba by sending the \cmd{Start}
116 command, the robot is in a state called \definition{Passive mode}. In this mode,
117 the user cannot control the robot by himself, but the internal logic defines
118 his movement and cleaning behavior. However, the user is able to read the
119 internal sensors in this mode. The \ac{ROI} then allows the user to set the
120 Roomba into two different modes:
121 \begin{itemize}
122 \item In \definition{Safe mode}, the Roomba monitors the wheel drop, cliff
123 and internal charger sensors, and reverts into Passive mode if safety
124 conditions occur, so the Roomba is not harmed.
125 \item In \definition{Full mode}, the user has full control over the Roomba,
126 and has to take care not to harm the Roomba by evaluating the wheel drop,
127 cliff and internal charger sensors by himself.
128 \end{itemize}
129
130 In particular, every command is assigned an \ac{opcode} of one byte length,
131 followed by a fixed amount of bytes as parameters which depend on the opcode.
132 For example, to start the communication with the Roomba, the \cmd{Start}
133 command has to be sent, which has the \opcode{0x80} and takes no parameters. The
134 \cmd{Safe} command to put the Roomba into safe mode has \opcode{0x83}, and like
135 the \cmd{Full} command with \opcode{0x84}, it takes no parameters.
136
137 For example, to start the communication with the Roomba and set it into Safe
138 mode, one would send the following bytes over the serial interface:
139 \begin{verbatim}
140 0x80, // Start command
141 0x83 // Safe command
142 \end{verbatim}
143 Then, additional commands can be sent over the \ac{ROI}, like actuator commands
144 for controlling the Roomba's driving behavior.
145
146 \paragraph{Actuator commands}
147 The \ac{ROI} specifies various actuator commands to control the Roomba's wheels,
148 brushes and \ac{LED} displays, and let the Roomba play tunes. However, the
149 central command needed for the experiments in this thesis is the \cmd{Drive}
150 command, \opcode{0x89}, which takes 4 additional bytes as parameter: the first
151 two bytes specify the velocity with which the Roomba's center point should travel
152 while driving, and the third and fourth bytes specify the radius of the arc the
153 Roomba's center point should describe. The Roomba then calculates the required
154 right and left wheel velocities internally without further interference of the
155 user.
156
157 The velocity is interpreted in mm/s, the value can range from -500~mm/s to
158 500~mm/s, with negative values implying backwards movement -- it is to be noted
159 however that velocities between -10~mm/sec and 10~mm/sec are ignored, since the
160 wheel motors cannot operate with that small velocities. The radius is
161 interpreted in mm, ranging from -2000~mm to 2000~mm. Negative values make the
162 Roomba turn towards the right, whereas positive values make it turn towards the
163 left. There are also four special values for the radius: \magicvalue{1} makes
164 the Roomba turn on the spot in counter-clockwise direction, \magicvalue{-1}
165 makes the Roomba turn on the spot in clockwise direction, and
166 \magicvalue{0x7fff} and \magicvalue{0x8000} make it drive straight.
167
168 For example, to drive straight with a velocity of 1000~mm, one would send the
169 following bytes over the serial interface:
170 \begin{verbatim}
171 0x89, // Drive command
172 0x03, 0xe8 // parameter velocity: 0x03e8 == 1000
173 0x80, 0x00 // parameter radius: special value "straight"
174 \end{verbatim}
175
176 A slight disadvantage of the \ac{ROI} \cmd{Drive} command is that the robot is
177 modeled without a time awareness. In the previous example, the Roomba would keep
178 on driving until it runs out of energy, or a safety condition occurs which
179 causes the Roomba to revert into Passive mode, or a new \cmd{Drive} command with
180 the velocity parameter set to zero is sent. Thus, if the user wants to drive a
181 specific distance, he has to calculate the time the robot needs to travel that
182 distance, measure the time, and stop the robot after that time interval has
183 passed. When using inaccurate timers or the system controlling the Roomba is
184 overloaded, this can lead to errors in movement. Because of that, it is
185 appropriate to monitor the Roomba's movement, for example with its internal
186 sensors.
187
188 \paragraph{Input commands}
189 The Roomba~500 series features a total of 49 different sensor values. Beyond the
190 sensors mentioned above, there are also some internal values concerning battery
191 charge, capacity, and temperature, motor currents, and even some more (or less)
192 useful variables like the characters read from the infrared remote control, the
193 current \ac{ROI} mode or the currently playing song. Anyway, there is also the
194 possibility to query the traveled distance, the turned angle and the internal
195 encoder counts (``ticks'') for the left and right wheel. Each sensor value is 1
196 or 2 bytes long and is assigned a specific \definition{packet ID}. Some packet
197 IDs also describe groups of multiple sensor values sent together.
198
199 Sensor values can be retrieved either by explicit polling or by enabling a
200 stream of values that is sent every 15~ms. Explicit polling works through the
201 \cmd{Sensors} command (\opcode{0x8e}), which takes the packet ID of a single
202 sensor as parameter, or through the \cmd{Query List} (\opcode{0x95}) command,
203 which takes multiple packet IDs headed by the total number of requested packets
204 as parameter. Both of these functions send back the requested values directly.
205
206 By using the \cmd{Stream} command (\opcode{0x94}), it is possible to receive
207 the requested sensor values every 15~ms. This is very convenient for real-time
208 behavior, when the sensor values have to be evaluated very often. As the
209 \cmd{Query List} command, the \cmd{Stream} command takes the total number of
210 packet IDs followed by the requested packet IDs as parameter. It sends back the
211 sensor values in packets using the byte format\\
212 \verb|0x13|, $\mathtt{n, p_1, v(p_1), p_2, v(p_2), \ldots, p_n, v(p_n),
213 c}$, where:
214 \begin{itemize}\setlength{\itemsep}{0pt}
215 \item $n$ is the number of bytes sent back, excluding $n$ and $c$,
216 \item $p_i$ is a requested packet ID, $i = 1, \ldots, n$
217 \item $v(p_i)$ is the value of the packet with the packet ID $p_i$
218 \item $c$ is a checksum, with
219 $\sum_{i=1}^n\left(p_1 + v(p_1)\right) + c + n \equiv 0 \mod 256$
220 \end{itemize}
221 Example: The following byte sequence requests data from the left cliff
222 signal (sensor packet~ID \magicvalue{0x1d}) and virtual wall sensor (packet~ID
223 \magicvalue{0x0d}):~\cite{irobot-oi}
224 \begin{verbatim}
225 0x94, // Stream command
226 0x02, // parameter: 2 packets following
227 0x1d, 0x0d // parameter: request packets 0x1d and 0x0d
228 \end{verbatim}
229 The Roomba then would return a packet with the following format every
230 15~ms:\label{sec:roi-stream-packet}
231 \begin{verbatim}
232 0x13, // Header byte
233 0x05, // 5 bytes following, except checksum
234 0x1d, // Packet ID 0x1d following
235 0x02, 0x19, // Data for Packet ID 0x1d (2 byte)
236 0x0d, // Packet ID 0x1d following
237 0x00, // Data for Packet ID 0x0d (1 byte)
238 0xb6 // Checksum: 0x5+0x1d+0x2+0x19+0xd+0x0+0xb6 = 0x100
239 \end{verbatim}
240
241 \paragraph{Latency}
242 On the connection, there is a certain latency between the time the command is
243 sent to the Roomba and the time the Roomba receives this command and carries out
244 the motion. At 19,200 baud, mode \ac{8N1}, the transfer of a 5-byte \cmd{Drive}
245 command needs $(5 \times 9) \div 19200 = 2.3$~ms. The time the Roomba
246 logic needs to process the command is not mentioned in the \ac{ROI}
247 Specification, and there was no way to measure it precisely. %It is however
248 %short enough that a human would describe it as ``instant''.
249
250 The same latency of course also exists in the opposite directions when the
251 Roomba is sending sensor data to the user. However, the sensor data are sent by
252 the Roomba every 15~ms (which is the internal speed at which the data is
253 updated from the sensors) and according to the wheel's maximum velocity of
254 500~mm/s (which means that a sensor data packet is received every $7.5$~mm when
255 driving at this speed), this is acceptable for real-time evaluation of the data.
256
257 \paragraph{Usage}
258 In our setup, an iRobot Roomba~530 is used as an instance of an autonomous,
259 mobile robot to conduct the experiments described afterwards. For that, the
260 Roomba's movements are controlled over a netbook mounted on top of the Roomba
261 (cf.~Figure~\ref{fig:roombasetup}), which is running Wiselib code. The Wiselib
262 code in turn uses the \ac{ROI} and especially the \cmd{Stream} and \cmd{Drive}
263 command to control the Roomba.
This page took 0.059377 seconds and 5 git commands to generate.