navdata.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: navdata.h
  5. *
  6. * Description: Navdata head file
  7. *
  8. * Version: 1.0
  9. * Created: 2018/8/15 17:22:18
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: Jarod Lee
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #ifndef __NAV_DATA_H
  19. #define __NAV_DATA_H
  20. #include <stdbool.h>
  21. #define MAX_SVID 300
  22. enum {
  23. CONSTELL_TYPE_UNKNOWN = 0,
  24. CONSTELL_TYPE_GPS,
  25. CONSTELL_TYPE_GLN,
  26. CONSTELL_TYPE_BDS,
  27. MAX_CONSTELL_TYPES,
  28. };
  29. /*
  30. * Satellite structure
  31. */
  32. struct sate {
  33. int constell; // GPS or GLN or BDS....
  34. int prn;
  35. int cn0;
  36. int elev; // elevation
  37. int azim; // azimuth
  38. bool in_use; // is the satellite used in fix
  39. bool valid; // is the satellite valid
  40. };
  41. /*
  42. * Gnss date structure
  43. */
  44. struct gnss_date {
  45. int year;
  46. int month;
  47. int day;
  48. };
  49. /*
  50. * Gnss time structure
  51. */
  52. struct gnss_time {
  53. int hour;
  54. int minute;
  55. int second;
  56. int ms;
  57. };
  58. /*
  59. * Navigation data
  60. */
  61. struct nav_data {
  62. struct gnss_date date; // 日期
  63. struct gnss_time time; // 时间
  64. bool is_fixed; // 定位状态
  65. double lat; // 纬度
  66. double lon; // 经度
  67. float alt; // 海拔
  68. float speed; // 速度
  69. float heading; // 航向角度
  70. float hdop; // 水平精度
  71. float vdop; // 垂直精度因子。反映高程(海拔)的精度。
  72. float pdop; // 位置精度因子。反映三维位置的综合精度。
  73. int sv_inuse; // 参与定位的卫星数量。即在计算当前位置时,实际使用了多少颗卫星的数据。
  74. int sv_inview; // 当前可视的卫星数量。即接收机天空中视野范围内一共搜到了多少颗卫星。
  75. int sv_count; // 卫星总数(具体含义取决于上下文,有时等同于 sv_inview,或者是用于遍历卫星数组的计数器)。
  76. struct sate sates[MAX_SVID]; // 用来存储每一颗具体卫星的详细数据(如卫星ID、信噪比、仰角、方位角等)。
  77. };
  78. int prn2svid(int prn, int constell); // convert @prn and @constell to SVID
  79. int tell_constell(int svid); // tell the constellation type of @svid
  80. const char *constell_name(int constell); // get constellation type's name
  81. void navdata_init(struct nav_data *d); // int nav_data to 0
  82. #endif