/* this is the code I mentioned in my previous e-mail */ macro diffStop diffEqn DiffStop { d(myPos.x)=0.0; d(myPos.y)=0.0;} macro updatePere 10.0 macro commPer 50.0 macro spd1 10.0 macro spd2 20.0 macro spd3 30.0 agent Robot (position initPos, real speed, estimate[] initEst) { input channel of estimate[] inLink1, inLink2; output channel of estimate[] outLink1, outLink2; extern estimate[] sense(position, obstacle[]); extern estimate[] comm(estimate[], estimate[]); extern real plan(position, position, estimate[]); mode main() { estimate[] myEst; position goal; real direction; diff analog position myPos; diff analog real timer; diffEqn diffTimer{d(timer) = 1;} /* initialization of controlled variables */ trans initTrans from main to communicate when true do { outLink1 = empty; outLink2 = empty; myEst[] = initEst[]; goal = /* initial value ? */ direction = /* initial value ? */ myPos = initPos; timer = 0.0; } mode stop() { diffStop inv invAtGoal {myPos == goal} } init mode communicate() { diffStop inv invMoreMessages{ !isEmpty(inLink1) || !isEmpty(inLink2) } init mode sending () { inv invMoreMessages } mode receiving () { inv invMoreMessages } trans sendToReceive from sending to receiveing when ( timer % commPer == 0 ) do{ send( outLink1, myEst[] ); send( outLink2, myEst[] ); } when ( timer % commPer != 0 ) do{} trans receiveToSend from sending to receiving when true do{ myEst[] = comm( myEst[], inLink1); myEst[] = comm( myEst[], inLink2); } trans receiveAgain from receiving to receiving when true do{ myEst[] = comm( myEst[], inLink1); myEst[] = comm( myEst[], inLink2); } } mode move() { diffEqn diffMove{ d(myPos.x) = speed*cos(direction); d(myPos.y) = speed*sin(direction); } inv invMoving{ timer % updatePer != 0 } } trans sensing from move to communicate when ( timer % updatePer == 0 && !(myPos == goal) ) do { myEst[] = sense(myPos, obstacles[]); } trans planning from communicate to move when ( isEmpty(inLink1) && isEmpty(inLink2) ) do { direction = plan(myPos, goal, myEst[]); } trans reached from move to stop when ( (timer % updatePer == 0) && (myPos == goal)) do{} trans stopToComm from stop to communicate when ( myPos != goal ) do{} } } Robot1 = Robot (iPos1, spd1, initEst1) [ inLink1, inLink2, outLink1, ouLink2 = r21Link1, r31Link2, r12Link1, r13Link2 ]; Robot2 = Robot (iPos2, spd2, initEst2) [ inLink1, inLink2, outLink1, ouLink2 = r12Link1, r32Link2, r21Link1, r23Link2 ]; Robot3 = Robot (iPos3, spd3, initEst3) [ inLink1, inLink2, outLink1, ouLink2 = r13Link1, r23Link2, r31Link1, r32Link2 ]; sys = Robot1 || Robot2 || Robot3