Java Mobile Simulator.

Best Viewed 800*600

Introduction

This website was developed to allow for the viewing of a Java Applet and in order to view the applet you must have a Java enabled browser. Should your browser not be Java enabled the plugin is available from the Sun Microsystems website and at the time of writing is available here. The Java applet was written to allow for the simulation of tracking a mobile node. The mobile node could be something like a mobile phone or a tracking device fitted to an individual or a vehicle. The simulation was written to take into account a 2D environment as opposed to a 3D environment and as such is reflected in the way distances are calculated.

Distance Measurement

The GPS system consists of 24 satellites of which on earth at least four are visible at any one point in time. The GPS receiver must locate these satellites and calculate its distance from each of the located satellites to estimate its own position.

Distance can be measured by:

Distance = Signals Travel Time * The Speed of Light

In order to measure this distance both the satellite and receiver must be synchronised to within a nanosecond. This is achieved by placing expensive atomic clocks on the satellites and a cheaper quartz clock on the receivers. The receiver can then reset its clock by gauging its inaccuracy based on the satellites. In this report it is made by assumption that the mobile and field nodes are perfectly locked. The distance measured between our mobile node and field nodes cannot use the signal travel time or the speed of light to estimate the distance therefore these will be calculated using Pythagoras' theory, which states:

Radius * Radius = X*X+Y*Y

Each node will calculate the distance between its self and the mobile node.

Xmobile = Known mobile X position

Ymobile = Known mobile Y position

X = Xmobile − field node known X position;

Y = Ymobile − field node known Y position;

Distance * Distance = X * X + Y * Y

Distance = Square Root of Distance.

Errors occur in the measurement on a GPS system due to the way electromagnetic energy travels through the atmosphere. This delay can vary dependant on your location and can thus introduce distance measurement errors. Our system is using a random error with a maximum error of 5%. The distance and error is contained in the Node.java file.

Trilateration

The GPS receiver uses trilateration in order to estimate its position. The Monitor.java is the heart of this operation in the mobile simulation and creates the central monitoring node, which allows for the values of the field nodes to be passed in.

A summary of the method is shown below:

public void getNodePosition(Node NodeA, Node NodeB, Node NodeC, Node NodeD){

xvals [0] = NodeA.getx() ;

yvals [0] = NodeA.gety() ;

radvals [0] = NodeA.getRadius() ;

calcMobileXY();

}

The getNodePosition() method uses the Nodes getter methods to retrieve the nodes X, Y and radius values and stores them into an array. This is repeated for all nodes. Once these values are stored the calcMobileXY() method is called.

The calcMobileXY() method initiates a for loop and creates a random number.

public void calcMobileXY(){

for( int i = 0; i < 1000; i++ ) {

int randNumber = (int)(Math.random() * 99D) + 1;

If the random number generated is greater than 50 then randomly perturb the estimated X position. This is done by adding a random value delX to the estimated X value. This creates the estimated new X value (enewX).

if (randNumber > 50)

{

float delX = RandomNumber();

float enewX = estX + delX;

A new method called error() is called in which the old estimated X and Y values are passed. A second set of values is also sent which passes the enewX and the old estimated Y value.

float eold = error(estX, estY);

float enew = error(enewX, estY);

When the error values are returned if the new estimated X error is smaller than the old then set the estimated X position to the new value.

if (enew < eold)

{

estX = enewX;

}

If the random number generated is less than 50 the same procedure is carried out for the Y values.

The error method uses Pythagoras theory again. The method accepts two float values which are the estimated X and Y positions of the mobile passed in from the calcMobileXY() method.

public float error(float estMx1,float estMy1){

A for loop is initiated which is set to the length of the number of nodes passed in to the xvals array.

for (int i=0; i<xvals.length; i++){

Inside the “for” loop the estimated radius (distance) is generated for the estimated mobile X, Y values. This subtracts the known X and Y field node positions from the estimated mobile.

float estimateRadius = (estMx1 - xvals[i]) * (estMx1 - xvals[i]);

estimateRadius = estimateRadius +((estMy1 - yvals[i]) * (estMy1 - yvals[i]));

The known radius for each field node is generated from the known radius values passed in and set in the getNodePosition() method.

float knownRadius = (radvals[i] * radvals[i]);

The error can then be calculated by subtracting the known radius from the estimated radius. This gives an overall error for all nodes.

calcError = calcError+((estimateRadius-knownRadius)*(estimateRadius-knownRadius));

Finally the error value is returned to the calcMobileXY() method.

return calcError;

The smaller the error the closer the estimated X and Y positions will be to the actual X, Y position.   

Paul Guy copyright © 2005. For information on this site please contact the webmaster. It is valid XHTML 1.1 and CSS 2.0.