00001 /* 00002 00003 Copyright (c) 2011, Ascending Technologies GmbH 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions are met: 00008 00009 * Redistributions of source code must retain the above copyright notice, 00010 this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright 00012 notice, this list of conditions and the following disclaimer in the 00013 documentation and/or other materials provided with the distribution. 00014 00015 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 00016 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY 00019 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00021 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00022 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00023 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00024 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00025 DAMAGE. 00026 00027 */ 00028 00029 #define a 6378137.0 // earth semimajor axis in meters 00030 #define f 0.0033528106647474807198455286185206 // reciprocal flattening 00031 #define e2 2*f-f*f // eccentricity squared 00032 #define MEAN_EARTH_RADIUS 6378137.0 00033 #define MEAN_EARTH_DIAMETER 12756274.0 00034 #define UMR 0.017453292519943295769236907684886 //PI/180 00035 #define PI 3.1415926535897932384626433832795 00036 00037 00038 struct GPS_DATA 00039 { 00040 //latitude/longitude in deg * 10^7 00041 int latitude; 00042 int longitude; 00043 //GPS height in mm 00044 int height; 00045 //speed in x (E/W) and y(N/S) in mm/s 00046 int speed_x; 00047 int speed_y; 00048 //GPS heading in deg * 1000 00049 int heading; 00050 00051 //accuracy estimates in mm and mm/s 00052 unsigned int horizontal_accuracy; 00053 unsigned int vertical_accuracy; 00054 unsigned int speed_accuracy; 00055 00056 //number of satellite vehicles used in NAV solution 00057 unsigned int numSV; 00058 00059 // GPS status information; Bit7...Bit3: 0 Bit 2: longitude direction Bit1: latitude direction Bit 0: GPS lock 00060 int status; 00061 }; 00062 extern struct GPS_DATA GPS_Data; 00063 00064 struct GPS_TIME 00065 { 00066 unsigned int time_of_week; //[ms] 00067 unsigned short week; //[1..52] 00068 }; 00069 extern struct GPS_TIME GPS_Time; 00070 00071 00072 //trigger's new gps data transmission 00073 extern unsigned int gpsDataOkTrigger; 00074 extern void xy2latlon(double lat0, double lon0, double X, double Y, double *lat, double *lon); //X: East, Y: North in m; lat0,lon0: Reference coordinates; lat,lon: current GPS measurement 00075