Title: Declarative Programming for Modular Robots Ashley-Rollman, De Rosa, Srinivasa, Pillai, Goldstein, Campbell
1Declarative Programming for Modular
RobotsAshley-Rollman, De Rosa, Srinivasa,
Pillai, Goldstein, Campbell
2Locally Distributed Predicates (LDP) Meld
- Two very different approaches to declarative
programming for modular robots - Meld - logic programming
- LDP - distributed pattern matching
- Both achieve higher goals
- Dramatically shorter code
- Automatically distributed
- Automatic messaging
3LDP Overview
- Originated in Distributed Watchpoint system
- Needed to describe and detect incorrect
distributed state configurations - Locally Distributed Predicates
- Locally Distributed involving a bounded number
of connected modules - Predicates boolean expressions over state,
temporal, and topological variables - An LDP program consists of a number of
predicates, each with one or more attached
actions - Every predicate/action pair is executed in
parallel
4Meld Overview
- Logic programming language
- Inspired by P2 Loo et. al. 2005
- Consists of facts and rules for deriving new
facts - When a fact changes, derived facts are
automatically deleted - Programs typically consider local neighborhoods
- Additional support for making non-local
neighborhoods
5LDP and Meld A Comparison
LDP Meld
Approach Predicate Matching Proof Search
Concise Code (vs. C/Java) ? ?
Automatic Messaging ? ?
Operations over all neighbors count forall
Quantified (Variably-Sized) Expressions ?
Automatic Fact Retraction ?
State Management By Programmer By System
6Example 3D Shape Change Algorithm
- lt20 lines of Meld or LDP
- Connectivity maintenance guaranteed by algorithm
7Example 1 Setting Module State
type state(module, min int). state(A, FINAL) -
isSeed(A). state(B, FINAL) - neighbor(A,
B), state(A, FINAL), in(B).
forall (a) where (a.isSeed) do a.state
FINAL forall (a,b) where (a.state FINAL)
(b.inside) do b.state FINAL
LDP
Meld
- If the module is the seed
- Set the seeds state to FINAL
- For every module inside the target shape
- If it is next to a module in FINAL state
- Set the modules state to FINAL
8LDP and Meld A Comparison
LDP Meld
Approach Predicate Matching Proof Search
Concise Code (vs. C/Java) ? ?
Automatic Messaging ? ?
Operations over all neighbors count forall
Quantified (Variably-Sized) Expressions ?
Automatic Fact Retraction ?
State Management By Programmer By System
9Example 2 Evaluation Over all Neighbors
type deletable(module). type notChild(module,
module). notChild(A, B) - neighbor(A, B),
parent(B, C), A ! C. deletable(A) -
forall neighbor(A, B) notChild(A, B).
forall(a,b) where (b.parent ! a.id) do
a.notChild.add(b.id) forall(a) where
size(a.notChild) size(a.neighbors) do
a.delete()
LDP
Meld
- A module can only be deleted if none of its
neighbors are children - We first determine which neighbors are not
children - If there are no children, the module can be
deleted
10LDP and Meld A Comparison
LDP Meld
Approach Predicate Matching Proof Search
Concise Code (vs. C/Java) ? ?
Automatic Messaging ? ?
Operations over all neighbors count forall
Quantified (Variably-Sized) Expressions ?
Automatic Fact Retraction ?
State Management By Programmer By System
11Example 3 Self-deleting Gradients
12Example 3 Self-deleting Gradients
forall (a,b) where (a.value gt b.value) do
a.value b.value 1 forall (a,b0,6) where
count(a.value gt bi.value) 0 a.value ! 0
do a.value INF
type gradient (module, min int). gradient(A, N)
- neighbor(A, B),
gradient(B, M), N M
1.
LDP
Meld
- Meld deletes all dependent facts when the root
fact is deleted - LDP directly manipulates state variables, so
retraction must be manual - LDP must specify the maximum number of neighbors
13LDP and Meld A Comparison
LDP Meld
Approach Predicate Matching Proof Search
Concise Code (vs. C/Java) ? ?
Automatic Messaging ? ?
Operations over all neighbors count forall
Quantified (Variably-Sized) Expressions ?
Automatic Fact Retraction ?
State Management By Programmer By System
14Example 4 Spanning Tree Creation
15Example 4 Spanning Tree Creation
forall (a) where (a.isRoot 1) do a.parent
a.id forall (a,b) where (a.parent ! -1)
(b.parent -1) do b.parent a.id
type parent(module, first module). parent(A, A)
- root(A). parent(B, A) - neighbor(B, A),
parent(A, _).
- Newer versions of Meld use the first aggregate
to ensure uniqueness - This qualifier is not sufficient for more complex
situations
16Example 4b Spanning Tree Creation
forall (a) where (a.isRoot 1) do a.parent
a.id forall (a,b) where (a.parent ! -1)
(b.parent -1) do b.parent a.id
type possibleParent(module, module, int). type
bestParent(module, min int). type parent(module,
module). parent(A, A) - root(A). possibleParent(B
, A, T) - neighbor(A, B), parent(A,
_) , T
localTimeStamp(). bestParent(B, T) -
possibleParent(B, _, T). parent(B, A) -
possibleParent(B, A, T), bestParent(B,
T).
- Without first, Meld must use timestamps to
ensure exactly one unique parent - LDP uses a single state variable, and thus can
never have more than one parent
17LDP and Meld A Comparison
LDP Meld
Approach Predicate Matching Proof Search
Concise Code (vs. C/Java) ? ?
Automatic Messaging ? ?
Operations over all neighbors count forall
Quantified (Variably-Sized) Expressions ?
Automatic Fact Retraction ?
State Management By Programmer By System
18Future Research
- Performance enhancements/optimizations
- Additional language features
- Support transactions
- Applicability to other application domains
- Explore tradeoffs between automated and manual
state control - Find a balance that allows programmers to
maintain state while gaining some or all of the
benefits of automated state
Interested in Meld/LDP? Email mderosa,mpa_at_cs.cmu
.edu