770 likes | 957 Views
CSE- Mobile Computing Systems and Applications. Class 11. Announcements. Phase 2 and 3 requirements uploaded Please return the motes to TA after class today Come up with topics and reference papers by 10/3/2011. Agenda. Concurrent Execution in TinyOS Sensor Networks and Localization.
E N D
Announcements • Phase 2 and 3 requirements uploaded • Please return the motes to TA after class today • Come up with topics and reference papers by 10/3/2011
Agenda • Concurrent Execution in TinyOS • Sensor Networks and Localization
TinyOS multi-threading • TinyOS is a single application OS • It supports multi-threading for the application • Several threads can be posted in parallel which get scheduled in a FIFO queue • Tasks and events are primarily used for doing computation • Tasks are for long running computations • Events are used for very short computation and for posting long running computations in the FIFO queue
Concurrent execution • uint16_t Samples[SAMPLES]; • Uint16_t i = 0; • event void ReadStream.readDone(error_t ok, uint32_t SensedVal) { • if (ok == SUCCESS){ • i++; • Samples[i] = Val; • if(i == SAMPLES-1){ • i = 0; • post calculateAvg(); • } • } • } • task void calculateAvg() { • uint16_t i, avg, var; • for (avg = 0, i = 0; i < SAMPLES; i++) • avg += Samples[i]; • avg /= SAMPLES; • for (var = 0, i = 0; i < SAMPLES; i++) • { • int16_t diff = Samples[i] - avg; • var += diff * diff; • } • } In readDone, we need to compute the variance of the sample. We defer this “computationally-intensive” operation to a separate task, using post. We then compute the variance
Exercise to understand concurrency • Lets have a loop in a task • Increment a counter • Have a timer fired event where at each fired event we send the counter value to the base station • What values do we see at the base station ?
Code Flow Diagram Booted Boot Start Radio StartDone Call Timer Only the first task gets done FIFO scheduler gives preference to events TimerFired Call Sensor Task gets pushed back in the queue ReadDone Post 10 tasks
Sensor Networks and Localization Gianni Giorgetti impact.asu.edu 4nd September 2007
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
Microcontroller Sensors Light, Temp, Hum, Gas… Progr. Interface Batteries Flash Memory Radio Transceiver On-board antenna Node ID Wireless Sensor Networks: hardware • Tens to thousands of small embedded devices: Commercially available HW
Ad-hoc Deployment from U.A.V. March 2001, UC Berkeley and MLB http://robotics.eecs.berkeley.edu/~pister/29Palms0103/
4 6 9 Fire! 7 2 10 3 8 0 1 5 Internet WAN Multi-Hop Ad Hoc Network GW User Remote Link
? Where is the fire? 9 Fire! Close to node 9
Location awareness: • Enable Context-Aware Apps • Resource & Services Discovery • Tracking (People, Equipment,...) • Navigation Support • Security (Location-based access) 4 6 9 7 2 10 3 8 0 1 5 Remote user Localization Problem: to assign coordinates to the network nodes Fire! Quick solutions: • Manual Configuration: not feasible for large networks. • GPS: accurate, but power-hungry and not cost-effective Need of Localization Algorithms for Wireless Sensor Networks
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
Px Fixed Node (anchor node) ? Node to localize Localization by proximity ? P1 ? P2 ? ? • PROS: • Easy to implement • Computationally inexpensive • CONS: • Coarse resolution • Accuracy/coverage trade-off
Scene Analysis • Map positions to some measurable parameter e.g. signal strength from cellular towers
3 4 1 2 5 6 7 8 9 10 11 15 14 12 13 19 16 17 18 “WiFi Fingerprinting” Data Collector P1 P2 <P1,P2,P3,P4>? ? P3 P4 • PROS: • Computationally inexpensive • No need for range estimates CONS: Data collection needed at each site Re-training if environment changes
Scene Analysis – Mobile Loc. • Radio Strenght Map : 4 Wi-Fi base stations http://www-robotics.usc.edu/~ahoward/projects_wifi.php
Range-based Localization P1 P2 d1 d2 ? ! d3 P3 P4 • PROS: • Better accuracy (in theory) • CONS: • Need calibration (RSSI / distance) • High Errors (in practice)
Effect of multipath, shadowing, scattering ? ? ? ? PRX~(1/d)1.5 PRX~(1/d)2 PRX~s(1/d)3 Range Estimation using RSSI information Friis’ Free Space Propagation Fixed the TX power, the RX power decreases a function of (1/d)2 PTX PRX PRX~(1/d)2 Range Estimation using RSSI information is challenging (expecially indoors)
Node 1 Range Estimation using TDoA (TDoA = Time Difference of Arrival) Radio Radio Node 2 d Ultrasound Transmitter Microphone speed of light = 300 * 106 m/s speed of sound = 344 m/s • Need of dedicated hardware • Ultrasound has short range
Range Estimation using ToA (ToA = Time Difference of Arrival) Radio Radio Node 1 Node 2 d Localization using ToA requires precise clock synchronization and high resolution timers (e.g. GPS, Ultra Wide Band UWB). Not suitable for sensor nodes with energy and costs contraints.
Localizing the whole network P1 P2 P3 P4
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
The problem: locating the nodes Inputs: • A set of nodes: 6 4 8 1 3 10 9 5 2 7 0 2) A set of measurements: e.g. Range measurements: d(p1,p2) = Z12 e.g. Connectivity constraints d(p3,p4) ≤ Z34 Output: a set of node coordinates
2 7 1 4 5 3 8 6 Graph Embedding in Euclidean Spaces WSN represented as a undirected graph G=(V,E) GRAPH EMBEDDING: find a mapping :V Rd such that the the computed coordinates satisfy constraints (e.g. graph planar, or edge have specific lengths ) The problem has been extensively studied due to its application to molecular conformation, structural analysis, graph drawing.
2 d(1,2) d(2,4) 7 d(4,5) 1 4 d(3,4) d(5,7) 5 d(1,3) 3 d(3,6) 8 d(5,6) d(3,8) 6 Embedding with known edge lengths We assume that inter-node distances can be measured. Note: this is feasible only if nodes have dedicated hardware (e.g. ultrasound). • Problem: • find an embedding such that d(p1,p2)=d((1), (2)) • Fundamental Questions: • Computational complexity • Uniqueness of solution • Answer 1: • Graph Embedding is NP-complete in 1D and NP-hard in 2D [Saxe79]
d(3,4) 5 3 d(3,6) 8 d(5,6) d(3,8) 6 2 2 2 d(1,2) d(1,2) d(1,2) d(2,4) d(2,4) d(2,4) 7 7 7 1 1 1 4 4 4 d(4,5) d(4,5) d(4,5) d(3,4) d(3,4) d(3,4) d(5,7) d(5,7) d(5,7) 5 5 5 d(1,3) d(1,3) d(1,3) 3 3 3 d(3,6) d(3,6) d(3,6) 8 8 8 d(5,6) d(5,6) d(5,6) d(3,8) d(3,8) d(3,8) 6 6 6 Uniqueness of the Solution d(1,3) Original graph Translation Rotation Reflection If we use inter-node distances, the solution is correct up to global translation, rotation or reflection. We need to fix the relative position of 3 non collinear nodes (2D).
6 7 7 Uniqueness of the Solution (cntd) Considering N nodes there are 2N degree of freedom in the 2D space. Each measurement set a constraint. If we don’t have enough constraints the solution is not unique. 2 7 1 4 2 5 7 3 1 4 8 5 3 8 6 Flexible framework 6 Flipping ambiguities
2 d(1,2) d(2,4) 7 d(4,5) 1 4 d(3,4) d(5,7) 5 d(1,3) 3 d(3,6) 8 d(5,6) d(3,8) 6 Condition for unique realization in 2D • The graph need to have 2N-3 well distributed edges [2] • The graph need to be triconnected and reduntantly ridig [3] • Condition are testable in polynomial time (peeble game) [5] • This conditions were proved to be necessary and sufficient [4] • No such characterization exists for dimension greater than 2
Connectivity information only R • Assuming an idealized radio model: • d(a,b) R a,b neighbors • d(a,c) > R a,c non neighbors • Network can be represented by an Unit Disk Graph (UDG) 2 7 1 4 5 3 8 6 NB(3)={1,2,4,6,8) • Theoretical Results on Unit Disk Graphs: • Embedding NP-Complete in 1D and NP-hard in 2D [6] • Problem is APX-hard (no Polynomial Time Approximation) [7] • Finding exact nodes position is not just hard algorithmically, but impossible since the lack of information
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
Spring-Mass Model The network is modelled as a mesh of masses connected by spring with a given length • Keep neighbors nodes close to each other Radio Range = 50 mt 100 mt
Spring-Mass Model The network is modelled as a mesh of masses connected by spring with a given length • Keep non-neighbors nodes far from each other Radio Range = 50 mt 10 mt
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
Self-Organizing Map (SOM) 2D SOM with hexagonal Lattice Introduced in 1982 by T. Kohonen, it has some resemblance to the cerebral cortex, where similar stimuli are processed in adjacent areas (to minimize the length of sinapsys connections) SOM learning algorithm is UNSUPERVISED Î Rd 7 x 5 hexagonal SOM Weight Vector
BLUE GREEN RED Input Space SOM before training SOM after training Example • Properties of the SOM technique: • SOMs are able to learn the underlying features of the input space (e.g. a uniform color distribution). • Final weights are topologically ordered (adjacent neurons converge to similar values).
Learning Algorithm Training Set 1 1) Sampling: a sample x is extracted from the input set and compared with the map weights. 2) Competition: the neuron whose weights are more similar to the input is the Best Matching Unit (BMU) 3) Adaptation: the SOM weights are updated. Adaptation is regulated by a Gaussian shaped neighborhood function. BMU 2 Neighborhood funct. h(·) Weight changes 3
Online Demos http://www.eas.asu.edu/~eee511/
9 3 7 4 2 1 SOM Localization • The unknown node positions are stored as weights of a neural networks known as Self-Organizing Maps (SOM) • Connections between neurons are created match the radio links in the sensor networks (two neurons are connected, if the corresponding sensor nodes are neighbors) • Can work using connectivity information (proximity) or RSSI. • No attempt to estimate the actual range from RSSI, therefore no need of calibration parameters. • Lightweight implementation (in term of memory and execution time). Sensor Network SOM Training phase 9 3 7 4 2 1
Localization Error SOM / MDS Self-Organizing Map Average, 13% accuracy improvement over MDS. SOM4A, 50% accuracy improvements for network with conn. < 6
SOM – avg.err. 0.38R SOM – avg.err. 0.33R Anisotropic Networks MDS – avg.err. 1.32R “W” layout MDS – avg.err. 1.56R “C” layout ~ 75% accuracy improvement over MDS.
Indoor Localization using SOM and RSSI Average Error ~= 1.3 m Results are comparable (even better) to those obtained using methods that relies on RSSI range estimates (and require parameters calibration) [1] N. Patwari, A. O. Hero, M. Perkins, N.S. Correal and RJ O‘Dea, “Relative location estimation in wireless sensor networks”,IEEE Transactions on Signal Processing, 2003
Agenda • PART I • Intro to Wireless Sensor Networks • Examples of localization techniques • Theoretical aspect of the localization problem • Collaborative localization • Spring-Mass Model • Self Organizing Maps • Directional Antennas • PART II • “Computer-Less” WSN
Switched Beam Directional Antenna Four Beam Directional Antenna Patch 1 Patch 2 Patch 3 Patch 4
2D Range Based Localization Trilateration Triangulation Range + Angle
Angle of Arrival Estimation Friis’ free space equations Patch 2 d 2 2 1 Patch 1 r2 1 r1 0 target