A GPS serial interrupt service routine that has an on the fly nmea parser. Works with a STM32F411RE and a Adafruit GPS logger.

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of GPS by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nav.h Source File

nav.h

00001 /*
00002     File:       nav.h
00003     Version:    0.1.0
00004     Date:       Feb. 28, 2017
00005     License:    GPL v2
00006     
00007     Navigation class
00008     
00009     ****************************************************************************
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023     ****************************************************************************
00024  */
00025 class NAV {
00026     #define PI  3.14159265358979f
00027     #define point_proximity_radius 10
00028     #define NMEA_EARTH_FLATTENING       (1 / 298.257223563)             /**< Earth's flattening according WGS 84 */
00029     #define NMEA_EARTH_SEMIMAJORAXIS_M  (6378137.0)                     /**< Earth's semi-major axis in m according WGS84 */
00030     #define NMEA_EARTH_SEMIMAJORAXIS_KM (NMEA_EARTH_SEMIMAJORAXIS_M / 1000) /**< Earth's semi-major axis in km according WGS 84 */
00031 
00032 
00033     private:
00034     // Convert Degrees to Radians
00035     double DegreeToRadian(double angle);
00036     // Convert Radians to Degrees
00037     double RadianToDegree(double angle);
00038     
00039     public:
00040     // Calculate the heading
00041     double CalculateDistance (double latitude1, double longitude1, double latitude2, double longitude2);
00042     // Calculate bearing
00043     double CalculateBearing(double latitude1, double longitude1, double latitude2, double longitude2);
00044     /*
00045         This function takes as input the next gps coordinate that the boat is suppossed to achieve and calculates the compass
00046         heading to the waypoint
00047         Jeff Witten - 05/26/14 from Github VT-SailBOT/Navigation sailbot.c
00048     */
00049     int direction_to_next_point (double latitude, double longitude, double next_latitude, double next_longitude);
00050     /*
00051         This function takes as input the gps coordinates of the boat and the gps coordinates of a waypoint that the boat desires to approach
00052         The function then sets a flag based on whether or not the boat is within a predetermined perimeter of the waypoint
00053         Approach:
00054         1.) Latitude and Longitude of San Francisco = 37.7844 N, 122.4167 W
00055         2.) At 40 degrees North: 1 degree latitude = 111.03 km, 1 degree longitude = 85.39 km
00056         3.) 111.03 = 85.39 * (1.30027) - used to correct approximately rectangular lat/lon grid to approximately square
00057         4.) Through unit analysis, 1 meter = 0.0000111509 degrees longitude 
00058         Jeff Witten - 03/27/14 from Github VT-SailBOT/Navigation sailbot.c
00059         */
00060     int point_proximity(double boat_latitude, double boat_longitude, double next_latitude, double next_longitude);
00061     
00062     double distance_ellipsoid(double from_lat,  double from_lon, double from_azimuth, double to_lat, double to_lon, double to_azimuth);
00063     
00064     int distance;
00065     
00066    };