Library tutorials & articles
Writing Your Own GPS Applications: Part 2
- Introduction
- Causes of Precision Error
- Determining Precision Needs
- Enforcing Precision
- High Precision in Action
High Precision in Action
High Precision in Action
Enforcing maximum DOP values is the easiest part of the whole programming process because enforcing precision is a matter of ignoring positional measurements above your maximum allowable DOP amount. This can be done in one “ if ” statement. To best demonstrate this, I've written a small application (the "Demo" linked at the start of this article) which uses the NMEA interpreter to enforce a maximum DOP of 6.
C#
public class HighPrecisionTest
{
private NmeaInterpreter MyInterpreter = new NmeaInterpreter();
private int MaximumDOPAllowed = 6;
private double CurrentHDOP;
public HighPrecisionTest()
{
// Bind events for dilution of position
MyInterpreter.HDOPReceived += new System.EventHandler(OnHDOPReceived);
MyInterpreter.PositionReceived += new System.EventHandler(OnPositionReceived);
}
public void Test()
{
// Parse satellite information (HDOP is 50.0)
MyInterpreter.Parse(
"$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05");
// Parse the current position
MyInterpreter.Parse(
"$GPRMC,225233.990,V,3939.4000,N,10506.4000,W,0.00,51.40,280804,,*35");
// Parse satellite information (HDOP is 1.2)
MyInterpreter.Parse(
"$GPGSA,A,3,11,29,07,08,19,28,26,,,,,,2.3,1.2,2.0*30");
// Parse the current position again
MyInterpreter.Parse(
"$GPRMC,012558.584,A,3939.7000,N,10506.7000,W,0.00,198.07,290804,,*11");
}
private void OnHDOPReceived(double value)
{
// Remember the current HDOP value
CurrentHDOP = value;
}
private void OnPositionReceived(string latitude, string longitude)
{
// Is the HDOP at least six?
if (CurrentHDOP <= MaximumDOPAllowed)
{
// Yes. Display the current position
Debug.WriteLine("You are here: " + latitude + ", " + longitude);
}
else
{
// No. Discard this positional measurement
Debug.WriteLine("The received location is not precise enough to use.");
}
}
}
VB.NET
Public Class HighPrecisionTest
Private WithEvents MyInterpreter As New NmeaInterpreter
Private MaximumDOPAllowed As Integer = 6
Private CurrentHDOP As Double
Public Sub Test()
' Parse satellite information (HDOP is 50.0)
MyInterpreter.Parse("$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05")
' Parse the current position
MyInterpreter.Parse("$GPRMC,225233.990,V,3939.4000,N," & _
"10506.4000,W,0.00,51.40,280804,,*35")
' Parse satellite information (HDOP is 1.2)
MyInterpreter.Parse("$GPGSA,A,3,11,29,07,08,19,28,26,,,,,,2.3,1.2,2.0*30")
' Parse the current position again
MyInterpreter.Parse("$GPRMC,012558.584,A,3939.7000,N," & _
"10506.7000,W,0.00,198.07,290804,,*11")
End Sub
Private Sub OnHDOPReceived(ByVal value As Double) _
Handles MyInterpreter.HDOPReceived
' Remember the current HDOP value
CurrentHDOP = value
End Sub
Private Sub OnPositionReceived(ByVal latitude As String, _
ByVal longitude As String) Handles MyInterpreter.PositionReceived
' Is the HDOP at least six?
If CurrentHDOP <= MaximumDOPAllowed Then
' Yes. Display the current position
Debug.WriteLine("You are here: " & latitude & ", " & longitude)
Else
' No. Discard this positional measurement
Debug.WriteLine("The received location is not precise enough to use.")
End If
End Sub
End Class
And that's it! Armed with a deep understanding of GPS precision and how to keep it tightly controlled, you can now develop location-based services suitable for the real world.
Conclusion
There are several ways to distort a GPS satellite signal. Some are corrected by the Department of Defense and others can be corrected in your GPS receiver using real-time ground station correction signals. The only precision problem which is left to you to control is Geometric Dilution of Precision. Controlling GDOP is the key to writing commercial-grade GPS applications. A small mathematical formula can be applied to determine the maximum allowable DOP for a particular application. The maximum allowable error should be the greatest possible value which minimizes accuracy problems while maximizing operational conditions.
Another factor which helps developers is time itself. Advances in GPS receiver technology are pushing precision to new levels. While precision can be questionable with any consumer GPS device, there will soon be a time when precision to a centimeter is possible. I believe that this level of precision will cause a revolution in industry and pave the way for some truly amazing things: automated construction machines, tracking for every shipping container in the world, traffic control systems that actively prevent traffic jams... and self-guiding golf balls.
(To be continued...)
[ Note : Please indicate your interest in part three by rating this article.]
Related articles
Related podcasts
-
More jQuery in ASP.NET
In this episode Chris Brandsma, Rick Strahl, Dave Ward, Bertrand Le Roy, and Scott Koon conclude their discussion of Microsoft's jQuery in ASP.NET announcement1.This episode of the Alt.NET Podcast is brought to you by LLBLGen Pro, the most mature O/R mapper and code generator out there.Are ...
Events coming up
-
Dec
9
GL.net Group Meeting - December 2009
Gloucester, United Kingdom
The beginning of this year holiday season will belong to mocks. Ronnie and Stephen will take us for a tour around exciting world of unit testing.
Hello,
I do not understand what you mean by writing your own GPS application, the most GPS receivers gives
navigation data in real time as UTC, Lat/Lon, SOG, TrueCourse, Magvar,Tracks,constellation sat.
What we can get more with this application ?
Best regards
Maritime
Great paper.
Thx very much.
GPS- Deriving British Ordnance Survey Grid Referece from NMEA data
AlexE
However this led to a new error as the final word in the string contained the checksum.
ie in the example sentence
$GPGSV, 3, 1, 10, 24, 82, 023, 40, 05, 62, 285, 32, 01, 62, 123, 00, 17, 59, 229, 28*70
the final word would be 28*70
this caused an error when trying to convert this to an int32 in the line
SignalToNoiseRatio = Convert.ToInt32(Words[Count * 4 + 3]);
My solution was to remove the checksum part of the sentence in GetWords, before splitting the sentence
public string[] GetWords(string sentence)
{
//remove the final * + checksum
sentence = sentence.Substring(0, sentence.IndexOf("*"));
//now split it up
return sentence.Split(',');
}
Assuming that I'm not talking out of my rear, I hope this proves useful
Alex
This update may help save many lives!
I love this product. Excellent Job on this product, Jon Person
your product 360%!... I just have to correct 1 minor error. I feel you should be aware or maybe your are already....don't know
might have been a typo,... I'm not much of a C# coder but, I believe during the ParseGPGSV() function, which is suppose to
parse the "Satellites in View" $GPGSV sentence.... If you look closesly. During the... public bool ParseGPGSV(string sentence)
Original Article: http://www.developerfusion.com/show/4652/4/
Example Sentence: $GPGSV, 3, 1, 10, 24, 82, 023, 40, 05, 62, 285, 32, 01, 62, 123, 00, 17, 59, 229, 28*70
Each Block consist of 4 words.. "24, 82, 023, 40" == "PseudoRandomCode, Elevation, Azimuth, SignalToNoiseRatio"
According to your Article... SNR values range from 0-50...where 50 means "Excellent Signal"...though SNR can go as high as 99,
like you've stated.
// Interprets a "Satellites in View" NMEA sentence -- section.
//ERROR suspect
Azimuth = Convert.ToInt32(Words[Count * 4 + 2]);
SignalToNoiseRatio = Convert.ToInt32(Words[Count * 4 + 2]);
// ^--- Logical Bug, I believe it should be ....
//CORRECTION
SignalToNoiseRatio = Convert.ToInt32(Words[Count * 4 + 3]);
// ^--- This would be correct.
Otherwise I believe it would return the same value from the Azimuth extraction. So you wouldn't get any SNR information to
be able to base precision correctly. For the future of dependability and reliability of code production, I post this correction. As
far as the Signal Strength of the satellites, within the Notification, of the Event call to,...
SatelliteReceived ( PseudoRandomCode, Azimuth, Elevation, SignalToNoiseRatio );
I believe it would generate incorrect results...to what ever is going to be done with the SNR variable.
Please feel free to e-mail me at deciphered_scripturez@yahoo.com for additional details...I really Thank you, Jon Person, for
your hard work and time put into this and I really would LOVE to help as much as possible...I believe in your product.
P.S. This update may save many lives! ... Can you imagine lets say for example, the next block of words over you had,
"05, 62, 285, 32" in the example above, lets say you passed the third Word of 285 as the value I know 99 would be the highest possible value, but imagine the reliability of the signal being factored in the calculation based on the strength for precision. I assume maybe this would throw off a calculation significantly.
Thank You,
-- cprogrammingguru
This thread is for discussions of Writing Your Own GPS Applications: Part 2.