2 The
\definition{Wiselib
}\cite{wiselib
} is a C++
\index{C++
} algorithm library for
3 sensor networks, containing for example algorithms for routing, localization and
4 time synchronization, and is strongly focused on portability and cross-platform
5 development. In particular, it allows the user to develop applications that run
6 on different hardware platforms without the need to change the code, and it
7 strongly uses C++ templates to achieve that feature. Amongst the supported
8 platforms are diverse sensor node platforms, like iSense, Contiki and TinyOS,
9 but there are as well implementations for the diverse x86-compatible Personal
10 Computer platforms, and the Shawn sensor network simulator.
12 \subsection{Architecture
}
13 \paragraph{Concepts and Models
}
14 Wiselib makes strong uses of
\definition{concepts
} and
\definition{models
} as
15 central design objects. Concepts serve as an informal description of interfaces,
16 only existent in documentation, defining expected parameters and types. Models
17 however implement these interfaces in C++ code while fulfilling their
18 specification. The Wiselib algorithms can in turn rely on the concepts as a
19 generic specification, and take models as template parameters to use their
20 functionality, so a function call will be immediately resolved to a specific
21 model at compile time without the need for an additional function call as it is
22 the case with virtual inheritance. Furthermore, this also allows usage on
23 platforms which do not have support for C++, as the bytecode generated by the
24 compiler does not include C++ specific extensions (no virtual function tables,
25 and templates are resolved at compile time) and can be linked against any
28 This makes cross-platform development easily possible. For example, to implement
29 a routing algorithm, one can rely on the concept of a Radio to send and receive
30 data packets, without needing to implement code specific to the used radio
31 hardware. The users of that routing algorithm can now choose which radio model
32 they want to use, according to their needs and the underlying hardware, provided
33 that their radio model also implements the same Radio concept that the routing
38 \includegraphics[width=
.8\textwidth]{images/Wiselib-Arch.pdf
}
39 \caption{Wiselib architecture
\label{fig:wiselib-arch
}}
41 Besides algorithms, and basic concepts and models, the Wiselib also consists of
42 two other main parts: the internal interface and the external interface (see
43 Figure
\ref{fig:wiselib-arch
}).
45 \paragraph{External Interface
}
46 The
\definition{External Interface
} provides access to the underlying
\ac{OS
},
47 like iSense, Contiki, Shawn
\ldots and defines concepts like a Radio or a Timer.
48 Thus, the concepts are as generic as possible to match all supported operating
49 systems and provide a light-weight abstraction to the underlying
\ac{OS
}. These
50 concepts sometimes extend the generic concepts, for example there is a TxRadio
51 which has the ability to set the transmission power on the radio. The models
52 (for example an iSenseRadioModel or a ShawnTimerModel) implement these concepts
53 on the specific operating system, and can be passed around as template
56 \paragraph{Internal Interface
}
57 The
\definition{Internal Interface
} defines concepts and models for data
58 structures that can be used in algorithms. This allows to specialize for
59 restricted platforms; for instance a wireless sensor node without dynamic memory
60 management can use a static implementation of lists and other containers,
61 whereas a full-grown desktop can use the dynamic implementation provided by the
62 C++
\ac{STL
}. For this purpose, the Wiselib also contains the
63 \ignoreoutput{\ac{pSTL
}}\definition{\acl{pSTL
}} (
\acs{pSTL
}) which implements a
64 subset of the
\ac{STL
} without the use of dynamic memory allocation.
66 \paragraph{Stackability
}
67 Another central design principle used in the Wiselib is
68 \definition{stackability
}, which describes the possibility to stack
69 implementations of the same concept, thereby building a layered structure. For
70 example, one could stack a cryptography algorithm on top of a radio model, which
71 both implement the Radio concept. In this case, the cryptography layer doesn't
72 have to know anything at all about the underlying implementation, as long as it
73 can use the Radio concept of the underlying layer. And it can even provide the
74 same interface to a possibly higher layer in order to provide transparent packet
75 de- and encryption over the radio.
77 \subsection{Roomba Control
}
78 Even more interesting is the fact that the Wiselib includes code to control an
79 iRobot Roomba
\index{Roomba
} over a serial interface, and getting access to its
80 internal sensor data, using the
\acl{ROI
}\index{\acl{ROI
}} mentioned earlier.
81 For this purpose, it defines two concepts for Robot Motion:
83 \paragraph{TurnWalkMotion concept
}\index{TurnWalkMotion (concept)
}
84 This concept represents a simple robot that can turn on the spot and walk
85 straight, without automatic stopping.
89 \item[\code{velocity
\_t}] Type for velocity measurement
90 \item[\code{angular
\_velocity\_t}] Type for angular velocity measurement
92 \item \todo{clearpage?
} Methods:
94 \item[\code{int turn(angular
\_velocity\_t)
}] turn the robot with a
95 constant angular velocity
96 \item[\code{int move (velocity
\_t)
}] move the robot straight with a
98 \item[\code{int stop()
}] stop the robot
99 \item[\code{int wait
\_for\_stop()
}] hold the execution until the robot has
104 \paragraph{Odometer concept
}\index{Odometer (concept)
}
105 This concept represents an Odometer which tracks motions over time.
106 Whenever the object turns or moves, internal counters will adjust their
107 guessing of the object's traveled distance and current orientation.
111 \item[\code{angle
\_t}] Type for angle measurement
112 \item[\code{distance
\_t}] Type for distance measurement
116 \item[\code{angle
\_t angle()
}] return the current angle
117 \item[\code{int reset
\_angle()
}] reset the angle of the object
118 \item[\code{distance
\_t distance()
}] return the current distance
119 \item[\code{int reset
\_distance()
}] reset the distance of the object
120 \item[\code{int register
\_state\_callback (T *obj)
}] register a callback
121 that gets called when the state changes
122 \item[\code{int unregister
\_state\_callback (int)
}] unregister a
123 previously registered callback
124 \item[\code{int state()
}] return the current state
128 \paragraph{ControlledMotion class
}\index{ControlledMotion (class)
}
129 On top of the TurnWalkMotion and Odometer concepts builds the
130 \definition{ControlledMotion
} model. It takes implementations of each of these
131 concepts as template parameters and extends the simple turn-and-walk paradigm by
132 a temporal dimension, which let the robot stop after a specific time interval.
133 In particular, it provides the following methods:
135 \item[\code{int move
\_distance(distance
\_t, velocity
\_t)
}] move the robot
136 straight by a given distance with a given velocity
137 \item[\code{int turn
\_about(angle
\_t, angular
\_velocity\_t)
}] turn the robot
138 about a given angle with a given angular distance
139 \item[\code{int turn
\_to(angle
\_t, angular
\_velocity\_t)
}] turn the robot
140 to a given orientation with a given angular distance
143 The class first registers a callback function at the given Odometer instance,
144 and then uses its distance and angle values to control the robot over the
145 TurnWalkMotion instance. Everytime the state of the robot changes (i.~e. new
146 data from its sensors are received), it compares the new actual values with the
147 target values given by the user through the functions above, and if the actual
148 values exceed the target values, the robot is stopped.
150 \paragraph{Underlying Roomba Implementation
}
151 The actual communication with the Roomba is done in the
\definition{RoombaModel
}
152 class. It implements the aforementioned TurnWalkMotion and Odometer concepts
153 and therewith allows the interaction with a ControlledMotion instance. In
154 particular, it manages the serial communication with the Roomba and translates
155 the function calls
\code{turn()
},
\code{move()
} and
\code{stop()
} of the
156 TurnWalkMotion concept to the according parameters for the
\ac{ROI
} \cmd{Drive
}
157 command, reads a subset of the Roomba's sensors and presents the sensor data to
158 the user, and, while implementing the Odometer concept, calculates the covered
159 distance and angle from the Roomba's right and left wheel rotations.
161 The sensor data is read from the Roomba using the
\cmd{Stream
} command on the
162 \ac{ROI
}, which results in a sensor data packet (see Section
163 \ref{sec:roi-stream-packet
}) every
15~ms, and $
66.67$ packets per second. At a
164 speed of
19,
200 baud in mode
8N1 (
8 data bits, no parity,
1 start/stop bit), the
165 maximum size of a data packet is $
19,
200 \div (
66.67 \times 9) =
32$ byte,
166 so at the moment only the sensor packets
\emph{encoder counts left/right
}
167 (IDs~
\magicnumber{0x2b},
\magicnumber{0x2c},
2+
2 bytes),
\emph{battery
168 voltage/current/charge/capacity
} (IDs~
\magicnumber{0x16},
\magicnumber{0x17},
169 \magicnumber{0x19},
\magicnumber{0x1a},
2+
2+
2+
2 bytes) are streamed, which add
170 up to
18 data bytes +
3 header/checksum bytes. There has currently been no
171 success yet in communicating at the higher speed of
115,
200 baud.
173 Also there has been research to use the distance and angle values that the
174 Roomba itself provides (sensor packet~IDs
\magicnumber{0x13} and
175 \magicnumber{0x14}). However, according to the
\ac{ROI
} Specification these
176 values are integer values, and the value is reset to zero every time it is read.
177 By using the
\cmd{Stream
} command on the
\ac{ROI
} and therefore reading these
178 values every
15~ms, the Roomba cannot move fast enough to increment these values
179 to
\magicnumber{1}, so everytime
\magicnumber{0} is read. It is obvious that
180 these sensor values are not suited for such rapid evaluations, and can only be
181 used for larger distances and angles. Nevertheless, since the Wiselib Roomba
182 control needs to keep track of the Roomba's current position and orientation as
183 fast as possible to maintain a certain accuracy in movement, the distance and
184 angle values as provided by the Roomba itself cannot be used. On the other hand,
185 working with the Roomba's wheel encoder counts (sensor packet~IDs
186 \magicnumber{0x2b} and
\magicnumber{0x2c}) has proven itself quite acceptable.
187 After a few test runs, the number of encoder counts per~mm for straight
188 walks turned out as $
2.27$, and for turning on the spot, $
2.27 \times 115 =
189 261.05$ encoder counts per radian, which is the number of encoder counts per~mm
190 multiplicated with half the Roomba's wheelbase. So when new sensor data is read
191 each
15~ms, the RoombaModel implementation calculates the covered distance and
192 the turned angle from these values.
195 \todo{cite Wisebed book chapter on Roomba code
}
196 \todo{which roomba sensors were used?
}