Wireless OEP Breakout Session David Culler & Shankar Sastry University of California, Berkeley
6/5/2001NEST Wireless OEP Breakout2 Agenda Additional Technical Background on HW/SW platform Additional Technical Background on Challenge Application Development Identify how each project will use the platform Solicit platform requirement input in preparation for Aug. freeze Identify components that projects will contribute
6/5/2001NEST Wireless OEP Breakout3 NEST Program Structure SW platform coordination services synthesis services composition services Challenge Application HW platform sensors processing communication actuators storage
6/5/2001NEST Wireless OEP Breakout4 NEST Program Structure – evolution SW platform coordination services synthesis services composition services Challenge Application HW platform sensors processing communication actuators storage year Composition Open Platform initial low-power wireless Open Platform 100+ tiny devices for alg. dev.
6/5/2001NEST Wireless OEP Breakout5 Platform Background material provided as reference coverage directed by discussion
6/5/2001NEST Wireless OEP Breakout6 Characteristics of Network Sens/Act Small physical size and low power consumption Concurrency-intensive operation –multiple flows, not wait-command-respond Limited Physical Parallelism and Controller Hierarchy –primitive direct-to-device interface –Asynchronous and synchronous devices Diversity in Design and Usage –application specific, not general purpose –huge device variation => efficient modularity => migration across HW/SW boundary Robust Operation –numerous, unattended, critical => narrow interfaces sensors actuators network storage
6/5/2001NEST Wireless OEP Breakout7 HW Platforms Current: SmartDust MacroMOTE => Renes => Phase 1: 6 months => algorithm studies –Mote++, MEMS sensors, TinyOS –more microcontroller »atmega163 => 2x storage »atmega103 => 128K flash, 4k ram »TIMSP430 => 60k flash, 2k ram, HW *,... »many subtle factors –RFM with ASH »too early for bluetooth –100+ nodes for < 20K$ Phase 2: 30 months => composition of alg’s –ARM-power, Bluetooth physical –integrated system –OS??
6/5/2001NEST Wireless OEP Breakout8 Isun Motherboard: Processor Core Atmel AVR Clock speed: 4 MHz Memory –8 Kbytes of program memory (flash) –512 bytes of data RAM –512 bytes of EEPROM on chip (write: 4 ms/byte) –32 8 bit registers IO capabilities –32 general purpose IO lines »Some lines also serve more specialized purposes, e.g. UART »10-bit 8-channel ADC –Connector interface means that the IO lines serve a more specific purposes Interrupts –No interrupt queuing 256K EEPROM secondary store over I2C
6/5/2001NEST Wireless OEP Breakout9 Radio Circuit RFM Monolithics TR MHz radio –On/off keying at 10 kbps (max kbps) –Capable of 115 kbps using amplitude shift keying –Capable of turning on in 30 us Processor interface –Raw, unbuffered access to transmit (RFM TX) and receive (RFM RX) »TX current => signal strength –Requires DC balanced signal – an equal number of 1’s and 0’s in the signal –Sampling on reception and modulating on transmission done is software »Too much noise in received signal to use UART for sampling Signal-strength Sensing and Control
6/5/2001NEST Wireless OEP Breakout10 Expansion Connector Documented hardware interface –Swap components on either side of the connector while preserving investment in sensors or main boards Sensor interfaces –4 lines dedicated to switching components on and off –7 analog voltage sensing lines –2 I 2 C busses –SPI –UART lines Debugging aids –All radio-related signals: RX, TX, base band, control signals, signal strength Programming interfaces –SPI and reset signals for the main processor and the coprocessor Ground, Vcc for both analog and digital circuits 12 lines reserved for future use
6/5/2001NEST Wireless OEP Breakout11 Sensor Boards Basic Sensor Proto –Photo resistor – PW1 and ADC1 –Thermistor – PW2 and ADC2 –Prototyping area Vibration Sensor –Photo resistor: PW1 and ADC1 –Thermistor: PW4, ADC6 –2 axis accelerometer: ADC2 and 3, PW2 –Digital temperature: I2C Bus 1 2 axis magnetometer –Convert magnetic fields into a differential output –Field range -2 to +2 gauss –Sensitivity 3.2mV/V/gauss –Resolution: 27 gauss at 10Hz –Bandwidth: 5MHz
6/5/2001NEST Wireless OEP Breakout12 Basic Power Breakdown… But what does this mean? –Lithium Battery runs for 35 hours at peak load and year at minimum load! –A one byte transmission uses the same energy as approx cycles of computation. –Idleness is not enough, sleep! »short and long control loops ActiveIdleSleep CPU5 mA2 mA3 μA Radio7 mA (TX)4.5 mA (RX)12 μA* EE-Prom3 mA00 LED’s4 mA00 Photo Diode200 μA00 Temperature200 μA00 Panasonic CR mAh * 10 uA for Dallas digital pot
6/5/2001NEST Wireless OEP Breakout13 A Operating System for Tiny Devices? Traditional approaches –command processing loop (wait request, act, respond) –monolithic event processing –bring full thread/socket posix regime to platform Alternative –provide framework for concurrency and modularity –never poll, never block –interleaving flows, events, energy management –allow appropriate abstractions to emerge
6/5/2001NEST Wireless OEP Breakout14 Tiny OS Concepts Scheduler + Graph of Components –constrained two-level scheduling model: threads + events Component: –Commands, –Event Handlers –Frame (storage) –Tasks (concurrency) Constrained Storage Model –frame per component, shared stack, no heap Very lean multithreading Efficient Layering Messaging Component init Power(mode) TX_packet(buf) TX_pack et_done (success ) RX_pack et_done (buffer) Internal State init power(mode) send_msg (addr, type, data) msg_rec(type, data) msg_sen d_done) internal thread Commands Events
6/5/2001NEST Wireless OEP Breakout15 Application = Component Graph RFM Radio byte Radio Packet UART Serial Packet ADC Tempphoto Active Messages clocks bit byte packet Route map routersensor appln application HW SW Example: ad hoc, multi-hop routing of photo sensor readings
6/5/2001NEST Wireless OEP Breakout16 Storage Breakdown (C Code) 3450 B code 226 B data
6/5/2001NEST Wireless OEP Breakout17 DARPA 29 palms demo UAV drops nodes along road, –hot-water pipe insulation for package Nodes self configure into linear network Calibrate magnetometers Each detects passing vehicle Share filtered sensor data with 5 neighbors Each calculates estimated direction & velocity Share results As plane passes by, –joins network –upload as much of missing dataset as possible from each node when in range 7.5 KB of code!
6/5/2001NEST Wireless OEP Breakout18 TOS Execution Model commands request action –ack/nack at every boundary –call cmd or post task events notify occurrence –HW intrpt at lowest level –may signal events –call cmds –post tasks Tasks provide logical concurrency –preempted by events Migration of HW/SW boundary RFM Radio byte Radio Packet bit byte packet event-driven bit-pump event-driven byte-pump event-driven packet-pump message-event driven active message application comp encode/decode crc data processing
6/5/2001NEST Wireless OEP Breakout19 Dynamics of Events and Threads bit event filtered at byte layer bit event => end of byte => end of packet => end of msg send thread posted to start send next message radio takes clock events to detect recv
6/5/2001NEST Wireless OEP Breakout20 Event-Driven Sensor Data clock event handler initiates data collection sensor signals data ready event data event handler calls output command common pattern char TOS_EVENT(SENS_OUTPUT_CLOCK_EVENT)(){ return TOS_CALL_COMMAND(SENS_GET_DATA)(); } char TOS_EVENT(SENS_DATA_READY)(int data){ return TOS_CALL_COMMAND(SENS_OUTPUT_OUTPUT)((data >> 2) &0x7); }
6/5/2001NEST Wireless OEP Breakout21 Component Composition include modules{ MAIN; SENS_OUTPUT; INT_TO_LEDS; CLOCK; PHOTO; }; MAIN:MAIN_SUB_INIT SENS_OUTPUT:SENS_OUTPUT_INIT MAIN:MAIN_SUB_START SENS_OUTPUT:SENS_OUTPUT_START SENS_OUTPUT:SENS_OUTPUT_CLOCK_EVENT CLOCK:CLOCK_FIRE_EVENT SENS_OUTPUT:SENS_OUTPUT_SUB_CLOCK_INIT CLOCK:CLOCK_INIT SENS_OUTPUT:SENS_OUTPUT_SUB_OUTPUT_INIT INT_TO_LEDS:INT_TO_LEDS_INIT SENS_OUTPUT:SENS_OUTPUT_OUTPUT_COMPLETE INT_TO_LEDS:INT_TO_LEDS_DONE SENS_OUTPUT:SENS_OUTPUT_OUTPUT INT_TO_LEDS:INT_TO_LEDS_OUTPUT SENS_OUTPUT:SENS_DATA_INIT PHOTO:PHOTO_INIT SENS_OUTPUT:SENS_GET_DATA PHOTO:PHOTO_GET_DATA SENS_OUTPUT:SENS_DATA_READY PHOTO:PHOTO_DATA_READY CLOCK INT_TO_LEDS MAIN SENS_OUTPUT LED hardware.h PHOTO
6/5/2001NEST Wireless OEP Breakout22 TinyOS Execution Contexts Hardware Interrupts events commands Tasks
6/5/2001NEST Wireless OEP Breakout23 Typical application use of tasks event driven data acquisition schedule task to do computational portion char TOS_EVENT(MAGS_DATA_EVENT)(int data){ struct adc_packet* pack = (struct adc_packet*)(VAR(msg).data); printf("data_event\n"); VAR(reading) = data; TOS_POST_TASK(FILTER_DATA);... mags.c
6/5/2001NEST Wireless OEP Breakout24 Filter Magnetometer Data Task TOS_TASK(FILTER_DATA){ int tmp; VAR(first) = VAR(first) - (VAR(first) >> 5); VAR(first) += VAR(reading); VAR(second) = VAR(second) - (VAR(second) >> 5); VAR(second) += VAR(first) >> 5; VAR(diff) = VAR(diff)-(VAR(diff) >> 5); tmp = VAR(first) - VAR(second); if(tmp < 0) tmp = -tmp; VAR(diff) += tmp; if((VAR(diff) >> 5) > 85){ TOS_CALL_COMMAND(MAGS_LEDg_on)(); VAR(led_on) = 255; } 128 Hz sampling rate simple FIR filter dynamic software tuning for centering the magnetometer signal (1208 bytes) digital control of analog, not DSP ADC (196 bytes)
6/5/2001NEST Wireless OEP Breakout25 Tasks in low-level operation transmit packet –send command schedules task to calculate CRC –task initiated byte-level datapump –events keep the pump flowing receive packet –receive event schedules task to check CRC –task signals packet ready if OK byte-level tx/rx –task scheduled to encode/decode each complete byte –must take less time that byte data transfer i2c component –i2c bus has long suspensive operations –tasks used to create split-phase interface –events can procede during bus transactions
6/5/2001NEST Wireless OEP Breakout26 Active Messages Sending –Declare buffer storage in a frame –Request Transmission –Naming a handler –Handle Completion signal Receiving –Declare a handler –Firing a handler »automatic upon arrival of corresponding message »behaves like any other event Buffer management –strict ownership exchange –tx: done event => reuse –rx: must rtn a buffer –built-in wrapper TOS_FRAME_BEGIN(INT_TO_RFM_frame) { char pending; TOS_Msg msg; } TOS_FRAME_END(INT_TO_RFM_frame);
6/5/2001NEST Wireless OEP Breakout27 Send Message c har TOS_COMMAND(INT_TO_RFM_OUTPUT)(int val){ int_to_led_msg* message = (int_to_led_msg*)VAR(msg).data; if (!VAR(pending)) { message->val = val; if (TOS_COMMAND(INT_TO_RFM_SUB_SEND_MSG)(TOS_MSG_BCAST, AM_MSG(INT_READING), &VAR(msg))) { VAR(pending) = 1; return 1; } return 0; } msg buffer access appln msg buffer cast to defined format mark busy application specific ready check build msg request transmission destination identifier get handler identifier
6/5/2001NEST Wireless OEP Breakout28 Completion Event Underlying message layer notifies all sending components of completion event –may need to resume activity after other’s completion –provides reference to sent buffer to identify action Here event propagated as output done char TOS_EVENT(INT_TO_RFM_SUB_MSG_SEND_DONE)(TOS_MsgPtr sentBuffer){ if (VAR(pending) && sentBuffer == &VAR(data)) { VAR(pending) = 0; TOS_SIGNAL_EVENT(INT_TO_RFM_COMPLETE)(1); return 1; } return 0; }
6/5/2001NEST Wireless OEP Breakout29 Challenge Application Developmetn Specification of challenge application is a process layout how coordination and synthesis services plug in develop platform requirements Consider sequence of applications –interactive spaces –flock of model cars –Multi-agent pursuit-evasion
6/5/2001NEST Wireless OEP Breakout30 Challenge App: pursuer/evader contest obstacles evader UAVs active markers UAVs (pursuers) capable of: *flying between obstacles *seeing a limited region *placing active markers Terrain: with obstacles *not accurately mapped Evader capable of: *moving between obstacles (possibly actively avoiding detection) Active Markers : *form sensor field
6/5/2001NEST Wireless OEP Breakout31 obstacles evader UAVs UAVs (pursuers) capable of: *flying between obstacles *seeing a region around them (limited by the occlusions) Terrain: *with fixed obstacles *not accurately mapped The “rules” of the game Evader capable of: *moving between obstacles (possibly actively avoiding detection) Objective: find the evader in minimum time
6/5/2001NEST Wireless OEP Breakout32 LaValle, Latombe, Guibas, et al. considered a similar problem but assume the map of the region is known, the pursuers have perfect sensors, and worst case trajectories for the evaders: How many UAVs are needed to win the game in finite time? 1 agent is sufficient2 agents are needed (no matter what strategy a single pursuer chooses, there is a trajectory for the evader that avoids detection) Strategies for pursuit-evasion games
6/5/2001NEST Wireless OEP Breakout33 Deng, Papadimitriou, et al., study the problem of building a map (seeing all points in the region) traversing the smallest possible distance. standard “keep wall to the right” algorithm algorithm that takes better advantage of the cameras capabilities Exploring a region to build a map
6/5/2001NEST Wireless OEP Breakout34 A two step solution… exploration followed by pursuit is not efficient sensors are imprecise worst case assumptions the trajectories of the evaders leads to very conservative results exploration pursuit
6/5/2001NEST Wireless OEP Breakout35 A different approach… Use a probabilistic framework to combine exploration and pursuit-evasion games. Non determinism comes from: poorly mapped terrain noise and uncertainty in the sensors probabilistic models for the motion of the evader and the UAVs exploration pursuit
6/5/2001NEST Wireless OEP Breakout36 Markov Decision Processes state state x t X := {1,2,…, 16} action actionu t U := { up, down, left, right } time timet {1, 2, 3,…} transition probability function p(x,x ’,u) = P(x t+1 =x ’ | x t =x, u t =u) control policy control policy (stochastic) : U X [0,1] P(u t = u| x t =x, ) = (u, x) control policy control policy (deterministic) : X U u t = (x t ) (almost surely) .1| right | right.1| right … 4 x goal 21 …
6/5/2001NEST Wireless OEP Breakout37 Markov Decision Processes cost cost J = E [ T goal | ] (to be minimize) optimal control policy optimal control policy * J * = min J with 0 (additive) where T goal := min { t : x t = x goal } one can also write x goal 21 … | right.1| right … 4 Ø 1| -.1| right
6/5/2001NEST Wireless OEP Breakout38 Sub-optimal policies Q : How does one evaluate which control action will maximize the probability of finding the evader? greedy policy greedy policy ( + ) pursuit policy that, at each instant, maximizes the probability of finding the evader at the next time instant
6/5/2001NEST Wireless OEP Breakout39 Sub-optimal policies probabilistic map for the position of the evader Q : How does one evaluate which control action will maximize the probability of finding the evader? A : By keeping track of the probability of the evader being at each possible position greedy policy greedy policy ( + ) pursuit policy that, at each instant, maximizes the probability of finding the evader at the next time instant
6/5/2001NEST Wireless OEP Breakout40 Problem: For given paths of several UAVs, how to fuse the data sensed by each of them (in real-time) to build a global map? Map building
6/5/2001NEST Wireless OEP Breakout41 Probabilistic map building Bayes’ rule Problem: For given paths of several UAVs, how to fuse the data sensed by each of them (in real-time) to build a global map?
6/5/2001NEST Wireless OEP Breakout42 How each project will use the platform...
6/5/2001NEST Wireless OEP Breakout43 What components will be contributed...
6/5/2001NEST Wireless OEP Breakout44 What you’d like to see in the platform...