From: AAAI Technical Report SS-02-04. Compilation copyright © 2002, AAAI (www.aaai.org). All rights reserved. Automatic Synthesis of Controllers for Distributed Extended Abstract Assembly Eric Klavins ComputerScience Department California Institute of Technology Pasadena, CA91125 klavins@cs.caltech.edu Introduction Weconsider the problemof controlling hundredsof robots to performa task in concert. This problempresents many fundamentalissues to robotics, control theory and computer science. Witha great numberof robots, decentralization is critical due to the cost of communication and the needfor fault tolerance. In decentralizedcontrol, each robot should act based only on informationlocal to it. It then becomes difficult, however,to guaranteeor even derive the behavior of the entire systemgiven the behaviorsof the individual components.In this paper we address this difficulty in a novel way:Webegin with a specification of an assemblyand develop methodsthat allow us to automatically synthesize individual behaviorsso that they are guaranteedto produce the desired global behavior. Specifically, we consider the task of assemblingmany disk-shapedparts in the plane into copies of a prescribed assembly(formation), whichis specified by a graph. We not allowthe parts to collide, makingthe task moredifficult due to the non-trivial topology of the resulting 2n dimensional configuration space. As shownin Figure 1 we suppose that each part can moveitself and can play any role in an assembly,whichmakesthe task particularly rich. We first demonstratea meansof synthesizing from the specified assembly,a set of identical controllers for the parts to run whichhave the net effect of movingthe parts to form copies of the specified assemblywithoutcolliding. Theidea is that parts shouldjoin togetherto into subassemblies which should in turn join togetherto makelarger assembliesand so on. In (Klavins 2002) we introduce algorithms, summarized here, which perform the synthesis procedure described above. These algorithms are deployed in simulation and their performance is analyzed emperically. In (Klavins 2001), also summarizedhere, we give a proof of correctness of the algorithmwith respect to a discrete modelof the dynamics.Weare currently attemptingto extend this proof to the full hybrid dynamicsdescribedin (Klavins2002). Related Research Weare most strongly inspired by the work of Whitesides and his group (Bowdenet aL 1999; Breen et al. 1999) in meso-scale self-assembly. In this work, small, regular plastic tiles with hydrophobicor hydrophylicedgesare 4O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a) Initialpositions 0 °-%...o 8 b) Final positions Figure 1: The goal of the assembly problem. Each disk shapedpart mustmovefromits initial position (a) to a position in a a copyof the specified assembly(b). Dashedlines showthe resulting adjacencyrelationship E. There maybe leftover parts. placed on the surface of someliquid and gently shaken. Tiles with hydrophobicedgesare attracted along those edges while hydrophylicedgesrepel. Striking "crystals" emergeas larger and larger structures self assemble.Byusing different shapesand edgetypes, different gross structures can be created. At least twonext steps are apparent. First, these and similar methodsgenerallyproducearrays or lattices of parts, meaningthat there is no wayto terminate a regular pattern at, say, a 5 x 5 array of parts. Second,there is no known formal methodof starting with a specification of the desired emergentstructure and devisingthe structure of the individual parts. In this paper we address both of these issues by supposingthat each part can run aprograrnthat tells it when to join with another part, and whento repel it, basedon an appropriately synthesizedlookuptable. The Problem Weconsider a simple form of assemblyprocess by assuming that parts are programmable and able to sense the position and state of other nearbyparts. Westart with mdisk-shaped parts (of radius r) confinedto movein 2. Denote the position of part i by the vector xi. Wedesire that each part move smoothly,without colliding with other parts, so that all n parts eventually take somerole in an assemblyor formation. This is showngraphically in Figure 1. For simplicity, we assumethat the dynamicsof each disk are given by ~ ---- ui. Let G = (V, E) be a finite undirected, acyclic graph tree). Wewill call such a graph an assembly. SupposeG = (V, E) with [VI = n and first consider the case wherera n. The problemis to producea control algorithmto be used by each part that will control the mparts to move,without colliding, fromarbitrary initial conditionsto positions such that there exists a permutation h of { 1, ..., m}suchthat I. If {h(i),h(j)} E Ethend,~br-e < lixi-xjl[ < k,~t~+e; 2. If {h(i), h(j)} ¢ E then ]]xi - xj][ dnbr. Here d,b~ > 0 and e > 0 are parameters. The image h(i) of i is called the role of i in the assembly.Wefurthermore require that these assembliesbe stable to disturbancesin the sense that the set of points z~ .... , z,n satisfying the above conditions is an attractor of the closed loop dynamicswe will construct. If m = kn for somek E Z then we still require the aboveexceptnowwith respect to a disjoint union of k copies of G. Andof course, if mis not a multiple of n, then we require that as manyparts as possible form assembliesin the obviousway. Wenote that not all trees can be embedded in the plane in such a waythat neighbors are distance dnbr apart and nonneighborsare distance greater than dnbrapart. For simplicity in whatfollows, we restrict the assemblieswespecify to those that can be so embedded. Controller Structure In general we will assumethat parts have limited sensing and communication capabilities and we allow themto store a discrete state, si, along with their control programs.In particular, weassumethat part i can sense its ownposition and the positions and discrete states of other parts within someranged,,,~,= > 0 of xi. The methodswe develop below will, given a description of the desired assemblystructure, synthesize a hybrid controller Hi of the form shownin Figure 2. The goal is that wheneach pan runs a copy of Hi (fromdifferent initial conditions), the parts will self assemble. The controller Hi is described by a continuous control law Fi, a predicate A called the attraction predicate and a discrete update rule y. Fi describes the force that the part should apply to itself. A(si,sj) {t rue, fa lse} determines whether parts i and j with states si and sj should try to becomeneighbors,thereby forminga larger assembly. The update rule 9(si, sj, s~) determinesthe new discrete state of pank basedon the joining of parts i and j. Loosely, the operation of Hi is as follows. Pan i starts with some initial position xi(O), the initial state si(O) = (1, 1) 41 geceivedstate update (st,sa) st +- g(s,,s.s,) Figure2: Thestructure of the hybrid controller that is constructed by the compilationschemein this paper. Arcsdenote transitions and are labeled by a predicate/action pair. Whenan arc’s predicate becomestrue, the action is taken andcontrol transfers fromthe sourceof the arc to the target of the arc. neighbors.It then applies the control force Fi(x, ~1, s) to itself until either a newneighboris detectedor it receives a state update from a neighbor. Here x, ~ and s are mdimensional vectors describing the completestate of the system, However, Fi mayonly use the states of the parts within distance dm~zof part i. The force Fi is computedbased on the position, velocity anddiscrete state of part i andon the discrete states of the sensedparts. The task of an automatic synthesis procedure, performed by what weare calling a compiler, is to take a description Gspecof a desired assemblyand produceHi -- in this case, F~, .it and g. Theconstructionof A and 9 are describednext and the construction of F~, whichrequires A, is discussed after that. Compilation of Assembly Rules from Specifications Anassemblycan be specified simply by listing whichroles in the assemblyare adjacent -- that is, by a graph. As mentioned above, we restrict ourselves to the situation where the adjacencygraphs are trees, leaving the detail of arbitrary graphs to future work. In any case, we believe that assemblingan arbitrary graphwill start with the assembly of a spanningtree of that graph. Thegoal of this section is to produce the attraction predicate A and the update rule g from a specified assembly Gsz,~c = (V~p~, E,~), which we assume is a tree. This requires first generatinga set of subassembliesof Gs~eand then compilingA and 9 from the set. Discrete State of a Part Weintend that the parts control themselvesto first formsubassemblies of G~pe~,and from those subassemblies form larger subassemblies and so on until G,pecis finally formed. Thediscrete state of a part must, therefore, include a reference to the subassemblyin which it currently plays a role. To this end, we build a list of the particular (connected) subassemblies we will allow: 9 = {G1, ..., Gp}. Werequire that each Gi ¢ S is of the form (V~, Ei) where l~ -- {1 .... , {V~{}and Ei C I~ x Vii. Althoughthis representation of subgraphsin 9 is arbitrary, becausethe vertices in ~ could have been namedin other ways, somecormnon schemeis required for a graceful definition of the states of parts. Thelist 9 can be built in various ways.Themostobvious wayis to include all O(2n) subassembliesin the list. Asexpalinedin (Klavins2002), a satisfactory list can also be built of size O(n). Thediscrete state of a part consists of a pair si = (j, k) Z2 wherej is the index of a subassembly in 9 and k E ~ is a role in that subassembly.Wedenote the graph obtained from G1and G2by joining a vertex i E G1to a vertex j E G2by Gl.i ~ G2.j. Generating Update Rules Froman assemblyset S, we can state the definition of A simply: Definition 1 GivenS, the attraction predicate J[ is defined as A(si, sj) = true ~ 3 G E 9 such that si ¯ sj "~ G. The symbol _~ denotes graph isomorphism. Wecan also define the updaterule g. Definition 2 GivenS and states si and sj with A(si, sy) true, the update rule g is defined as follows. SupposeG"~ s~ ~ sj has index k in ~, supposeh : si ¯ sj --~ G witnesses this isomorphismand supposesi = (a, b). Then g(si,sj, sl) -- (k,h(b’)) where¥ e V(si ~ sj) is the nameof vertex b after taking disjoint unions in of the $ operation. If A(si, sj) = false thenthe updaterule is notdefined:g( si, sj, sl ) "-- .1_. The procedurefor determiningthe values of J[ and g require determining tree isomorphisms-- which, although tractable (Reyner1977) is likely too time consumingto done online. Wecan, however, perform all the necessary computationsoffline by compiling9 into a table. The result is that Hi can makeall discrete transitions essentially instantaneouslybecauseall that is required is a table lookup. Furthermore,the size of the table is O([~[2n3). [~[ can taken to be ca, so that even complicatedassembliesrequire only O(ns) storage. The details are given in (Klavins2002). Implementation of Assembly Rules Completingthe controller Hi shownin Figure 2 requires a definition of F/as well as somemethodby whichparts can communicate.In this section we define an Fi and assume a simple communicationsschemethat works in simulation and about which we have a preliminary analytical understanding. Wesuppose that parts can only communicatewith their neighbors. 42 An Example Implementation For each part i, we can decide, using ./t, whetherpart i should movetowardj or not. To this end define sCi) = {j I llxi- z~ll < din,x} Attract(i) = ({j I A(si, sj)} U Nbrs(i)) n Repel(i) = ({j I -~(si,s~)} - Nbrs(i)) n S(i) is the set of parts that i can sense. Notethat these sets are easily computedfroma table compiledfrom a given G~p~.Onewayof formingthe control law Fi is to sum, for each j E Attract(i) a vector field Fatt whichhas an equilibriumset at distance dnb~fromxj and for each j E Repel(i) a vector field F~pwhichhas xj as a repellor. For the completecontrol law we use Fi(x, ~, s) E F.tt (zi, x j) jEAttract(i) + ~ F~,~(zi,zj)-bxi O) j E Repel(i where b > 0 is a damping parameter. In practice we assume a maximumactuator force, setting ui -max{u,naz,Fi (x, ~, s)}. Wehave built a simulation environmentfor the above systemand investigated a variety of initial conditions, with varying numbers of agents (from tens to hundreds), and various specifications of the desired assembly Gsp~c. Some simulations can be viewed at http://www.cs.caltech.edu/,-,klavins/rda/. Twodeadlocksituations arose in our initial simulations. First, F mayhave spurious stable equilibriums whichprevent attracting pairs from movingtowardeach other. Second, it is possiblethat the set of currently formedsubassemblies admitno joins in 9. Thatis, it maybe that at sometime there donot exist parts i andj suchthat Jt(si, sj) is true. To avoid these situations, we employa simple deadlock avoidance method. For each subassemblyGkE S we define a stale time stale(k) E R. Anysubassemblythat has not changedstate within stale(i) secondsof its formationtime should(1) breakapart, setting the state of eachpart in it (1, 1) and (2) haveeach part "ignore"other parts from sameassemblyfor stale(k) seconds. If kspe~is the index of G, vee in 9, we set stale(kspee) = ~¢. Theresult is a new controller Hd,i that checksfor staleness and implements(1) and (2) above, but is otherwisesimilar to Hi in Figure Wealso changethe definitions of Attract(i) and Repel(i). Supposethat Ignore(i) is the set of all part indices that part i is presently ignoringdue to a staleness break-up.Then Attractd(i) = Attract(i)Ignore(i) Repeld(i) = Repel(i) - Ignore(i). Fi is then changedaccordingly. Usingthis deadlockavoidante measure,we have not yet seen a set of initial conditions for any Gspecwe tried for which our simulation did not converge upon the maximum possible numberof parts playingroles in a final assembly,exceptwhenpartial assemblies were out of sensor range of parts neededto complete them. Average T~.me[sl 70 60 T All SubassembliesAllowed ~ n Subass~lies Allowed 50 40 30 20 0.1 0.2 0,3 0.4 0.5 0.6 Percent 0.7 Complete Figure 3: Comparisonof assemblytimes for Salt and GA~,I. Eachdampoint represents 50 simulations of 110parts. Analytical Figure 4: Timeto p-completionversus s(G) for each of the assembliesof size six, for p E {0.2, 0.6}. Eachdata point represents 100simulationsof 42 parts. Results In (Kiavins 2001) we describe a discrete modelof assembly, which includes the deadlock avoidence methoddescribed above, and showTheoremh Every run of the system resuits in a maximalnumberof parts being correctly assembled. The modelis, roughly, as follows: There are no continuous dynamics.Eachpan starts out in state (1, 1) with no neighbors. At each step, a compatiblepair (accordingto A) of subassembliesis chosenfromthe set of all subassemblies to be joined. If no such assemblyexists, the smallest non-final assemblyis brokenup into single-pan assemblies and the system proceeds. A lemmais then shownthat in each "epoch"of the system, the numberof subassembliesis reducedby at least one. Thetheoremis then Theorem1 Every sequence of the above discrete system ends with a maximumnumber of final assembles being formed. The proof is presented formally in (Klavins2001). Assembly Complexity and Performance It is informativeto considerthe time it takes until pmparts are in final assemblies(p E (0, 1]. Wecall this the time to p-completion.Figure 3 showsthe affect of the size of 9 on the time to p-completionfor different values ofp. Anotherfactor that affects performanceis the complexity of the specified tree Gspee, although wemust be careful about what we meanby this. Intuitively it seemsthat a straight line tree is less complexthan a tree with more branches. This is because of the wayassemblyoccurs in our system. A pan mayattracted to another but repelled (possibly) by its neighbors. Themoreneighborsthe latter part has, the more"difficult" it is for the formerpart to approach it. Thus, we comeup with a complexity measure~(G) of graphthat penalizes high branchingfactors therebydescribing how"crowded"it is likely to get during assembly.Let 43 i E V(G) and define d(i) = {j [ {i,j} E E(G)}. Set 7t K(G) ~ d(i)2" i=l Figure 4 showsthe time to p-completionversus it(G) for eachpossible assemblyof size six, for p E {0.2, 0.6}. Conclusion AlthoughTheoremI and simulations suggest that the implementation(particular choice of F/) combinedwith the deadlock avoidanceprocedureproducescontrollers that assemble a maximum numberof parts safely (without collisions), this mustbe verified analytically: A substantial problemrequiring possibly newtools in hybrid systemsanalysis. There are two reasons for considering only tree shaped assembliesoverarbitrary (planar) graphs. First, tree isomorphism(required at several steps in the synthesis procedure) is polynomialin the numberof vertices, whereasgraphisomorphismis (likely) exponential. Second,arbitrary graphs require certain embeddingsof their subassembliesin order to assemblethemselves. For example,suppose we assemble a graphby first assemblinga spanningtree of the graphand then "closing"it. If werequire the closing procedureto respect the d, br distance requirementswehave used, then the tree can not cross over itself while closing. This meansthe tree must assemble to an appropriate embeddingclass -- a constraint we cannotyet deal with, but plan to addresssoon. Besides exploring the complexityand performancemeasures we introduced analytically, manyvariations on the themepresented here should also be explored: hierarchical assemblywith intermediate goal assemblies, three dimensional assembly(whichhas fewer "closing" problemsthan in two dimensions), assembly of non-homogeneouspans, assembly of pans with complex dynamics (e.g. nonholonomic), and so on. Finally, we are exploring hardwareim- plementations of these algorithms so that the issues of asynchronous processing, inaccurate sensors and faulty communications maybe realistically addressed. References Bowden,N.; Choi, L. S., Grzybowski,B. A.: and Whitesides, G.M.1999. Mesoscaleself-assembly of hexagonal plates using lateral capillary forces: Synthesisusing the "capilary" bond. Journal of the AmericanChemicalSociety 121:5373-5391. Breen, T. L.; Tien, J.; Oliver, S. R. J.: Hadzic,T.; and Whitesides, G. M. 1999. Designand self-assemblyof open, regular, 3D mesostructures. Science 284:948-951. Klavins, E. 2001. Automaticallysynthesizedcontrollers for distributed assembly:Partial correctness. In CooperativeControl and Optimization. Presented at Conference.Submittedto Edited Volume. Klavins, E. 2002. Automaticsynthesis of controllers for distributed assemblyand formation forming. In Proceedingsof the IEEEConference on Robotics and Automation. To Appear. Reyner, S.W. 1977. An analysis of a good algorithm for the subtree problem. SIAMJournal on Computing6:730-732. 44