Christian Decker, 2005 – Particle Programming
2
Personal Introduction
Christian Decker • Telecooperation Office (TecO),
University of Karlsruhe, Germany • 3rd year PhD student • Since 6 years affiliated w/ TecO • Research interests
– Software for ubiquitous computing systems
– Operating systems for wireless sensor nodes
• Various projects – AwareGoods, SmartShelf, Smart-Its, DigiClip, CoBIs
Christian Decker, 2005 – Particle Programming
3
Co-Authors
• Manabu Isomura (KDDI Research) • Till Riedel (PhD student, TecO) • Emilian Peev, Philipp Scholl,
Thomas Morper (TecO student workers)
Emilian Philipp
Manabu
Till
Christian Decker, 2005 – Particle Programming
4
What is a Particle Computer?
• Tiny wireless sensor node • Integrated in everyday objects • Enabling technology for Ubiquitous Computing
applications
Particle Computer (20 x 17mm)
Sensor data from a Particle Computer within a PDA application
Christian Decker, 2005 – Particle Programming
5
Course Mission
To enable you to build complete applications using Particle Computers
uPart Sensor nodes & Network
Data processing
Application front-end
?
Data provider
Data reasoning
Action
Application
Christian Decker, 2005 – Particle Programming
6
Objectives and Target Group
• Objectives – Insight into TecO‘s Particle Computer System – Sensor basics – Introduction in the Particle software tool suite and
programming
• Target Group – Student with interest in Ubicomp and Sensor
networks – Required programming experiences, e.g. Java,
C/C++
Christian Decker, 2005 – Particle Programming
7
Course Outline
• Introduction • Particle System Architecture • Sensors • Data Processing • Software and Tools • Exercise
Christian Decker, 2005 – Particle Programming
9
A Brief History of Particle Computer
• Roots: EC project „Smart-Its“ (2001-2003) • Goal: Augment mundane everyday objects by
small embedded electronic devices to form digital relationships
• Results: wireless sensor platforms
Particle 1.01 (TecO)
BTNode rev2 (ETH)
DIY Smart-It (Lancs)
Christian Decker, 2005 – Particle Programming
10
Particle Zoo
Sensor board SSmall • 3-axis acceleration, temperature, audio,
ambient and visible light sensor, force
Particle 2/29 – pPart • Freely programmable, customized RF protocol • 128KB program ROM, 512KB for data storage
zPart – ZigBee Particle • Freely programmable, onboard movement sensor • 128KB program ROM, 512KB for data storage
Blueticle • Bluetooth radio, Zeevo • Acceleration, temp., audio, light and force sensor
Christian Decker, 2005 – Particle Programming
11
Particle Zoo cont.
uPart • Integrated wireless sensor node • Light, temperature, movement and
sensor sensor • Coin-cell powered
Your course platform
Christian Decker, 2005 – Particle Programming
12
Particle Zoo Supplements
XBridge • Bridges Particle data to UDP network • Supports cell-of-origin location
system • Self-contained, i.e. no further
computer system required
USB Bridge • Bridges Particle data to UDP network • Requires laptop/desktop system
Christian Decker, 2005 – Particle Programming
13
And there is more...
• Software for all platforms • Libraries and tools • New and upcoming devices
http://particle.teco.edu
Christian Decker, 2005 – Particle Programming
14
Course Approach
1. Learn about the system
?
Application 5. Do your own exercises!
4. Learn about the tools
3. Learn about data processing
2. Learn about the sensors
Christian Decker, 2005 – Particle Programming
16
Particle System Architecture
uPart
UDP Network
ParticleDB
Particle Analyzer
uPart uPart
Bridge
...
Particle Computer
Back end
uPart Router
uPart Router
Christian Decker, 2005 – Particle Programming
17
Particle System Architecture
uPart
UDP Network
ParticleDB
Particle Analyzer
uPart uPart
Bridge
... uPart Router
uPart Router
Flat architecture / no middleware
Christian Decker, 2005 – Particle Programming
18
Particle System Architecture
uPart
UDP Network
ParticleDB
Particle Analyzer
uPart uPart
... uPart Router
uPart Router
Flat architecture: All components are Particle Computer
Bridge
Christian Decker, 2005 – Particle Programming
19
Flat Architecture – Consequence
• Messages have to be distributed to all components – Particle sensor nodes broadcast on RF – Bridge broadcasts on UDP
• Common communication language between all
components – ConCom
Christian Decker, 2005 – Particle Programming
20
ConCom • Data encoded as tuples, strictly typed
– Type: 3 bytes, freely selectable – Length: 1byte, data length – Data: data to transmit
• Subject = first tuple, identifies application • Sentence = subject + [tuples]*
Leng
thD
ata
...
Subject Tuple Tuple
Type
A B C 1 1Le
ngth
Dat
a
Type
S T E 2 23 5
Christian Decker, 2005 – Particle Programming
21
ConCom cont. • Flat model
– Sentence imposes no hierarchy – Complies to the architecture
• Composite semantic – Sentence can be extended by additional tuples – Meaning does not change
• Contextual semantic – Order of tuples may encode additional information
• Publish/subscribe model – Application subscribes on subject – Several application run parallel – Tuple type reuse – Cross-layer optimizations
Christian Decker, 2005 – Particle Programming
22
The Big Picture
• ConCom is common communication language throughout the system • ConCom is used on all platforms, uParts, zPart, pParts, Blueticle …
no middleware required
ConCom
uPart
UDP Network
ParticleDB
Particle Analyzer
zPart pPart
... uPart Router
uPart Router
Bridge
ConCom
ConCom
ConCom
ConCom
ConCom
Christian Decker, 2005 – Particle Programming
23
References
• A. Krohn, M. Beigl, C. Decker, P. Robinson, T. Zimmer, ConCom – A language and Protocol for Communication of Context, Technical Report ISSN 1432-7864 2004/19
• Decker, C., Krohn, A., Beigl, M., Zimmer T.
The Particle Computer System. IPSN Track on Sensor Platform, Tools and Design Methods for Networked Embedded Systems (SPOTS). Proceedings of the ACM/IEEE Fourth International Conference on Information Processing in Sensor Networks 2005, Los Angeles, USA
Christian Decker, 2005 – Particle Programming
25
uPart – Technical Details
• Speak “mü-part” • MCU: 12F675 at 4 MHz • Memory:
– Internal Flash 1.4 kByte, – Internal SRAM 64 Byte – Internal EEPROM 128 Byte
• Communication: Transmitter only – 869 Mhz / 315 Mhz – 2-FSK, ALOHA protocol – 15m indoor, up to 30m outdoor
• Sensors – Light, temperature, movement, voltage
• Power supply – Single CR1632 coin cell – Lasts for several weeks (~35s duty cycle, CR1632)
uPart 1/40
Christian Decker, 2005 – Particle Programming
26
Sensing and Communication
• Both underlie a duty-cycle mechanism Operation phase • Sensor sampling
– Samples light, movement, temperature, voltage sensor
• Compression – Aggregates several consecutive samples
• Communication – Packet contains recent and a set of previous compressed sensor values
Sleep Sleep Sleep
Operation Operation Operation Operation
Time
Sleep >> Operation
Christian Decker, 2005 – Particle Programming
27
System Layout
• This course will use uParts in single-hop communication distance.
ConCom
ConCom
ConCom
USB
USB Bridge
Christian Decker, 2005 – Particle Programming
28
uPart Packet Format
• Header (6 bytes) – Version, field strength, sequence number – ID (1.2.3.4.x.x.x.x)
• Payload (max. 11+24=35 bytes) in ConCom • Data encodes
– configuration, i.e. sampling cycles, compression, sensor selection – recent uncompressed sensor values – compressed previous sensor information
Header Payload CRC16
AMP | lenght | data
Ref: http://particle.teco.edu/upart/ Protocols
Christian Decker, 2005 – Particle Programming
29
uPart ID Scheme
• 8 byte ID = 1.2.3.4 + 4 byte significant ID
Ref: http://particle.teco.edu/upart IDs
id0
id1 id2 id3
• Format:1.2.3.4.id0.id1.id2.id3(id0..id3 in decimal)
• On the uPart: id0..id3 in hex • Example:
– uPart: 00 01 00 10 – Full ID: 1.2.3.4.0.1.0.16
Christian Decker, 2005 – Particle Programming
30
uPart Configuration
• uPart are transmitting-only device • But, configuration possible via double usage of light
sensor on LCD or CRT • Applet generates black/white pattern encoding
configuration data • uPart ready to receive config
after bootup • Configuration options
– Sampling intervals = transmit rate – Compression – Sensor selection
Online: http://particle.teco.edu/upart uPart Config
Christian Decker, 2005 – Particle Programming
32
Overview
uPart 1/40
Movement (digital)
Temperature (analog)
Light (analog)
PIC microcontroller • Analog-Digital converter (10bit ADC) • Digital I/O
Battery (analog)
Christian Decker, 2005 – Particle Programming
33
Analog & Digital Sensors
• Analog sensors – Sensor output voltage encodes
the sensor value – ADC translates in digital value
• Digital sensors
– Sensor value encoded as “1“ and “0” – Example: PWM
MCU Sensor
GND
Vdd
Source: ADXL Datasheet
Christian Decker, 2005 – Particle Programming
34
Movement Sensor
• Binary sensor, ballswitch (on/off state) • Motion detection, orientation dependent • No current, really low power sensor!
Encapsulated ball, Shake it, you hear it!
• count #states (on/off) • continous state length • on/off cycle
Signal (ideal) :
Switch opened Vdd Switch closed GND
GND Vdd
Christian Decker, 2005 – Particle Programming
35
Movement Sensor Sampling
• 1 sample every 144ms (short wake-up) • Count “on”-state, min{#on, 255} • Reset when sending
Sleep
Send
Time Sample Count
Sample Count
… Reset Counter
min{#on, 255}
Christian Decker, 2005 – Particle Programming
36
Compression
Compression coverage = 12 * Compression factor * transmit rate
Sleep
Send
Time min{#on, 255}
Send Send
min{#on, 255}
… min{#on, 255}
Send
3 2 1 0 7 6 5 4
average diff
Bit
12 byte compression ring buffer
Compression Coverage Time
average: step encoding, width 16
#avg.“on“counts = average * 16
diff = min{maxCounts–minCounts, 15}
Christian Decker, 2005 – Particle Programming
37
Light Sensor
• TSL13, analog sensor, neutral to angular displacement • Sampled once per sampling cycle • Compression scheme like ballswitch
TSL13T Internals Source: TSL13 Datasheet
Photo Diode
Christian Decker, 2005 – Particle Programming
38
Temperature Sensor
• TC1047A, analog sensor • Output voltage linear to temperature • Output independent from input voltage
Source: TC1047A datasheet
Source: TC1047A datasheet
Christian Decker, 2005 – Particle Programming
39
Temperature Sensor
temperature = const. VTC1047_out = const. And
Vdd_MCU != const. sampleADC_TC1047 != const. I.e. (temp. = const.)
Problem: How to measure Vdd_MCU?
1024
* 1047___1047
TCADCMCUddoutTC
sampleVV =
MCUddTCADC
Vsample _
1047_
~1
Christian Decker, 2005 – Particle Programming
40
Voltage Sensor
• ADC is powered by same source which should be measured (Vdd != const.)
• ADC samples reference diode in reverse operation
ADC
refdd sample
VV
1024*=
Diode’s reverse characteristic Source: LM385 Datasheet
Formula for computing the uPart supply voltage
Christian Decker, 2005 – Particle Programming
41
Voltage Sensor cont.
Supply Voltage Accuracy
2
2,2
2,4
2,6
2,8
3
3,2
3,4
380 390 400 410 420 430 440 450 460 470 480 490
Sampled Values from ADC
Su
pp
ly V
olt
age
[V]
Exact uPart Implementation
Christian Decker, 2005 – Particle Programming
42
Sensor Selection
• uPart configuration – Sampling intervals = transmit rate – Compression – Sensor selection
• Compression – applied only on selected sensors – Light compression like ballswitch – Temperature averaged
• Selection options – Sensor 1: Movement (fix) – Sensor 2:
• light sensor, OR • temperature sensor
Christian Decker, 2005 – Particle Programming
43
Problems with Sensors
• Systematic problems – Sensors must be aligned to an application
• Orientation of sensors is crucial – placement of movement sensor is an interesting
research question!
• Computation and compression are lossy • Sampling intervals too large
– Inaccurate results – Missed events – Idea: increase sampling
(therewith transmit) rate Source: Albrecht Schmidt, Summer School 2005
Christian Decker, 2005 – Particle Programming
44
Increase Transmit Rate...
Unslotted ALOHA Performance
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
1
0 10 20 30 40 50 60
Transmitting interval [s]
Pro
bab
ility
of
No
Co
llisi
on
5 nodes
10 nodes
15 nodes
20 nodes
25 nodes
50 nodes
75 nodes
100 nodes
150 nodes
200 nodes
250 nodesIncrease transmit rate
Christian Decker, 2005 – Particle Programming
45
More on Sensors...
• uPart sensors – http://particle.teco.edu/upart/ Protocols – http://particle.teco.edu/upart/ Datasheet
• Albrecht Schmidt
“From Sensors to Context” Dagstuhl Summer School Summer School on Wireless Sensor Networks and Smart Objects 2005 http://www.vs.inf.ethz.ch/events/dag2005/program/lectures/schmidt-sensors-2.pdf
Christian Decker, 2005 – Particle Programming
47
Introduction
• Lotfi Zadeh (* 4. Februar 1921) • Founded theory of fuzzy sets and fuzzy
logic • Approach: describe a system
mathematically as similar as a human being would describe it linguistically
• Fuzzy Sets
– Elements are part of sets to a certain degree
• Fuzzy Logic – Operations on fuzzy sets – Superset of Boolean logic
Lotfi Zadeh (2004)
Christian Decker, 2005 – Particle Programming
48
Motivating Example
Example: What is a convenient temperature?
Temp. ( °C)
Membership µ
1
0 20 25 Temp.
( °C)
Membership µ
1
0 20 25
0,6
Everything between 20°C and 25°C, but not 19,9°C.
20°C is to a certain degree a convenient temperature.
Christian Decker, 2005 – Particle Programming
49
Fuzzy Set
• Elements: • Membership function: • Def. Fuzzy Set • Special case (Boolean Set): • Fuzzification: determine the truth value
Uu ∈[ ]1,0: →Uµ A
{ }]1,0[)(,|))(,(: ∈∈= uµUuuµuA AA
{ }1,0: →Uµ A
[ ]1,0:)( →uuµ A
Christian Decker, 2005 – Particle Programming
50
Operations on Fuzzy Sets
• NOT: • AND: • OR: • Other functions for logic operators are
possible.
)(0.1)( uµuµ AA −=¬
{ })(),(min)()( vµuµvµuµ BABA =∧
{ })(),(max)()( vµuµvµuµ BABA =∨
Christian Decker, 2005 – Particle Programming
51
Fuzzy Expert System
Process: 1. Fuzzification 2. Inference 3. Composition 4. Defuzzification
Expert System “reason about data“
If ... and ..., then ... If ... or ..., then ... ...
Membership Functions
Rules
Conclusion
Data
Christian Decker, 2005 – Particle Programming
52
Fuzzification & Inference
• Fuzzification – Apply membership function on actual data value
• Inference – Determine truth value of the premise of each rule
• Ex. “If a is HIGH and b is LOW, then c is HIGH”
• Rule only fires, if
– Apply it to the conclusion of each rule, result is new fuzzy set • Ex. “If a is HIGH and b is LOW, then c is HIGH”
)()(:Pr bµaµµ LOWHIGHemise ∧=
0Pr >emiseµ
{ }],0[)(,|))(,(:)(premiseHIGHHIGH
c µuµUuuµuHIGH ∈∈=
Christian Decker, 2005 – Particle Programming
53
Composition & Defuzzification
• Composition – Combination of all result fuzzy sets – Methods:
• MAX, i.e. OR operation across all sets • SUM, i.e. sum truth values point-wise
• Defuzzification – Compute crisp value from final fuzzy set – “inverse“-operation to fuzzification – Methods:
• Centroid, i.e. center of gravity of the set • Maximum, i.e. largest truth value
Christian Decker, 2005 – Particle Programming
54
Example
• Input: Data from uParts in Badges on Ubicomp05 • Task: Find the sessions reasoned from light and movement data.
Light Membership Function
Movement Membership
Function
Session Membership
Function
Christian Decker, 2005 – Particle Programming
55
Example Fuzzy Expert System
if light is low and movement is low then event certain; /* Rule 1 */
if light is high and movement is low then event none; /* Rule 2 */
if light is low and movement is high then event none; /* Rule 3 */
if light is high and movement is high then event none; /* Rule 4 */
defuzzification
input: input: output:
and
and
and
and
fuzzification
com
po
sition
Fig. Matlab
Christian Decker, 2005 – Particle Programming
56
Example Results
Ubicomp Data
Fuzzy Expert System
Results
Christian Decker, 2005 – Particle Programming
57
More on Data Processing...
• Kristof van Laerhoven’s Homepage http://www.comp.lancs.ac.uk/~kristof/
Readings • K. Van Laerhoven and H.-W. Gellersen. "Spine versus Porcupine: a Study in
Distributed Wearable Activity Recognition". In Proceedings of the eighth International Symposium on Wearable Computers, ISWC 2004, Arlington, VA. ISBN: 0-7695-2186-X; IEEE Press, 2004, pp. 142-150.
• K. Van Laerhoven, A. Schmidt and H.-W. Gellersen. "Multi-Sensor Context-Aware Clothing". In Proceedings of the sixth International Symposium on Wearable Computers, ISWC 2002, Seattle, WA. ISBN: 0-7695-1816-8; IEEE Press, 2002, pp. 49-57. PDF
Christian Decker, 2005 – Particle Programming
59
General Remarks
• Remember system architecture – All data is broadcasted on UDP – All components speak ConCom
• Default: Bridges broadcast on UDP 5555, i.e. application have to listen on 5555 in order to receive data in ConCom format.
ConCom
ConCom
USB
USB Bridge
ConCom
UDP Broadcast on 5555
Christian Decker, 2005 – Particle Programming
60
libparticle
• Communication library in C for Windows and Linux
• UDP broadcast communication • ConCom tuple coding, • Powerful filters, e.g. ConCom, addresses etc. • Plain, addressed, acknowledged,
fragmented/file data transfer • Tunneling, i.e. connect two remote Particle networks via TCP • All PC applications base on libparticle
– E.g. consoleanalyzer, send2particle (included examples)
• ParticleAnalyzer, USBBridge, ParticleDB, OtAP, timeserver (TecO tool set)
Application
libparticle
PC / OS
Network
Christian Decker, 2005 – Particle Programming
61
Libparticle – Example
int main(...) { ... sockd = p_socket_open(0 , 0, port); printf("Listening:\n"); for (;;) { fflush(stdout); packet = p_socket_recv(sockd, sockd); if (packet != NULL) p_describe_pkt(packet); } return 0; }
Extensive Examples can be found in the libparticle directory on the course CD
Christian Decker, 2005 – Particle Programming
62
Libparticle – Language Bindings
• Previous: re-implemented libparticle for Java (TecO) and C# (Lancaster)
• Now: SWIG • SWIG = interface compiler, wraps C-
libparticle • object-orientied interface is defined
(.i files) • SWIG generates bindings for other
languages, e.g. Java, C#, Ruby, Python, PHP,…
• SWIG libraries handle type conversion (through typemaps)
App(Java)
libparticle (C)
App (C#)
Wrapper (C)
Wrapper (lang)
Christian Decker, 2005 – Particle Programming
64
libparticleJava – Example
public class uPartVoltage { static {
/** load particleJava native library */ System.loadLibrary("particleJava"); }
public static void main(String[] args) { uPartVoltage voltage = new uPartVoltage(); while( true ) { System.out.println(voltage.getVoltage() );
}
} protected String getVoltage() {... }
... private float parseTuple(ParticleTuple pt) { ParticleTuple amp; long value;float voltage amp = packet.findFirstAcl( "amp" ); value = amp.getAclByte( 3 ); voltage = (float)value / 10; return voltage; } } // end class uPartVoltage
Christian Decker, 2005 – Particle Programming
65
Language Bindings – Status
• Every language binding supports – C-error to exception mapping. – OO-Interface. – all functionality of libparticle.
• Java – C-array to java-array convenience mapping and vice versa.
• Csharp – no modification.
• Ruby – no modification.
• Php4: – minor mod for exception handling.
Christian Decker, 2005 – Particle Programming
66
pComponents
• Collection of JavaBeans • Graphically compose Applications • Encapsulate common functionality:
– Scanner – scan for particles and their tuples. – Scope – graphical data plotter. – Console – text representation of network packets. – packetEditor – build packets and send them. – socketThread – easily receive packets
concurrently.
• Under development: – particleTemplate – template based filtering. – otap – Over-the-Air Programming. – otad – Over-the-Air Debugging.
libparticle as bean
Console bean
Christian Decker, 2005 – Particle Programming
67
ParticleAnalyzer
• Real-time data analysis tool • Scanning and managing of Particle network • filtering, displaying and plotting of Particle data • Create/sending of Particle data • all functionality encapsulated in pComponents. • “clicked together” with Visual Editor of Eclipse.
Christian Decker, 2005 – Particle Programming
68
ParticleAnalyzer cont.
Bean libparticle socket connected with Console bean
Bean based ParticleAnalyzer
Christian Decker, 2005 – Particle Programming
69
Software Stack
App(Java)
libparticle (C)
App (C#)
Wrapper (C)
Wrapper (lang)
PC / OS
Network
App (Ruby)
App (PHP) pComponents
App (C)
ParticleAnalyzer
Systems and Toolkits
Christian Decker, 2005 – Particle Programming
70
uPartLoggerSystem
libparticle (C)
PC / OS
Network
MySQL
Apache WWW
logger
Client
uParts
Display
uPartLogger System
Christian Decker, 2005 – Particle Programming
71
Equip4j Toolkit for Particles
• Equip4j: Distributed component based software framework (EQUATOR project, UK)
• Equip4j-Application: set of functional software components connected through event exchange mechanism
• Development: graphical composition of components, definitions of events exchange path, rapid approach
• Component Repository: controlling webcams, record audio, TTS, neural networks, etc.
• Particles enabling components
– Representation: ParticleFactory, ParticleInstance – ConCom Parser: ParticleDemultiplexer, StringSplitter – Feedback: ParticleSender (for pParts, zParts, no uParts)
Christian Decker, 2005 – Particle Programming
72
Equip4j for uPart
• uPart specific components – UPartDBConnector: fetches, exports, replays data from a
database – UPartAmpParser: interprets a data set
Parsing
Representation of uPart
Network & Filter
USB Bridge
Christian Decker, 2005 – Particle Programming
73
More Software...
• Particle PC software – http://particle.teco.edu/software/index.html – More software, tools + docs
• uPart website
– http://particle.teco.edu/upart – Specifications, protocols, uPartConfig
Christian Decker, 2005 – Particle Programming
75
Prerequisites
• Software for Win2000 SP4, WinXP SP2
• Java 1.5 required (on CD) • Install and connect the USB
Bridge on your computer • Deactivate virtual network
cards, e.g. from VMWare • Start your uPart, place battery
correctly
USB Bridge
Insert Battery CD: <Drive>:\index.html
Christian Decker, 2005 – Particle Programming
76
Quick Step 1: Logging
• ready-to-run Apache/PHP/MySQL installation
• Extract the .zip file,
follow the instructions • Run the uPart logger • Go to http://localhost/
and plot uPart data
CD: <Drive>:\uPartLoggerSystem_1_bundle\ + Install.txt
Christian Decker, 2005 – Particle Programming
77
Quick Step 2: Equip4j Toolkit
• ready-to-run Equip4j installation
• Extract the .zip file,
follow the instructions • Start-up the toolkit • Create the
ParticleFactory + watch data comming in
CD: <Drive>:\Equator4uPart_2_bundle\ + Manual.pdf
Drag & Drop
Christian Decker, 2005 – Particle Programming
78
Quick Step 3: Dump Your Data
• Within Equip4j, create the uPartDBConnector
• DataExporterGUI will
come up automatically • Fetch(1) and export(2)
uPart data to a textfile
CD: <Drive>:\Equator4uPart_2_bundle\ + Manual.pdf
1
2
Christian Decker, 2005 – Particle Programming
79
Quick Step 4: Use Excel
• Import the data dump in Excel • Select the voltage field • Plot the values in series Success! 2,6
2,7
2,8
2,9
3
3,1
3,2
3,3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Christian Decker, 2005 – Particle Programming
80
JFS2
• Free Fuzzy Expert System • programming language JFL • Combines traditional
programming and fuzzy logic
• Supports informal descriptions, e.g. rule of thumbs, example values, etc.
• Interface to gnuplot, C compiler
CD: <Drive>:\JFS2\ + Quick Intro
title "Stopping a bicycle"; operators and min precedence 30; or max precedence 20; whileop max; ... input distance "Distance to stop point" metres defuz avg; speed "Speed" speed_dom defuz avg; output brake "brake force" percent defuz avg; adjectives distance near 5; distance medium 17.5; distance far 30; ... program if speed is slow and distance is near then brake is low; if speed is slow and distance is medium then brake is none; if speed is slow and distance is far then brake is none;
Christian Decker, 2005 – Particle Programming
81
Additional Material
• libparticle, pComponents • Programming examples + documentation • ParticleAnalyzer • USB bridge software and drivers • Eclipse 3.1.1, JDK1.5 • Tools: Ant, JUnit, SWIG
CD: <Drive>:\index.html
Christian Decker, 2005 – Particle Programming
84
Exercise
• Build the AwareOffice – Recognize typical office activities – Support users in their activities
• Sub-projects – Annotation of whiteboard activity – Environmental control – Meeting detection – Encourage activities – Document management – Meeting Annotation
Christian Decker, 2005 – Particle Programming
85
Programming
This is your part!
Data from the office environment
Christian Decker, 2005 – Particle Programming
86
Development Process
• Bottom up approach
?
Application
1. Deploy uParts on people, places, things
2. Record their data
3. Construct a fuzzy expert system
4. Implement, run, test and evaluate your system
5. Document your approach and put your results on a website
uPar
t N
etw
ork
Dat
a pr
oces
sing
A
pplic
atio
n fr
ont-
end
Christian Decker, 2005 – Particle Programming
87
Development Process + Activities
Attach uParts Collect Data Review Data Find rules
Time
Replay your data + apply rules
Put application togehther
Run application
Time
Document places
Draw Membership Functions
Report results, Code
Convert in C Write Equip Component
Document Code!
Christian Decker, 2005 – Particle Programming
88
Tool Chain Logging & Reviewing
Export data
Design Fuzzy Expert System
Compile Fuzzy System to C code
Run the System live
Put your results online
uPartLogger System
Equip4j UPartDBConnector
JFS2
Test and Evaluate
public class TemplateBeanInfo extends SimpleBeanInfo {
protected Class beanClass = Template.class;
public PropertyDescriptor[] getPropertyDescriptors() {
try {
return new PropertyDescriptor[] { // an input - get and set
new PropertyDescriptor("input", beanClass, "getInput", "setInput"), // an output - get only new PropertyDescriptor("output", beanClass, "getOutput", null) } catch (IntrospectionException e) { throw new Error(e.toString()); } } }
Build Equip Component
Equip4j
Put everything together
WWW
Start here
Christian Decker, 2005 – Particle Programming
89
In the unlikely case, that...
• Nothing works – Determine how far the data are propageted within the tool chain – Use the ParticleAnalyzer to check the network (Do you see AMP
packets?)
• Performance is low due to Equip4j – Wrap Equip components as standalone application
• Documentation is incomplete – Go to http://particle.teco.edu, http://particle.teco.edu/upart
• Nothing helps... – Use the support, http://forum.teco.edu, [email protected]
Christian Decker, 2005 – Particle Programming
90
Exercise – Annotate Whiteboard Activities
• Goal: A picture log of your whiteboard writings • Tasks
– Attach uParts on pens, sponge and optional whiteboard – Record uPart data during the typical activities like writing, playing
w/ pens, erasing – Select and describe appropriate situations for taking a picture – Shoot pictures automatically in those situation and summarize
them in a log, e.g. website
• Questions – Is there a difference in the detection reliability when using the
system with and without the additional input from the uPart(s) on the whiteboard?
– What are possibilities to avoid the writer in the line-of-sight of the camera and whiteboard?
Christian Decker, 2005 – Particle Programming
91
Exercise – Environmental Control
• Goal: Room controller and recorder • Tasks
– Mount uParts on objects, e.g. windows, doors, chairs, tables etc., – Record sensor values and reflect object status, e.g. website – Detect people entering the room and document them by a
camera, results can be compiled on a website/weblog – Alert unusual situations, e.g. open window during night
• Questions – What are the criteria for your object selection? – What (alert) situations can you detect? – How reactive is your system? Time difference between activity
and detection
Christian Decker, 2005 – Particle Programming
92
Exercise – People Activity
• Goal: Personal fitness trainer for office workers • Tasks
– Attach uParts on people, document those places+orientation – Record people’s activities, e.g. movement levels – Display activities of single extremities, e.g. on a website – Select and describe activities you want to recognize – System should request people to practise and prove the exercise
by documenting it automatically, e.g. Text2Speech, Camera
• Questions – What are good places for mounting sensors? – What are the criteria for the activity selection? – How reliable is the activity detection? Real vs. system
Christian Decker, 2005 – Particle Programming
93
Exercise – Meeting Detection
• Goal: Detect and display spontaneous meetings • Tasks
– Attach uParts on chairs and record their movement information – Define the meeting and its parameters, e.g. number of persons, – Detect these meetings and display the state on a electronic
doorplate, e.g. a website – Test your system on false positives, e.g. What happens when
the room is cleaned up?
• Questions – What is the smallest meeting group your system can detect? – What is the reliability of your system? – What are measures to avoid false positives?
Christian Decker, 2005 – Particle Programming
94
Exercise – Document Management
• Goal: Electronic document containers • Tasks
– Attach uParts to paper documents – Support following activities
• Loader: “load” the electronic version if paper document is moved in a projector beams
• Security rules: describe and implement security rules, e.g. if document is put in a bag.
• Forget-me-not: reminder, if a document is probably forgotten, e.g. not moved for a time
• Questions – Can you recognize patterns for the loader activity? – What is the rate of false positives and false negatives for the
security activity? – What may be other conditions indicating a forgotten document?
Christian Decker, 2005 – Particle Programming
95
Exercise – Meeting Annotation
• Goal: Meeting log / blog via audio + video • Tasks
– Attach uParts on chairs, tables, pens, windows, people – Define and describe situations within a meeting, where annotation
would be useful Split here in two teams
• Record audio + video periodically
• Select in post processing valueable scenes
• Record audio + video only if situation was detected
• Questions – Which approach is more reasonable? Why? – What may be necessary, e.g. sensors, to improve the system?
Christian Decker, 2005 – Particle Programming
96
Final Test (optional)
• Build the AwareOffice, i.e. let all your applications run in parallel
• Question: What happens?
Christian Decker, 2005 – Particle Programming
97
References
• TecO, “Impromptu – Creating Ad-hoc Pervasive Computing Environment” Video at at Pervasive 2004 in "Advances in Pervasive Computing", ISBN 3-85403-176-9, pp. 377-381, Vienna, Austria. (http://www.teco.edu/~zimmer)
• Equip examples at TecO:
http://particle.teco.edu Software