control_throttle.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #ifndef __CONTROL_THROTTLE_H
  2. #define __CONTROL_THROTTLE_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include "control_rate.h"
  6. #define HOVER_THR 1300
  7. // 解锁限制条状枚举类
  8. enum
  9. {
  10. // 允许解锁
  11. UNLOCK_ALLOW = 0,
  12. // 不允许解锁,IMU 通讯错包
  13. UNLOCK_DMAERR = 1,
  14. // 不允许解锁,速度超 0.4m/s
  15. UNLOCK_VELERR = 2,
  16. // 不允许解锁,遥控器拨杆位置错误
  17. UNLOCK_RCERR = 3,
  18. // 不允许解锁,未收到IMU数据
  19. UNLOCK_NOIMU = 4,
  20. // 不允许解锁,GPS状态标志错误
  21. UNLOCK_GPSERR = 5,
  22. // 不允许解锁,陀螺加速度计状态标志错误, 或加速度超 0.8m/s^2
  23. UNLOCK_ACCERR = 6,
  24. // 不允许解锁,未INS定位
  25. UNLOCK_NOINSGPS = 7,
  26. // 不允许解锁,无RTK
  27. UNLOCK_NORTK = 8,
  28. // 不允许解锁,磁状态标志错误
  29. UNLOCK_MAGERROR = 9,
  30. // 不允许解锁,陀螺超10deg/s
  31. UNLOCK_GYROERROR = 10,
  32. // 不允许解锁,温度超过80度
  33. UNLOCK_OVER_TEMPRATURE = 11,
  34. // 不允许解锁,imu版本不匹配
  35. UNLOCK_IMU_VERSION_ERR = 12,
  36. // 不允许解锁,在禁飞区内
  37. UNLOCK_IN_NO_FLY_ZONE = 13,
  38. // 不允许解锁, 电压低
  39. UNLOCK_VOLT_LOW = 14,
  40. // 不允许解锁, 智能电池 BMS 电量低
  41. UNLOCK_BMS_LOW_CAPACITY = 15,
  42. // 不允许解锁, 智能电池 BMS 故障
  43. UNLOCK_BMS_FAULT = 16,
  44. // 不允许解锁, 智能电池 BMS 通讯异常
  45. UNLOCK_BMS_LINK_LOST = 17,
  46. // 不允许解锁, 有断桨故障
  47. UNLOCK_SERVO_FAILSAFE = 18,
  48. // 不允许解锁, 姿态倾斜超 30 度
  49. UNLOCK_LEAN_ANGLE = 19,
  50. // 不允许解锁, SD 卡故障
  51. UNLOCK_SD_FAIL = 20,
  52. };
  53. // 油门上锁原因枚举类
  54. enum
  55. {
  56. //初始状态
  57. DEFLOCK = 0,
  58. //遥控器主动上锁
  59. RCLOCK = 1,
  60. //遥控器自动上锁
  61. RCAUTOLOCK = 2,
  62. //摇杆主动上锁
  63. ROCKLOCK = 3,
  64. //摇杆自动上锁
  65. ROCKAUTOLOCK = 4,
  66. //摇杆弹起上锁
  67. ROCKUPLOCK = 5,
  68. //返航上锁
  69. RTHLOCK = 6,
  70. //角度上锁
  71. ANGLELOCK = 7,
  72. //电台丢失上锁
  73. LINKLOSTLOCK = 8,
  74. //自动起飞超时上锁
  75. LAUNCHOTLOCK = 9,
  76. //丢失IMU上锁
  77. NOIMULOCK = 10,
  78. //一键上锁
  79. ONKEYLOCK = 11,
  80. //降落上锁
  81. LANDLOCK = 12,
  82. //丢星姿态降落上锁
  83. GPSFAILLOCK = 13,
  84. //遥控器错误上锁
  85. RCBADLOCK = 14,
  86. // 车载降落上锁
  87. VEHICLELAND_LOCK = 15,
  88. // 地面站强制上锁
  89. GCSFORCELOCK = 16,
  90. // 开伞上锁
  91. PARACHUTELOCK = 17,
  92. };
  93. // 解锁原因枚举类
  94. enum
  95. {
  96. // 初始状态
  97. DEFUNLOCK = 0,
  98. // 遥控器解锁
  99. RCUNLOCK = 1,
  100. // 摇杆解锁
  101. ROCKUNLOCK = 2,
  102. // 自动起飞解锁
  103. LAUNCHUNLOCK = 3,
  104. // 车载起飞解锁
  105. VEHICLELAUNCH_UNLOCK = 4,
  106. };
  107. // 油门锁状态枚举类
  108. enum
  109. {
  110. //上锁状态
  111. LOCKED = 1,
  112. //解锁状态
  113. UNLOCKED = 2,
  114. //起飞状态-给IMU发送指令使用
  115. TAKEOFF = 3
  116. };
  117. // 离地状态枚举类
  118. enum
  119. {
  120. //在地上
  121. ON_GROUND = 1,
  122. //在空中
  123. IN_AIR = 2,
  124. };
  125. // 油门控制状态
  126. typedef enum
  127. {
  128. THROTTLE_OFF = 0,
  129. THROTTLE_ONGROUND_IDLE = 1,
  130. THROTTLE_INAIR_RUNNING = 2
  131. } ThrCtrolStatusType;
  132. extern ThrCtrolStatusType throttle_pidctrl_status;
  133. // 定高状态标志
  134. enum
  135. {
  136. ALT_HOLD = 1,
  137. NO_ALT_HOLD = 2
  138. };
  139. extern char althold_state;
  140. extern bool unlock_fail;
  141. extern char thr_lock_flag;
  142. extern char thr_unlock_flag;
  143. extern char thr_lock_status;
  144. extern char ground_air_status;
  145. void pilot_unlock_decide(void);
  146. void pilot_takeoff_decide(void);
  147. void pilot_lock_decide(void);
  148. void get_pilot_desired_climb_rate_fromrc(short thr_in);
  149. void Calculate_Target_Az(float dt);
  150. void rate_pid_acctothrottle_alt(float dt);
  151. extern float base_thr, temp_basethr;
  152. void set_thr_lock_status(uint8_t lock_status, uint8_t reason);
  153. int judge_pilot_gsunlock_allow(void);
  154. int judge_pilot_rcunlock_allow(void);
  155. void throttle_enable_unlock_tune(void);
  156. bool throttle_get_enable_unlock_tune(void);
  157. void clear_poshold_i_item(struct pid_method_ap *method);
  158. #endif