pilot_navigation.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef __PILOT_NAVIGATION_H
  2. #define __PILOT_NAVIGATION_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #define MODE_COORDINATE 1 // 高速过弯
  6. #define MODE_LOITERTURN 2 // 悬停转弯
  7. #define MODE_LOCKHEAD 3 // 机头锁定
  8. #define MODE_THROWING 4 // 抛物
  9. #define MODE_LANDING 5 // 降落
  10. #define MODE_CIRCLE 6 // 环绕
  11. #define MODE_AUTOTURN 7 // 自动转弯
  12. #define MODE_EXITWP 10
  13. #define TASK_NO 1 // 无任务
  14. #define TASK_PHOTO_DISTANCE 2 // 启动定距离拍照
  15. #define TASK_PHOTO_TIME 3 // 启动定时间拍照
  16. #define ARRIVE_POINT_RADIUS 250.0f
  17. #define vector2(TYPE) \
  18. typedef struct \
  19. { \
  20. TYPE x; \
  21. TYPE y; \
  22. } vector2_##TYPE
  23. vector2(float);
  24. vector2(double);
  25. vector2(int);
  26. vector2(short);
  27. #define vector3(TYPE) \
  28. typedef struct \
  29. { \
  30. TYPE x; \
  31. TYPE y; \
  32. TYPE z; \
  33. } vector3_##TYPE
  34. vector3(float);
  35. vector3(double);
  36. vector3(int);
  37. vector3(short);
  38. struct rec_pos
  39. {
  40. int lng;
  41. int lat;
  42. int alt;
  43. int gps_alt;
  44. int16_t yaw;
  45. };
  46. extern struct rec_pos home_position;
  47. extern struct rec_pos takeoff_position;
  48. extern struct rec_pos poshold_position;
  49. extern struct rec_pos wpphoto_position;
  50. extern struct rec_pos circlecenter_position;
  51. extern struct rec_pos target_yaw_lock_position;
  52. extern uint16_t wp_cycle_times;
  53. extern uint16_t wp_have_cycle_times;
  54. void record_position(int *longitude, int *latitude, int lng, int lat);
  55. float earth_longitude_scale(int lat);
  56. int point_to_point_distance(int lon1, int lat1, int lon2, int lat2);
  57. float cal_tar_vel_z(int t_alt, int c_alt, int acc_up, int acc_down);
  58. //航点数据结构体
  59. struct waypoint_data
  60. {
  61. unsigned short wp_num; // 航点序号
  62. int wp_lng; // 航点经度 *10^7
  63. int wp_lat; // 航点纬度 *10^7
  64. int wp_alt; // 航点高度 cm
  65. short wp_vel; // 巡航速度 cm/s
  66. unsigned char wp_mode; // 航点模式
  67. unsigned short wp_mode_param; // 模式参数。cm、s、
  68. unsigned char wp_task; // 航线任务
  69. unsigned short wp_task_param; // 任务参数。cm、s、
  70. unsigned short wp_totalnum; // 航点总数
  71. short wp_param3; // 航点机头指向
  72. uint8_t wp_alt_type; // 航点高度类型
  73. int16_t wp_param4; // 环绕半径 dm
  74. };
  75. //航点总数
  76. extern unsigned short waypoint_totalnum;
  77. //目标航点序号
  78. extern unsigned short tar_wp_no;
  79. //前一个点到目标点的距离 cm
  80. extern int wp_prevtotar_distance;
  81. //前一个点到目标点的方位角 deg
  82. extern float wp_prevtotar_bearing;
  83. //前一个点到当前点的距离 cm
  84. extern int wp_prevtocur_distance;
  85. //前一个点到当前点的方位角 deg
  86. extern float wp_prevtocur_bearing;
  87. extern int wp_curtotar_distance;
  88. extern float wp_curtotar_bearing;
  89. //开始点到当前点的垂线距离
  90. extern int wp_prevtocur_verdistance;
  91. //当前点到目标点的垂线距离
  92. extern int wp_curtotar_verdistance;
  93. extern bool fly_point_flag, update_point_flag, execute_command_flag;
  94. extern unsigned int arrive_point_time;
  95. extern float wp_curtotar_bearing_last;
  96. extern bool reset_wp_start_time_flag;
  97. int cal_tar_vel_xy_unac(int h_dist, int r_dist, int min_vel, int max_vel);
  98. #endif