00001 #ifndef GPS_h_GAURD_123412341
00002 #define GPS_h_GAURD_123412341
00003
00004 #include <math.h>
00005
00016 class GPS {
00017 public:
00018 enum {Static=1, Quasi_Static=2, Walking=3, Ship=4, Automobile=5, Aircraft=6};
00019
00020
00022
00023
00024 GPS(const char* serial, int noWait=1);
00025
00027
00028
00029
00030 GPS(void);
00031
00033
00034
00035
00036
00037
00038 int init(float period=5.0, int dynamicMode=Quasi_Static);
00039
00041
00042
00043 int Read(void);
00044
00046
00047
00048
00049
00051
00052
00053 inline int hasPositions(void) {return has_positions;}
00054 inline double xPos(void) {return x;}
00055 inline double yPos(void) {return y;}
00056 inline double zPos(void) {return z;}
00058
00059
00060 inline int hasVelocities(void) {return has_velocities;}
00061 inline double xVel(void) {return xvel;}
00062 inline double yVel(void) {return yvel;}
00063 inline double zVel(void) {return zvel;}
00065 inline double pDOP(void) {return pdop;}
00066 inline double hDOP(void) {return hdop;}
00067 inline double vDOP(void) {return vdop;}
00068 inline double tDOP(void) {return tdop;}
00070
00071 inline int getNumSat(void) {return numsat;}
00073 inline double getLatitude(void) {return latitude;}
00074 inline double getLongitude(void) {return longitude;}
00076
00077
00078 inline const char* getMsg(void) {return msgbuf;}
00079 inline int getFD(void) {return gps_fd;}
00081
00082 int dispatchMsg(const char *msg);
00083 int parsePOS(const char *msg);
00084 int parseUTM(const char *msg);
00085
00086
00087 void printData(void);
00088
00089
00090
00092
00094
00095 private:
00096 void initVars(void);
00097
00098 protected:
00099 char msgbuf[200];
00100 int msglen;
00101 int gps_fd;
00102 int reading;
00103 int using_file;
00104
00105
00106 int numsat;
00107 char NorS, EorW;
00108 double latitude, longitude, altitude;
00109 double x,y,z;
00110 double hVelocity, vVelocity, direction;
00111 double xvel, yvel, zvel;
00112 double pdop, hdop, vdop, tdop;
00113
00114
00115 int is_corrected;
00116 int has_positions, has_velocities;
00117 int nowait;
00118
00119 static const double minutes2radians = (M_PI / 180.0 / 60.0);
00120 static const double degrees2radians = (M_PI / 180.0f);
00121 static const double knots2mps = 0.5144444;
00122 static double invalid;;
00123 static const double earthRadius = 6378137.0f;
00124
00125 static const double zeroLatitude = 0.700076f;
00126 static const double zeroLongitude = 1.53984f;
00127
00128
00129 int readLine(void);
00130 int writeLine(const char* msg);
00131 int checkAck(void);
00132
00133 inline float cos(float f) {return ::cosf(f);}
00134 inline double cos(double f) {return ::cos(f);}
00135 inline float sin(float f) {return ::sinf(f);}
00136 inline double sin(double f) {return ::sin(f);}
00137
00138 public:
00139 ~GPS();
00140
00141 };
00142
00143
00144 #endif