|
Algorithm 1 ProLoAlg distributed localization and control algorithm. |
-
1:
on node i:
-
2:
running ← true
-
3:
type MUWSN-Projection: {id, state, , pt1, pt2, neighbors }
-
4:
// projection on the beacon plane, : the coordinate vector
-
5:
//a sensor has 4 states: localized, flexible, rigid, localizable
-
6:
type neighbors[]:{id, state, d, }
-
7:
//d: distance between the neighbor and this node
-
8:
// 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 by distance vectors.
-
20:
if no enough parents then
-
21:
start contracting
-
22:
//on this node i
-
23:
if
.state is localizable then
-
24:
broadcast state and calculate the position
-
25:
position() // use equations like Equations (6) and (7) to calculate new candidate positions
-
26:
if
then
-
27:
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 from neighbors and
then
-
34:
.move()
-
35:
-
36:
state ← flexible
-
37:
if neighbor distance exceeds the threshold
then
-
38:
start contracting
-
39:
if state == flexible then
-
40:
continue
|