Pysense: wireless sensor computing in Python?
-
Upload
davide-carboni -
Category
Technology
-
view
2.349 -
download
1
description
Transcript of Pysense: wireless sensor computing in Python?
![Page 1: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/1.jpg)
1
Davide Carboni,
ICSOFT 2010, Athens 22-24 April
PySensePython Decorators for Wireless Sensor Macroprogramming
![Page 2: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/2.jpg)
2
Who, where...
2
geoweb.crs4.ittwitter.com/__dadaista__
locative sensor web ubicomp web of things mobile
![Page 3: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/3.jpg)
3
wireless sensor networking today
communication
communicationcomputation
![Page 4: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/4.jpg)
4
wireless sensor computing
communication--
communication--
computation++
computation++
computation--
![Page 5: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/5.jpg)
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)
![Page 6: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/6.jpg)
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
![Page 7: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/7.jpg)
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
![Page 8: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/8.jpg)
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
![Page 9: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/9.jpg)
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)
![Page 10: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/10.jpg)
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
![Page 11: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/11.jpg)
11
Motivation
• Python: – easy to use, – easy to learn, – rapid prototyping
And because we like to go beyond
the limits
![Page 12: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/12.jpg)
12
What is a python decorator
Syntactic sugar@foodef f(x):<implementation>
Equivalent to callfoo(f) where foo returns a function
![Page 13: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/13.jpg)
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
![Page 14: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/14.jpg)
14
Elements of PySense
• Region• Group• @mote• @onboard• @onbase• @auto
![Page 15: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/15.jpg)
15
PySense Regions
Region(“/(0,0,100,100)”) | Region(“/foo/3/312”)
![Page 16: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/16.jpg)
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
![Page 17: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/17.jpg)
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,...
![Page 18: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/18.jpg)
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
![Page 19: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/19.jpg)
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
![Page 20: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/20.jpg)
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
![Page 21: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/21.jpg)
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
![Page 22: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/22.jpg)
22
VM on board
MBED board64KB RAM
Clock 100MHzUSB, ETH, ...
Running pythonand HTTP
is too demanding
![Page 23: Pysense: wireless sensor computing in Python?](https://reader034.fdocuments.us/reader034/viewer/2022051817/5484c9565906b5a8158b47bc/html5/thumbnails/23.jpg)
23
Questions & Answers