Skip to main content
. 2019 Mar 22;19(6):1414. doi: 10.3390/s19061414
Algorithm 1 ProLoAlg distributed localization and control algorithm.
  • 1:

    on node i:

  • 2:

    running ← true

  • 3:

    type MUWSN-Projection: {id, state, p{x,y}, pt1, pt2, neighbors }

  • 4:

    // projection on the beacon plane, p{x,y}: the coordinate vector

  • 5:

    //a sensor has 4 states: localized, flexible, rigid, localizable

  • 6:

    type neighbors[]:{id, state, d, p{x,y} }

  • 7:

    //d: distance between the neighbor and this node

  • 8:

    moveid=0 // moveid: the times of moving epochs

  • 9:

    while running do

  • 10:

     //first part: localization

  • 11:

     if this node is beacon then

  • 12:

      state ← localized

  • 13:

      set up the beacon plane with the other two beacons

  • 14:

     else

  • 15:

      while not receiving the beacon plane from beacons do

  • 16:

       wait

  • 17:

     while globally rigid graph is not constructed do

  • 18:

      //Use TE to construct the globally rigid graph on the beacon plane

  • 19:

      run TE and initialize ri.p by distance vectors.

  • 20:

      if no enough parents then

  • 21:

       start contracting

  • 22:

     risensorProjection //on this node i

  • 23:

     if ri.state is localizable then

  • 24:

      broadcast state and calculate the position

  • 25:

      candidates+= position() // use equations like Equations (6) and (7) to calculate new candidate positions

  • 26:

      if |candidates|>2 then

  • 27:

       ri.p vote(candidates) //choose one candidate as the correct position

  • 28:

       state ← localized

  • 29:

     // second part: moving control

  • 30:

     if MUWSN is localizing then

  • 31:

      wait

  • 32:

     beacon starts moving: moveid ← moveid+1

  • 33:

     if received moveid from neighbors and pi.moveid<moveid then

  • 34:

      pi.move(vi)

  • 35:

      pi.moveid=moveid

  • 36:

      state ← flexible

  • 37:

     if neighbor distance exceeds the threshold Td then

  • 38:

      start contracting

  • 39:

     if state == flexible then

  • 40:

      continue