Section 24.4 GPS Receiver and Sentence Explanation
The GPS constellation of satellites orbiting planet Earth are around 26 satellites. Typically there are about 13 satellites above you from horizon to horizon. However, with cloud cover and buildings and trees you can typically only receive data from about 7 of them. You need at least 3 but 4 is preferred to get a GPS lock. If you go outside on a clear data and wait your data will return coordinates for your current position. Latitude is your degree value above or below the equator, longitude is your degree value east or west of the prime meridian and then altitude is your height above sea level. Note that if you’re code is printing raw NMEA sentences, you may get something like this
$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47This is the raw NMEA sentence output by the GPS. The code in the example folder parses this data to get the latitude, longitude, altitude and speed. The NMEA sentence is a command that contains all the GPS data. The first part is the type of sentence (GPGGA in this case) and then the rest of the data is separated by commas. The format is type of sentence, time, latitude, N/S, longitude, E/W, fix quality, number of satellites, horizontal dilution of position, altitude, M (meters), height of geoid above WGS84 ellipsoid, M (meters), time since last DGPS update, DGPS reference station id, checksum. The code in either Arduino (Adafruit_GPS) or CPX/CPB (adafruit_gps) parses this data to get the latitude, longitude, altitude and speed. The code then prints this data in a more readable format. The code also converts the latitude and longitude from the NMEA format to decimal degrees which is easier to work with. Again, once you go outside and get a lock from more than 3 satellites, the latitude and longitude values will be replaced with your actual coordinates and speed. It’s possible to convert GPS position to X and Y coordinate provided you use the first GPS coordinate as the origin. The equations to convert GPS coordinates to position are shown below.
\begin{equation}
x = R cos(\lambda)(\phi - \phi_0) \tag{24.4.1}
\end{equation}
\begin{equation*}
y = R (\lambda - \lambda_0)
\end{equation*}
where \(R\) is the radius of the Earth, \(\phi\) is the longitude, \(\lambda\) is the latitude and \(\lambda_0\) and \(\phi_0\) are the latitude and longitude of the origin point. In this case the x-axis is East-West and the y-axis is North-South. Once you have position you can take the derivative to get velocity typically doing a heavily filtered moving average derivative to get a smooth velocity plot. To start though a simple first order derivative will at least get you started.
\begin{equation}
v_x = \frac{x_{i+1}-x_i}{t_{i+1}-t_i} \tag{24.4.2}
\end{equation}
\begin{equation*}
v_y = \frac{y_{i+1}-y_i}{t_{i+1}-t_i}
\end{equation*}
