Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef AP_GPS_UBLOX_h
00012 #define AP_GPS_UBLOX_h
00013
00014 #include <GPS.h>
00015
00016 #define UBLOX_SET_BINARY "$PUBX,41,1,0003,0001,38400,0*26"
00017
00018 class AP_GPS_UBLOX : public GPS
00019 {
00020 public:
00021
00022 AP_GPS_UBLOX(Stream *s);
00023 virtual void init();
00024 virtual bool read();
00025
00026 private:
00027
00028 #pragma pack(1)
00029 struct ubx_nav_posllh {
00030 uint32_t time;
00031 int32_t longitude;
00032 int32_t latitude;
00033 int32_t altitude_ellipsoid;
00034 int32_t altitude_msl;
00035 uint32_t horizontal_accuracy;
00036 uint32_t vertical_accuracy;
00037 };
00038 struct ubx_nav_status {
00039 uint32_t time;
00040 uint8_t fix_type;
00041 uint8_t fix_status;
00042 uint8_t differential_status;
00043 uint8_t res;
00044 uint32_t time_to_first_fix;
00045 uint32_t uptime;
00046 };
00047 struct ubx_nav_solution {
00048 uint32_t time;
00049 int32_t time_nsec;
00050 int16_t week;
00051 uint8_t fix_type;
00052 uint8_t fix_status;
00053 int32_t ecef_x;
00054 int32_t ecef_y;
00055 int32_t ecef_z;
00056 uint32_t position_accuracy_3d;
00057 int32_t ecef_x_velocity;
00058 int32_t ecef_y_velocity;
00059 int32_t ecef_z_velocity;
00060 uint32_t speed_accuracy;
00061 uint16_t position_DOP;
00062 uint8_t res;
00063 uint8_t satellites;
00064 uint32_t res2;
00065 };
00066 struct ubx_nav_velned {
00067 uint32_t time;
00068 int32_t ned_north;
00069 int32_t ned_east;
00070 int32_t ned_down;
00071 uint32_t speed_3d;
00072 uint32_t speed_2d;
00073 int32_t heading_2d;
00074 uint32_t speed_accuracy;
00075 uint32_t heading_accuracy;
00076 };
00077 #pragma pack(pop)
00078 enum ubs_protocol_bytes {
00079 PREAMBLE1 = 0xb5,
00080 PREAMBLE2 = 0x62,
00081 CLASS_NAV = 0x1,
00082 MSG_POSLLH = 0x2,
00083 MSG_STATUS = 0x3,
00084 MSG_SOL = 0x6,
00085 MSG_VELNED = 0x12
00086 };
00087 enum ubs_nav_fix_type {
00088 FIX_NONE = 0,
00089 FIX_DEAD_RECKONING = 1,
00090 FIX_2D = 2,
00091 FIX_3D = 3,
00092 FIX_GPS_DEAD_RECKONING = 4,
00093 FIX_TIME = 5
00094 };
00095 enum ubx_nav_status_bits {
00096 NAV_STATUS_FIX_VALID = 1
00097 };
00098
00099
00100 uint8_t _ck_a;
00101 uint8_t _ck_b;
00102
00103
00104 uint8_t _step;
00105 uint8_t _msg_id;
00106 bool _gather;
00107 uint16_t _expect;
00108 uint16_t _payload_length;
00109 uint16_t _payload_counter;
00110
00111
00112 union {
00113 ubx_nav_posllh posllh;
00114 ubx_nav_status status;
00115 ubx_nav_solution solution;
00116 ubx_nav_velned velned;
00117 uint8_t bytes[];
00118 } _buffer;
00119
00120
00121 bool _parse_gps();
00122 };
00123
00124 #endif