pysense: wireless sensor computing in python?

23
1 Davide Carboni, ICSOFT 2010, Athens 22-24 April PySense Python Decorators for Wireless Sensor Macroprogramming

Upload: davide-carboni

Post on 06-Dec-2014

2.348 views

Category:

Technology


1 download

DESCRIPTION

PySense aims at bringing wireless sensor (and "internet of things") macroprogramming to the audience of Python programmers. WSN macroprogramming is an emerging approach where the network is seen as a whole and the programmer focuses only on the application logic. The PySense runtime environment partitions the code and transmits code snippets to the right nodes finding a balance between energy consumption and computing performances.

TRANSCRIPT

Page 1: Pysense: wireless sensor computing in Python?

1

Davide Carboni,

ICSOFT 2010, Athens 22-24 April

PySensePython Decorators for Wireless Sensor Macroprogramming

Page 2: Pysense: wireless sensor computing in Python?

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?

3

wireless sensor networking today

communication

communicationcomputation

Page 4: Pysense: wireless sensor computing in Python?

4

wireless sensor computing

communication--

communication--

computation++

computation++

computation--

Page 5: Pysense: wireless sensor computing in Python?

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?

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?

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?

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?

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?

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?

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?

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?

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?

14

Elements of PySense

• Region• Group• @mote• @onboard• @onbase• @auto

Page 15: Pysense: wireless sensor computing in Python?

15

PySense Regions

Region(“/(0,0,100,100)”) | Region(“/foo/3/312”)

Page 16: Pysense: wireless sensor computing in Python?

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?

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?

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?

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?

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?

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?

22

VM on board

MBED board64KB RAM

Clock 100MHzUSB, ETH, ...

Running pythonand HTTP

is too demanding

Page 23: Pysense: wireless sensor computing in Python?

23

Questions & Answers