Pysense: wireless sensor computing in Python?
-
Upload
davide-carboni -
Category
Technology
-
view
2.354 -
download
1
description
Transcript of Pysense: wireless sensor computing in Python?
1
Davide Carboni,
ICSOFT 2010, Athens 22-24 April
PySensePython Decorators for Wireless Sensor Macroprogramming
2
Who, where...
2
geoweb.crs4.ittwitter.com/__dadaista__
locative sensor web ubicomp web of things mobile
3
wireless sensor networking today
communication
communicationcomputation
4
wireless sensor computing
communication--
communication--
computation++
computation++
computation--
5
Decentralization
• In today cloud computing “computation costs less then storage” → “move the computation to data”
• In today wireless networks “computation costs less then communication” → move the computation to data (sensors)
6
Decentralization
• Wireless Sensor Computing– not only simple sensors connected to
a central computer, but rather elements capable of computation in a distributed system
• Computation Vs Communication– One byte sent demands 100 times
the energy of an integer instruction
7
Programming models
• Node-level programming– program for each node type (error
prone, difficult, only for experts)
• Network as DB– Good but limited to queries (TinyDB)
• Macroprogramming– Program the net as a whole, the
middleware partition the code on the nodes automatically
8
Use case
• given an energy consumption model E and an application code C, there exists a partitioning of code C={c1,c2,...,cn} and a set Tx of transmissions Tx={tx1,tx2,...,txk} which is optimal for E
9
PySense
• What is PySense– A programming model for Python– A middleware based on Python
decorators and API – It runs on:
• Base Runtime Environment (based on Python 2.6)
• Remote Runtime Environment (based on Python-on-a-chip)
10
What is not PySense
• Not ready to use solution• Not bound to a specific network
topology (mesh, clustering, ...) or network protocol stack (zigbee,tcp,...)
• Not efficient in terms of memory used by nodes
11
Motivation
• Python: – easy to use, – easy to learn, – rapid prototyping
And because we like to go beyond
the limits
12
What is a python decorator
Syntactic sugar@foodef f(x):<implementation>
Equivalent to callfoo(f) where foo returns a function
13
What is a python decorator
def foo(func):def my_f(*args):
do_something_pre()func(*args)do_something_post()
return my_f
@foodef f(x):
return x*x
14
Elements of PySense
• Region• Group• @mote• @onboard• @onbase• @auto
15
PySense Regions
Region(“/(0,0,100,100)”) | Region(“/foo/3/312”)
16
@mote
@moteclass M: def getX(self):pass def setY(self,y):pass
m=M()m.getX()
Finds a mote m with X,Y
Read X from m, translated in a network message from the invoker to m
17
@moteclass M:
def getX(self):pass
@onboarddef f(self,args):<code to move on node>
@onbasedef g(self,args):<code to run on base>
@autodef h(self,args):<some code>
Translated into a network message:
TO <addr> CALL f x,y,...
18
Simple program
r=Region(“/somewhere”) #somewhere
@mote
class CO2Sense:
def getConc(self):
pass
values=
[c.getConc() for c in r.items(CO2Sense)]
avg = sum(values)/len(values)
A lot of long range messages exchanged between base
and remotes
19
A little better
@mote
class CO2Sense:
def getConc(self):pass
class CO2Group(Group):
@onboard
def avg(self):
return sum([m.getConc() for m in self.motes]) / len(self.motes)
avg=CO2Group(r.items(CO2Sense)).avg()
The avg () will be runIn one remote elected
head of group
Short range messages
20
Where we are
• API and decorators implemented and tested on PC processes running python-on-a-chip interpreter and pipes for I/O
• Todo:– @auto– Deployment on real boards … we
want a real test bed not simulation
21
A lot to do
• Approach #1– running a VM and interpreter on the
mote– Memory demanding
• Approach #2– Compiling @onboard python on native
code – Need OTA reconf
Hey … this is a position paper
22
VM on board
MBED board64KB RAM
Clock 100MHzUSB, ETH, ...
Running pythonand HTTP
is too demanding
23
Questions & Answers