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