a runtime system for logical-space programming · a runtime system for logical-space programming el...

35
A Runtime System for Logical-Space Programming El´ oi Pereira [email protected] eloipereira.com cpcc.berkeley.edu 2nd International Workshop on the Swarm at the Edge of the Cloud (CPSWeek) April 13 2015, Seattle, Washington Cyber-Physical Cloud Computing, UC Berkeley Research Center, Portuguese Air Force Academy

Upload: others

Post on 24-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

A Runtime System for Logical-SpaceProgramming

Eloi [email protected]

cpcc.berkeley.edu

2nd International Workshop on the Swarm at the Edge of the Cloud(CPSWeek)

April 13 2015,Seattle, Washington

Cyber-Physical Cloud Computing, UC BerkeleyResearch Center, Portuguese Air Force Academy

Page 2: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Thanks!

• Clemens Krainer, U. Salzburg

• Pedro Silva, former Po. Air Force Academy Researcher Center

• Prof. Raja Sengupta, UC Berkeley (adviser)

• Prof. Christoph Kirsch, U. Salzburg (co-adviser)

• UAV team from Po. Air Force Academy Researcher Center

Page 3: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Agenda

• Spatial Computing

• Logical-space computing by example

• Semantics

• Runtime system

• Field test: Oil-spill monitoring scenario

Page 4: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Spatial Computing

• Computation is becoming ubiquitously and spatially embedded inour environment.

• Mobile cyber-physical systems such as smartphones and robots areequipped with sensors and actuators that observe and manipulatetheir spatial environment.

• This kind of computation that exhibits a behavior in space iscommonly known as spatial computing [4].

Figure : Bridging programs and mobile machines.

Page 5: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space Computing• Programmer manipulates a symbolic space abstraction of the world

• Runtime system is in charge handling the physical world:• ensuring that symbolic observations are physically consistent• interpreting and executing logical actions in the physical world

Figure : Logical-space computing.

Page 6: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Example 1 - Find and track oil-spill

• Consider a mission consisting of sending a Unmanned Aerial Vehicle(UAV) to the location of an oil-spill

• The UAV has a standard waypoint controller and is equipped with avision computing system that detects and geo-references oil-spills

• The exact physical location of the oil-spill is unknown a priori,although it is known to be within a given rectangular areaparametrized by its North-East and South-West GPS locations,(37.04,−8.59) and (36.94,−8.79)

Page 7: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Physical-space

• Spatial computing often involves defining the behavior of machinesin a geometrical location model such as GPS coordinates or indoorlocal coordinates [6].

• In physical-space programming the operator works at the GPScoordinates level

• The UAV operator would perform the following steps:

1 select a UAV to perform the mission2 specify a searching pattern comprised by the sequence of GPS

locations inside the area delimited by (37.04,−8.59) and(36.94,−8.79)

3 the computing vision system finds an oil-spill, and sends the locationto the operator, e.g., (36.99,−8.69)

4 the operator creates a new waypoint at (36.99,−8.69)

Page 8: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Physical-space

• List of waypoints to be executed by the UAV using Mavlink protocol

QGC WPL 1100 1 0 16 0.15 0 0 0 -8.58 37.15 550 10 1 0 16 0.15 0 0 0 -8.62 37.01 550 10 1 0 16 0.15 0 0 0 -8.64 36.97 550 10 1 0 16 0.15 0 0 0 -8.69 36.99 550 1

• Physical-space execution:

→ → →

Figure : Physical-space execution.

• Pros: expressiveness; full control of the spatial semantics

• Cons: difficult to verify; easy to make mistakes

Page 9: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Symbolic-Space

• Symbolical space programming uses symbols and explicit relationsover those symbols, e.g., “1234 Oxford Street, Berkeley, CA, USA”.

• The oil-spill modelled usign Robin Milner’s Bigraphical model[12]and programmed using BigActors [13]

seearchArea0

oilSpill0

shore

uav0

BigActor hosted_at uav0 with_behavior{ MOVE_HOST_TO searchArea0 observe CHILDREN(PARENT(HOST)) loop{ react{ case obs.contains(oilSpill0) => MOVE_HOST_TO oilSpill0 case _ => observe CHILDREN(PARENT(HOST)) } }}

Figure : Symbolical-space model for the oil-spill scenario.

• MOVE HOST TO(loc) denotes the Bigraph Reaction Rule:

01

01HOST

locHOST

loc

Page 10: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Symbolic-Space

• Symbolical execution:

seearchArea0

oilSpill0

shore

uav0

seearchArea0

oilSpill0

shore

uav0

seearchArea0

oilSpill0

shore

uav0

Figure : Symbolical-space execution for the oil-spill scenario.

• Pros: location space is smaller (easier to verify); names can bedomain-specific; explicit containment semantics

• Cons: disregards physical properties of space necessary to generaterobot commands

Page 11: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Hybrid-space

• Hybrid models augment symbolic locations with physical metadata

• Jiang and Steenkiste [10] introduce Aura Location Identifiers thatcombine hierarchical symbolic locations with physical coordinates

• Example: (pseudo-code)uav loc ali://shore/#(37.15,-8.58)

searchArea loc

ali://sea/#{(37.04, -8.59),(37.04, -8.79),(36.94, -8.79),(36.94, -8.79)-0}

Move uav to ali://sea/#(37.01,-8.62)

Move uav to ali://sea/searchArea/#(36.97,-8.64)

oilSpill loc ali://sea/searchArea#(36.99,-8.69)

Move uav to ali://sea/searchArea/oilSpill#(36.99,-8.69)

• Pros: synthesizing control actions is now possible

• Cons: programmer must deal with both physical and symboliclocations; programmer can introduce inconsistencies between logicaland physical model

Page 12: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Logical-Space

• Logical-space

seearchArea0

oilSpill0

shore

uav0

shore

searchArea0

uav0

oilSpill0

BigActor hosted_at uav0 with_behavior{ MOVE_HOST_TO searchArea0 observe CHILDREN(PARENT(HOST)) loop{ react{ case obs.contains(oilSpill0) => MOVE_HOST_TO oilSpill0 case _ => observe CHILDREN(PARENT(HOST)) } }} (β,γ)

locuav0

MOVE_HOST_TO loc

locuav0

Bigraph Reaction Rule:

Figure : Logical-space program.

Page 13: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Logical-Space

The runtime system executes the following actions:

1 select the physical platform named uav0 to execute the mission

2 realize that the physical interpretation of oilSpill0 is unknown

3 look for location searchArea0 which is specified to containoilSpill0

4 generate a search pattern in the rectangle defined by p0 and p1

5 and as soon as the physical interpretation of oilSpill0 is provided,generate a waypoint at that location

Page 14: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Programming Example 1 in Logical-Space

→ → →

→ → →

Figure : Logical-space execution.

• Programmer uses oilSpill0 regardless of its physical location

• The runtime system is responsible for taking the UAV to therespective physical location

Page 15: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Example 2: Oil-spill tracking

• Example: UAV persistently tracking an oil-spill

• Logical-space programming:BigActor hosted_at "uav" with_behavior{

loop{MOVE_HOST_TO oilSpill0

}}

• The physical interpretation of oilSpill0 changes over time

• The runtime generates a sequence of different waypoints at differentphysical locations of the target

0 1 0 16 0.15 0 0 0 -8.58 37.15 550 10 1 0 16 0.15 0 0 0 -8.62 37.01 550 10 1 0 16 0.15 0 0 0 -8.64 36.97 550 10 1 0 16 0.15 0 0 0 -8.69 36.99 550 1

• Persistently moving to the same location in logical-space isequivalent to target tracking in physical-space

Page 16: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Example 3: Rendezvous

• Rendezvous at a location

BigActor hosted_at "uav0" with_behavior moveBigActor hosted_at "uav1" with_behavior move...BigActor hosted_at "uavN" with_behavior move

def move = {loop{

MOVE_HOST_TO(oilSpill0)}

}

• The logical rendezvous location does not change although thephysical interpretation might change during execution

• A rendezvous in logical-space is a formation flight, i.e., a “swarm”,in physical-space

Page 17: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space Programming

• Logical-space programming deliberately reduce the expressivenessprovided by physical space models for the sake of correctness ofspatial execution and for the sake of succinctness of programs

• Pros:• programmer focuses on the high-level spatial dynamics• programmer does not need to keep track of changes of the physical

interpretation• locations can be purely “logical” (no physical interpretation), e.g., a

cloud-based app logically located in a smartphone and which realphysical location is unknown

• Cons:• programmer hands low-level physical behavior to the runtime system• programmer have a notion of a logical distance, not physical

Page 18: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Literature on physical-space programming models

• Amorphous computing [1, 5, 3] addresses large aggregates ofhomogeneous devices that are distributed to fill a physical space.

• Roman et al. [14] introduce active spaces through Gaia middlewarethat abstract devices in a given physical space. Users are able to usedevices, services, and applications that are contained by the activespaces that they have access.

• Iftode et al. [9, 7] introduce Spatial Programming (SP) as aprogramming model for networks of embedded systems deployed inthe physical space

• Example of the creation of a space in SP:space2=rangeOf({space1:camera},10), i.e., space2 is a circularspace with radius 10 centred at a camera located at space1

Page 19: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Literature on symbolic-space programming models

• Milner addresses mobility in the π−calculus [11], where processescan change location by being communicated through channels.

• Cardelli addresses mobility explicitly in the Ambient calculus [8],which models computation that executes in bounded locations.

• Milner introduced the bigraphical formalism [12], which combinesnested location and connectivity.

• We introduced the BigActor model [13] as a model forstructure-aware computation, where actors [2] are embedded andoperate over a bigraphical model of the world.

Page 20: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space computing semantics

Definition (Spatial Computing Configuration)A configuration is a tuple

〈α | S | η〉

where

• α is a set of spatial agents:• Local state and behavior• Request observations and react upon its result• Request control actions

• S = (L,P, β, γ) is a spatial structure that contains a logical model,a physical model, and the physical interpretation

• η is a set of requests of the kind OBS(a, q), READY(a, obs), orCTR(a,R ⇒ R ′). OBS(a, q)

Page 21: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space computing semantics - Computation

• A spatial agent performs computation over its own local state

• We assume a generic host language with semantics defined bytransition →λ

〈fun : a〉E ` f ; b →λ E ′ ` b

〈α, [E ` f ; b]a | S | η〉 → 〈α, [E ′ ` b]a | S | η〉

Page 22: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space computing semantics - Observation

• Observation is asynchronous: request → sense → receive

〈req obs : a, observe(q)〉

〈α, [E ` observe(q); b]a | S | η〉 → 〈α, [E ` b]a | S | η, OBS(a, q)〉

〈sense : OBS(a, q)〉(Lq, βq) = [[q]](L,P) Lq ⊆L L′

〈α | (L,P, β, γ) | η, OBS(a, q)〉 → 〈α | (L′,P, β′, γ) | η, READY(a, Lq)〉

〈rcv obs : a, react(x)〉E ′ = E [x/obs]

〈α, [E ` react(x); b]a | S | η, READY(a, obs)〉 → 〈α, [E ′ ` b]a | S | η〉

Page 23: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space computing semantics - Actuation

• Actuation is also asynchronous: request → actuate〈req ctr : a, control(R ⇒ R′)〉

〈α, [E ` control(R ⇒ R′); b]a | S | η〉 → 〈α, [E ` b]a | S | η, CTR(a,R ⇒ R′)〉

〈actuate : CTR(a,R ⇒ R′)〉R ⊆L L R′ ⊆L L′ PR ⊆P P PR′ ⊆P P′

〈α | (L,P, β, γ) | η, CTR(a,R ⇒ R′)〉 → 〈α | (L′,P′, β, γ) | η)〉

Page 24: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Spatial computing semantics - Environment

• Environment can change the physical space〈env : P′〉

〈α | (L,P, β, γ) | η〉 → 〈α | (L,P′, β, γ) | η〉

Page 25: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space Runtime System

• Logical-space: Milner’s Bigraphs [12]

• Spatial Agents: Scala BigActors [13]• Scala: a JVM-based language• Scala Actors: concurrency and distribution• BigActors provide means for observing and controlling logical spaces

• Middelware: Robot operating system (ROS)• Open source• Publisher-subscriber and request-reply patterns

• Current supported and tested hardware:• UAVs equipped with Piccolo II/SL autopilot• AIS receivers

• Code repositories:• BigActors:https://bitbucket.org/eloipereira/bigactors

• Logical-space RT:https://bitbucket.org/eloipereira/bigactorrte

Page 26: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Logical-Space Runtime System

Figure : Logical-space runtime system.

Page 27: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Bigraph Driver

Figure : Bigraph Driver example.

Page 28: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Distributed Bigraph Estimates

Figure : Distributed bigraph example

Page 29: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

BRR Driver

Figure : BRR Driver example.

Page 30: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Field test: Oil-spill monitoring scenario

Page 31: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Conclusions

• Computation is becoming spatial and ubiquitously embedded ansspatially distributed in our world

• We introduce logical-space programming, a spatial programmingparadigm where programs are written over symbolic-space while theruntime system deals with the interactions and consistency withphysical-space

• We introduce a logical-space runtime system that uses bigActors forlogical-space programming of mobile robots

• We demonstrate the use of logical-space programming for specifyinga mission of vehicles and sensors performing an environmentalmonitoring scenario

Page 32: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

Thank You!

Page 33: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

References I

H. Abelson, D. Allen, D. Coore, C. Hanson, G. Homsy, T. Knight, R. Nagpal, E. Rauch,

G. Sussman, and R. Weiss.Amorphous Computing.Communications of the ACM, 43(5):74–82, 2000.

G. Agha.

Actors: a model of concurrent computation in distributed systems.MIT Press, Cambridge, MA, USA, 1986.

J. Bachrach and J. Beal.

Programming a Sensor Network as an Amorphous Medium.Technical report, MIT - Computer Science and Artificial Intelligence Laboratory, 2006.

J. Beal, S. Dulman, and K. Usbeck.

Organizing the aggregate: Languages for spatial computing.In Formal and Practical Aspects of Domain-Specific Languages, pages 1–60. InformationScience Reference, 2012.

J. Beal and G. Sussman.

Biologically-inspired robust spatial programming.Technical Report January, 2005.

B. Becker, D. Beyer, H. Giese, F. Klein, and D. Schilling.

Symbolic invariant verification for systems with dynamic structural adaptation.Proceeding of the 28th international conference on Software engineering - ICSE ’06,page 72, 2006.

Page 34: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

References II

C. Borcea, C. Intanagonwiwat, P. Kang, U. Kremer, and L. Iftode.

Spatial programming using smart messages: design and implementation.In 24th International Conference on Distributed Computing Systems, 2004. Proceedings.,pages 690–699. Ieee, 2004.

L. Cardelli and A. Gordon.

Mobile ambients.In Foundations of Software Science and Computation Structures, pages 140–155. Springer,1998.

L. Iftode, C. Borcea, a. Kochut, C. Intanagonwiwat, and U. Kremer.

Programming computers embedded in the physical world.The Ninth IEEE Workshop on Future Trends of Distributed Computing Systems, 2003.FTDCS 2003. Proceedings., pages 78–85, 2003.

C. Jiang and P. Steenkiste.

A hybrid location model with a computable location identifier for ubiquitous computing.In UbiComp 2002: Ubiquitous Computing, pages 246–263. Springer, 2002.

R. Milner.

Communicating and mobile systems: the π-calculus.Cambridge Univ Press, 1999.

R. Milner.

The Space and Motion of Communicating Agents.Cambridge University Press, 2009.

Page 35: A Runtime System for Logical-Space Programming · A Runtime System for Logical-Space Programming El oi Pereira eloi@berkeley.edu eloipereira.com ... 0 1 0 16 0.15 0 0 0 -8.58 37.15

References III

E. Pereira, C. Kirsch, R. Sengupta, and J. Borges de Sousa.

Bigactors - a model for structure-aware computation.In 4th International Conference on Cyber-Physical Systems. ACM/IEEE, April 2013.

M. Roman and R. Campbell.

Gaia: enabling active spaces.Proceedings of the 9th workshop on ACM . . . , pages 229–234, 2000.