Figure 1: GUI of WSNASG
Introduction
This tool is used as a scenario generator tool for the movement path of mobile Robot used for localization in WSNs. This tool has many capabilities such as:
- Animation of Wireless Sensor Network nodes (sensors, anchor)
- Deploying different number of sensor nodes
- Generating movement scenario file contains the coordinates of mobile robot (anchor) according to different static path planning mechanisms used for single anchor-assisted localization in WSNs. The generated scenario file can be used easily with your own simulation done by NS2. There are several static path planning mechanisms that can be simulated under this tool such as:
- SCAN
- DOUBLE_SCAN
- HILBERT
- CIRCLES
- S_CURVES
- SPIRAL
- LMAT
- Z_CURVE
- SQUARE_SPIRAL
- TGS
- Hexagon
- H_Curves
- Changing Size of deployment area, Resolution of trajectory model and Robot (anchor) mobility speed.
- Generating a text file contains (t, x, y) for the mobile robot. Where t is movement time and (x, y) is the coordinates of robot at second. This file can be used as input movement file for Arduino-based mobile robotics to control the mobility of Arduino robot according to different static path planning mechanisms.
- Generating an Excel file, used to draw the shape of the trajectory model according to different resolutions.
- Generating results of trajectory model such as: Area size, Number of horizontal R segments, Trajectory length and Simulation time. These results are generated on the GUI screen and written into external Excel file.
Background
As the number of Localization proposals increased, the classification of Localization models was expanded. Based on the nature of mobility, accordingly, localization schemes are grouped into four main categories. The first category (Static Node – Static Anchor), where both nodes and anchors are static. The second category (Mobile Node – Static Anchor) contains the schemes in which the mobility exists in nodes, not the anchors. This type usually includes applications where a sensor node is attached to a mobile body, such as an animal, and the static anchors provide each node with an updated location with each movement.
In the third category (Static Node – Mobile Anchor), the sensor nodes remain static at the time, while the MA is responsible for traversing the network and assisting these sensor nodes in localization to estimate their positions. This type of localization model is further subdivided into two categories: random mobility and planned mobility which is the main concern of the proposed GUI tool. The last category (Mobile Node – Mobile Anchor) includes scenarios where both sensor nodes and anchors are mobile.
The Problem and Its Solution
Most researchers working in the area of localization in WSNs most likely in single anchor-assisted localization, do their simulation based on NS-2 simulator. But they need to generate a scenario file that is responsible for the movement of mobile anchor/robot according to different static path planning mechanism. Thus, this tool can be used by them to do their own simulations under different trajectory models with varying most of the parameters needed for simulation based on NS-2. Beside this, this tool helps researchers to validate the generated path model by animator window used to visualize the movement of mobile Robot according to the chosen trajectory. Also helps them to go deeply into statistics about the chosen path model by generating most important results needed in NS-2 like initial position of Robot, Simulation time, Resolution and Area size.
Single Anchor Trajectory Models
The main difference between static mobility paths and other mobility types is that the motion path is set in advance and cannot be changed or modified after deployment, except some models which supports obstacles. Thus, most static path works are in some way based on triangulation or trilateration or multilateration techniques. However, proposing a static path requires giving more attention to the details of the mobile Robot points and the designed trajectory to avoid other problems, such as collinearity and path length.
The collinearity problem exists when an unknown location sensor node receives more message lies on the same straight line. Another issue is that since the static path planning methods depend highly on trilateration concepts, the designed static path should ensure that all sensor nodes can receive at least three different Robot locations so they can determine their own locations. Examples of static path planning mechanisms:
Figure 2: Static Path Planning Mechanisms
Using the Code
The example code below shows how to use a recursive method to generate Hexagon trajectory. Here, this method also generates trajectory points to an external Excel file used for modelling this path.
//Calling method
hexagon_level(n,ref x,ref y, R, s,ref t,ref ns2,ref op,ref draw, nn);
// Called method
static void hexagon_level(int n,ref double x, ref double y, int R,double s, ref double t,ref string ns2,ref string op,ref string draw, int nn)
{
if (n == 0) return;
hexagon_level(n - 1,ref x, ref y, R, s,ref t,ref ns2,ref op,ref draw, nn);
x -= R / 2; y += Math.Sqrt(3) * R / 2;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
}
t += R / s;
for (int i = 1; i <= n; i++)
{
x += R;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
} t += R / s;
}
for (int i = 1; i <= n; i++)
{
x += R / 2; y -= Math.Sqrt(3) * R / 2;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
} t += R / s;
}
for (int i = 1; i <= n; i++)
{
x -= R / 2; y -= Math.Sqrt(3) * R / 2;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
}
t += R / s;
}
for (int i = 1; i <= n; i++)
{
x -= R;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
}
t += R / s;
}
for (int i = 1; i <= n; i++)
{
x -= R / 2; y += Math.Sqrt(3) * R / 2;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
}
t += R / s;
}
for (int i = 1; i <= n; i++)
{
x += R / 2; y += Math.Sqrt(3) * R / 2;
ns2 += "$ns_ at " + t + ".0 \"$node_(" + (nn - 1) + ") setdest " + x + ".0 " + y + ".0 " + s + ".0\"" + "\n";
op += Math.Round(x) + ", " + Math.Round(y) + "\n";
draw = Math.Round(t) + " " + Math.Round(x) + " " + Math.Round(y);
using (FileStream fs = new FileStream(".\\Hexagon\\Hexagon_Draw.txt", FileMode.Append))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(draw);
}
}
t += R / s;
}
}
How to Work with WSNACG
WSNASG has the following capabilities:
- Generate movement scenarios
- Animation of generated scenarios
- Reading already generated scenarios
Figure 3: Steps for running LMAT trajectory
Figure 3 presents the steps of simulating LMAT trajectory model. The steps are as follows:
- Write number of horizontal segments.
- Write the resolution.
- Determine anchor mobility speed.
- Write total number of sensor nodes (Sensors + one anchor). Note, for example, if you write 10 sensors, i.e., there are nine sensors (ranges from 0 to 8 index) plus one anchor node. So that the index of anchor node in the scenario file (according to NS-2) will be 9. See the first two lines of the generated movement scenario file:
$ns_ at 0.0 "$node_(9) setdest 1.0 51.0 10.0"
$ns_ at 5.0 "$node_(9) setdest 51.0 51.0 10.0"
As shown, $node_(9)
is the mobile anchor (robot) node which has index.
- Select trajectory model (LMAT).
- Press Deploy WSN button.
- Press Start Simulation button.
Figure 4: Output Screen after 3 minutes of simulation
As shown in figure 4, number of horizontal segment is 10 R segment, Resolution = 52 m, Anchor mobility speed = 10 m/sec, Total number of nodes including one anchor = 10, trajectory model is “LMAT”. As shown in this figure, the position of anchor node is at point (203, 101) after 3 min of simulation. Trajectory model results are shown in the lower right corner which states the following statistics: Deployment area = 520 x 495 m^2, Total trajectory length = 6824 m and calculated simulation time = 682 sec. Note, the default initial position for anchor node is at point (1, 1) which needed in TCL file of NS-2 but there are trajectory models that differ according to the initial position of anchor node which starts from the middle of deployment area. So, the initial position for such models will be printed on the screen at the “Trajectory Model Results” section of GUI tool.
There are output text file that will be generated after pressing “Deploy WSN” button. These files are present in the following path: .\WSNASG\WSNASG\bin\Debug\LMAT. So according to the trajectory model you have chosen, the output text files will be present in folder named by the same name of this model. The related text files are as follows:
Figure 5: Movement Scenario File
This file is needed by NS-2 simulator in order to simulate the movement of mobile robot (anchor) according to LMAT trajectory model. The name of this file is “LMAT.txt”. The genarated file is called “LMAT.xls” which used to draw the trajectory on Excel file as shown below:
Figure 6: Generated .xls file
In order to read already generated scenario, select “Read Existing Scenario” radio button, then press “Deploy WSN” and press “Start Simulation” button. Hint, there are trajectory models that require selecting curve level instead of number of horizontal segments such as HILBERT, Z_Curve and Hexagon.
Conclusion
The design of the proposed WSNASG tool is focusing on object oriented architecture which allows researchers to adapt the tool, or extend it to different trajectory models. This tool has been developed in such a way so that it can support or work with different kinds of static path planning mechanisms. The proposed tool has the ability to generate different scenarios written into external files so as to allow researchers to use the same scenarios when comparing different trajectories.
History
- 13th November, 2019: Initial version