Eigen
Dependencies: Vector3
Dependents: optWingforHAPS_Eigen hexaTest_Eigen
GPSUBX_UART.hpp
- Committer:
- cocorlow
- Date:
- 2021-09-17
- Revision:
- 1:71f5168e48c8
- Parent:
- 0:cf7c726ec8a1
- Child:
- 2:6218fe8e54f4
File content as of revision 1:71f5168e48c8:
#ifndef __GPSUBX_UART_HPP__ #define __GPSUBX_UART_HPP__ #include "mbed.h" #include "Vector3.hpp" #define POSECEF_LEN 20 #define POSLLH_LEN 28 #define TIMEUTC_LEN 20 #define VELECEF_LEN 20 #define VELNED_LEN 36 #define UBX_SYNC 0x62 << 8 | 0xb5 #define RECEIVE_SIZE 1024 #define SENTENCE_SIZE 64 extern Serial pc; //// 0x01 0x01 //union POSECEF //{ // char byte_data[POSECEF_LEN+8]; // struct // { // unsigned short sync; // char m_class; // char m_id; // unsigned short pay_len; // unsigned int iTOW; // int ecefX; // int ecefY; // int ecefZ; // unsigned int pAcc; // char check_a; // char check_b; // } data; //}; // 0x01 0x02 union POSLLH { char byte_data[POSLLH_LEN]; struct { unsigned int iTOW; int lon; int lat; int height; int hMSL; unsigned int hAcc; unsigned int vAcc; } data; }; // 0x01 0x21 union TIMEUTC { char byte_data[TIMEUTC_LEN]; struct { unsigned int iTOW; unsigned int tAcc; int nano; unsigned short year; unsigned char month; unsigned char day; unsigned char hour; unsigned char min; unsigned char sec; unsigned char valid; } data; }; //// 0x01 0x11 //union VELECEF //{ // char byte_data[VELECEF_LEN]; // struct // { // unsigned int iTOW; // int ecefVX; // int ecefVY; // int ecefVZ; // unsigned int sAcc; // } data; //}; // 0x01 0x12 union VELNED { char byte_data[VELNED_LEN]; struct { unsigned int iTOW; int velN; int velE; int velD; unsigned int speed; unsigned int gSpeed; signed int heading; unsigned int sAcc; unsigned int cAcc; } data; }; class GPSUBX_UART { private: RawSerial serial; char receive_buffer[RECEIVE_SIZE]; char sentence_buffer[SENTENCE_SIZE]; static const float Radius = 6378136.6f; void Receive(); void Decode(char buffer[], int mc, int mi); public: int Year; int Month; int Day; int Hours; int Minutes; int Seconds; float Latitude; float Longitude; float Height; int iTOW_POSLLH; Vector3 VelocityNED; float Speed; float GroundSpeed; float Heading; int iTOW_VELNED; int TimeZone; volatile int receive_index; Vector3 UniversalZeroPosition; Vector3 UniversalZeroUnitN; Vector3 UniversalZeroUnitE; Vector3 UniversalZeroUnitD; Vector3 UniversalPosition; Vector3 PositionNED; GPSUBX_UART(PinName tx, PinName rx, int baud = 38400, int timezone = 9); void Update(); void Attach(); // Position Calculation Vector3 ToUniversalUnit(); Vector3 ToUniversal(); void CalculateUnit(); void Calculate(); Vector3 Calculate(Vector3 position); static void Checksum(char payload[], int n, char* ck_a, char* ck_b); }; #endif