How to calculate GPS positioning from NS/EW?

Thread Starter

camerart

Joined Feb 25, 2013
3,828
Hi,
A typical NMEA sentence: $GNRMC,060512.00,A,3150.788156,N,11711.922383,E,0.0,,311019,,,A,V*1B
shows NE and SW.
So far I've worked on just getting peripherals to work including the GPS, and where I live I get N and W, but for other parts of the world, how are positions calculated, especially if the GPS crosses any of the 'lines'?
Cheers, Camerart
 

WBahn

Joined Mar 31, 2012
32,702
Hi,
A typical NMEA sentence: $GNRMC,060512.00,A,3150.788156,N,11711.922383,E,0.0,,311019,,,A,V*1B
shows NE and SW.
So far I've worked on just getting peripherals to work including the GPS, and where I live I get N and W, but for other parts of the world, how are positions calculated, especially if the GPS crosses any of the 'lines'?
Cheers, Camerart
I don't know what you mean about that NMEA sentence showing NE and SW. It shows a location that is north latitude and east longitude.

Look at page 32 of the document Walter linked above.

I don't know what you mean by "crosses any of the 'line'". Do you mean things like the International Date Line? Those have NOTHING to do with the latitude and longitude of a point on the surface of the Earth.

If you are south of the equator, your latitude will have an 'S' instead of an 'N', Similarly, if you are east of the Principal Meridian, your longitude will have an 'E' instead of a 'W'.

Don't make it harder than it is.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
Hi Wn and WB,
I didn't fully explain.
I use UBLOX modules, which are similar to Quectel, so they output the same.

In my project, I will control a vehicle, using Joysticks, so 'say' it's aiming North just south of the equator, and I move the joystick forward, the GPS will change from S to N, and the calculation will need to change from counting down to the Equator, then up as it passes the line.
I hope you follow?
C
 

Ya’akov

Joined Jan 27, 2019
10,226
Hi,
A typical NMEA sentence: $GNRMC,060512.00,A,3150.788156,N,11711.922383,E,0.0,,311019,,,A,V*1B
shows NE and SW.
So far I've worked on just getting peripherals to work including the GPS, and where I live I get N and W, but for other parts of the world, how are positions calculated, especially if the GPS crosses any of the 'lines'?
Cheers, Camerart
I am not clear on your question. Are you asking how to convert a DDMM.MMMMMM fix to a D°M'S" fix? Or are you asking how to compare DDMM.M...N/S or E/W fixes to each other when they don't have matching positions relative to the prime meridian and/or equator?

If the latter, are you calculating distance, bearing, something else?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
I am not clear on your question. Are you asking how to convert a DDMM.MMMMMM fix to a D°M'S" fix? Or are you asking how to compare DDMM.M...N/S or E/W fixes to each other when they don't have matching positions relative to the prime meridian and/or equator?

If the latter, are you calculating distance, bearing, something else?
Hi Y,
I live North of the Equator and West of Greenwich, and in my project I parse an NMEA sentence $ to W which includes all of what I need. But it's been pointed out to me, that this won't work in all other global locations, so I'm looking into it.

What I am doing in the project, is sending a location to the 'remote', so if it was at 0 Lat and 0 Lon, and I want to send a distance move 1 'step' North, as I push one of the joysticks forward, 0.0, would now be 1,0, and the 'remote' should move to 1,0, so 1 'step' North.

The NMEA sentence outputs Deg,Min,Sec then 'say' N, so I imagine that, IF N then ADD or IF S then SUBTRACT. Can it stay as Deg,Min,Sec, or does it have to be changed to all SECs?
I'm looking at the GPS programming and there may be an output that looks like this 7654321 and -7654321 for 'say' Lat, but I haven't got this to work yet.

What is the best approach?
C
 

WBahn

Joined Mar 31, 2012
32,702
Hi Wn and WB,
I didn't fully explain.
I use UBLOX modules, which are similar to Quectel, so they output the same.

In my project, I will control a vehicle, using Joysticks, so 'say' it's aiming North just south of the equator, and I move the joystick forward, the GPS will change from S to N, and the calculation will need to change from counting down to the Equator, then up as it passes the line.
I hope you follow?
C
A simple approach is to just convert the lat/lon readings into a coordinate system that is more convenient for your application. Converting to spherical is trivial (though there is an assumption that the GPS coordinates are lat/lon on a sphere, which they aren't. But the difference should be negligible for most applications.
 

WBahn

Joined Mar 31, 2012
32,702
Hi Y,
I live North of the Equator and West of Greenwich, and in my project I parse an NMEA sentence $ to W which includes all of what I need. But it's been pointed out to me, that this won't work in all other global locations, so I'm looking into it.

What I am doing in the project, is sending a location to the 'remote', so if it was at 0 Lat and 0 Lon, and I want to send a distance move 1 'step' North, as I push one of the joysticks forward, 0.0, would now be 1,0, and the 'remote' should move to 1,0, so 1 'step' North.

The NMEA sentence outputs Deg,Min,Sec then 'say' N, so I imagine that, IF N then ADD or IF S then SUBTRACT. Can it stay as Deg,Min,Sec, or does it have to be changed to all SECs?
I'm looking at the GPS programming and there may be an output that looks like this 7654321 and -7654321 for 'say' Lat, but I haven't got this to work yet.

What is the best approach?
C
NMEA does not output Def,Min,Sec. It outputs in the format DDMM.MMMMMM for lat and DDMM.MMMMMM for lon. The first digits are the degrees and the rest is fractional minutes.

What is 1 'step'? Is it one foot? One meter? One nautical mile? One minute?

You need to be specific, because the relation of one 'step' is going to change for different places on the Earth - a change of one minute of longitude at the equator is a greater distance than it is at the Arctic Circle, for instance.
 

Papabravo

Joined Feb 24, 2006
22,058
You might greatly benefit from the knowledge of spherical trigonometry. They used to teach it, but seldom do any more. It is not outside the realm of possibility for you to acquire these skills on your own, in order to facilitate your interest in navigation. I know it will be a challenge, but the potential payoff is considerable.

A simple example would be computing the great circle distance between two points given their coordinates. From there you proceed to computing the great circle path between two points. It is a tedious calculation by hand, but that is what computers are for.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
Hi W and P,
For what I want this doesn't need spherical trigonometry, as I'm only talking about short distances.

Yes, DDMM, and fractions, I'd forgotten.

1 step is the shortest distance this system will move.

I am looking for the simplest way to calculate the movement for a PIC microcontroller, taking into consideration NS and EW? Trigonometry will be used for later calculations.
C.

C
 

WBahn

Joined Mar 31, 2012
32,702
Hi W and P,
For what I want this doesn't need spherical trigonometry, as I'm only talking about short distances.

Yes, DDMM, and fractions, I'd forgotten.

1 step is the shortest distance this system will move.

I am looking for the simplest way to calculate the movement for a PIC microcontroller, taking into consideration NS and EW? Trigonometry will be used for later calculations.
C.

C
How will you know if it moved the right amount if you can't translate between "steps" and differences in lat/lon?

You can work with a plane approximation about the lat/lon that is reported, but the scaling factors on that plane come from the spherical coordinate system you are given.

Taking N/S into account is trivial -- N values are positive and S values are negative.

Dealing with E/W is almost as simple, but there is one gotcha. E values are positive and W values are negative. But if the values are near 180°, then there is a step-discontinuity in your coordinates. This can be handled in a number of ways, depending on what you are doing with the coordinates. In many cases you can just do the math, then check the result and normalize it, if needed.
 

Papabravo

Joined Feb 24, 2006
22,058
Hi W and P,
For what I want this doesn't need spherical trigonometry, as I'm only talking about short distances.

Yes, DDMM, and fractions, I'd forgotten.

1 step is the shortest distance this system will move.

I am looking for the simplest way to calculate the movement for a PIC microcontroller, taking into consideration NS and EW? Trigonometry will be used for later calculations.
C.

C
Well, if you already know all the answers, what is missing? A calculation is a calculation. Either you can do it or you can't. Maybe a PIC microcontroller does not have the capabilities you might like.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
Hi,
I'll see if I can figure it out. I'll have to try different ideas, and see what happens.
Thanks.
C.
 

Papabravo

Joined Feb 24, 2006
22,058
It occurred to me that you might be asking about how to do various computations on a PIC processor. The only thing that comes to mind besides doing multiplication and division is computing the values of elementary functions. Things like sine and cosine and square root. Is that what you are asking about?
 

ericgibbs

Joined Jan 29, 2010
21,390
Hi C,
Is this an example of the type of GPS message you are parsing.?

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47

This is a demo program I did for you in 2014. :)

E
Clips
Hserout 'local is needles light house, CrLf, CrLf"
'these values will be keypad input
latrad1 = 50.662341 / 57.295779
lonrad1 = 1.591347 / 57.295779
latcos1 = Cos(50.662341)

local portchester church
'$GPGGA,123519,5050.198,N,00106.769,W,1,08,0.9,123.4,M,46.9,M,,*47?

'dummy test messages quadrants 1,2,3,4
'portland bill
'$GPGGA,000001,5032.474,N,00226.474,W,1,08,0.9,123.1,M,46.9,M,,*47
'$GPGGA,000002,5100.000,N,0000.000,W,1,08,0.9,123.2,M,46.9,M,,*47
'$GPGGA,000003,4930.000,N,00300.000,W,1,08,0.9,123.3,M,46.9,M,,*47
'$GPGGA,000004,5030.000,N,00300.000,W,1,08,0.9,123.4,M,46.9,M,,*47
 

Attachments

Last edited:

WBahn

Joined Mar 31, 2012
32,702
Hi C,
Is this an example of the type of GPS message you are parsing.?

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
He says that he is using the $--RMC messages, not $--GGA messages. The lat/lon info is the same in both, but I'm concerned that dealing with a different message format may be confusing.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
Hi P, E and W,

Yes, I'm programming a PIC (I'n Oshonsoft BASIC)

I've been using the #15 example since 2014 (Still trying ;) ), where I later changed to $GNRMC (I forget why) and parsing out the relevant elements (LAT,LON ETC), thanks.

I'm soon going to be using these elements, to control the REMOTE so I need these calculations.
I have to decide which is the best way to do this, so what i'm thinking is quite complicated, and needs to be unravelled bit by bit, hence the minimum question in #1

I've just been introduced to this [ ECEF ]:
Which is not an NMEA sentence, and has negative numbers, for 'say' W. These are in Mtrs. I haven't got this working yet.
So I wanted to whether to stick with NMEA or keep trying ECEF, depending on the replies I get.

In the NMEA example, moving the CH2 (MODE 2) joystick forward would increment LAT.
$GNRMC,060512.00,A,3150.788156,N,11711.922383,E,0.0,,311019,,,A,V*1B
Would be:
$GNRMC,060512.00,A,3150.788157,N,11711.922383,E,0.0,,311019,,,A,V*1B
So: the REMOTE should start to move N, until it arrived at:
$GNRMC,060512.00,A,3150.78815
7,N,11711.922383,E,0.0,,311019,,,A,V*1B
If this movement isn't enough, then move the joystick more forward so there's a bigger difference.

What I'm trying to work out is is the NMEA method with NS better or is ECEF with +- better. and does it all need to be common deneonimators e,g, SECONDS?
C.
 

Attachments

WBahn

Joined Mar 31, 2012
32,702
What are are saying amount to wanting the remote to move a different amount, for the same joystick movement, at different places on the Earth.

Is that really the behavior you want to have?

What if the remote is facing northwest. Do you still want a forward motion of the joystick to move it due north? Or to move forward?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,828
What are are saying amount to wanting the remote to move a different amount, for the same joystick movement, at different places on the Earth.

Is that really the behavior you want to have?

What if the remote is facing northwest. Do you still want a forward motion of the joystick to move it due north? Or to move forward?
Hi W,
I'm working on a project that does just that! It sends a location to the REMOTE, and the remote should move to that location.

I gave the simplest example of aiming N and moving N, but it will move in all directions and altitudes.

I think the many return questions tell me that I ought to use the NSEW, that is in the NMEA sentences and not keep trying to get ECEF to work.
So as before, I think I have to do some tests with NSEW, and see what results.
Thanks.
C.
 

WBahn

Joined Mar 31, 2012
32,702
So you DO want it to move DIFFERENT distances for the SAME joystick input, depending on where it happens to be on the Earth?

How are you going to get the altitude information? That's not contained in a $--RMC message.
 
Top