config.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. #pragma once
  2. #include "defines.h"
  3. //////////////////////////////////////////////////////////////////////////////
  4. //////////////////////////////////////////////////////////////////////////////
  5. // HARDWARE CONFIGURATION AND CONNECTIONS
  6. //////////////////////////////////////////////////////////////////////////////
  7. //////////////////////////////////////////////////////////////////////////////
  8. #ifndef CONFIG_HAL_BOARD
  9. #error CONFIG_HAL_BOARD must be defined to build ArduSub
  10. #endif
  11. // run at 400Hz on all systems
  12. # define MAIN_LOOP_RATE 400
  13. # define MAIN_LOOP_SECONDS 0.0025f
  14. #ifndef SURFACE_DEPTH_DEFAULT
  15. # define SURFACE_DEPTH_DEFAULT -10.0f // pressure sensor reading 10cm depth means craft is considered surfaced
  16. #endif
  17. //////////////////////////////////////////////////////////////////////////////
  18. // PWM control
  19. // default RC speed in Hz
  20. #ifndef RC_SPEED_DEFAULT
  21. # define RC_SPEED_DEFAULT 200
  22. #endif
  23. //////////////////////////////////////////////////////////////////////////////
  24. // Circle Nav parameters
  25. //
  26. #ifndef CIRCLE_NAV_ENABLED
  27. # define CIRCLE_NAV_ENABLED ENABLED
  28. #endif
  29. //////////////////////////////////////////////////////////////////////////////
  30. // RPM
  31. //
  32. #ifndef RPM_ENABLED
  33. # define RPM_ENABLED DISABLED
  34. #endif
  35. //////////////////////////////////////////////////////////////////////////////
  36. // RCMAP
  37. //
  38. #ifndef RCMAP_ENABLED
  39. # define RCMAP_ENABLED DISABLED
  40. #endif
  41. //////////////////////////////////////////////////////////////////////////////
  42. // Rangefinder
  43. //
  44. #ifndef RANGEFINDER_ENABLED
  45. # define RANGEFINDER_ENABLED ENABLED
  46. #endif
  47. #ifndef RANGEFINDER_HEALTH_MAX
  48. # define RANGEFINDER_HEALTH_MAX 3 // number of good reads that indicates a healthy rangefinder
  49. #endif
  50. #ifndef RANGEFINDER_GAIN_DEFAULT
  51. # define RANGEFINDER_GAIN_DEFAULT 0.8f // gain for controlling how quickly rangefinder range adjusts target altitude (lower means slower reaction)
  52. #endif
  53. #ifndef THR_SURFACE_TRACKING_VELZ_MAX
  54. # define THR_SURFACE_TRACKING_VELZ_MAX 150 // max vertical speed change while surface tracking with rangefinder
  55. #endif
  56. #ifndef RANGEFINDER_TIMEOUT_MS
  57. # define RANGEFINDER_TIMEOUT_MS 1000 // desired rangefinder alt will reset to current rangefinder alt after this many milliseconds without a good rangefinder alt
  58. #endif
  59. #ifndef RANGEFINDER_WPNAV_FILT_HZ
  60. # define RANGEFINDER_WPNAV_FILT_HZ 0.25f // filter frequency for rangefinder altitude provided to waypoint navigation class
  61. #endif
  62. #ifndef RANGEFINDER_TILT_CORRECTION // by disable tilt correction for use of range finder data by EKF
  63. # define RANGEFINDER_TILT_CORRECTION ENABLED
  64. #endif
  65. // Avoidance (relies on Proximity and Fence)
  66. #ifndef AVOIDANCE_ENABLED
  67. # define AVOIDANCE_ENABLED DISABLED
  68. #endif
  69. #if AVOIDANCE_ENABLED == ENABLED // Avoidance Library relies on Proximity and Fence
  70. # define PROXIMITY_ENABLED ENABLED
  71. # define FENCE_ENABLED ENABLED
  72. #endif
  73. // Proximity sensor
  74. //
  75. #ifndef PROXIMITY_ENABLED
  76. # define PROXIMITY_ENABLED DISABLED
  77. #endif
  78. #ifndef MAV_SYSTEM_ID
  79. # define MAV_SYSTEM_ID 1
  80. #endif
  81. #ifndef EKF_ORIGIN_MAX_DIST_M
  82. # define EKF_ORIGIN_MAX_DIST_M 50000 // EKF origin and waypoints (including home) must be within 50km
  83. #endif
  84. //////////////////////////////////////////////////////////////////////////////
  85. // MAGNETOMETER
  86. #ifndef MAGNETOMETER
  87. # define MAGNETOMETER ENABLED
  88. #endif
  89. //////////////////////////////////////////////////////////////////////////////
  90. // OPTICAL_FLOW
  91. #ifndef OPTFLOW
  92. # define OPTFLOW DISABLED
  93. #endif
  94. //////////////////////////////////////////////////////////////////////////////
  95. // gripper
  96. #ifndef GRIPPER_ENABLED
  97. # define GRIPPER_ENABLED DISABLED
  98. #endif
  99. //////////////////////////////////////////////////////////////////////////////
  100. // Nav-Guided - allows external nav computer to control vehicle
  101. #ifndef NAV_GUIDED
  102. # define NAV_GUIDED ENABLED
  103. #endif
  104. //////////////////////////////////////////////////////////////////////////////
  105. // CAMERA TRIGGER AND CONTROL
  106. //
  107. #ifndef CAMERA
  108. # define CAMERA DISABLED
  109. #endif
  110. //////////////////////////////////////////////////////////////////////////////
  111. // MOUNT (ANTENNA OR CAMERA)
  112. //
  113. #ifndef MOUNT
  114. # define MOUNT ENABLED
  115. #endif
  116. //////////////////////////////////////////////////////////////////////////////
  117. // Flight mode definitions
  118. //
  119. // Acro Mode
  120. #ifndef ACRO_RP_P
  121. # define ACRO_RP_P 4.5f
  122. #endif
  123. #ifndef ACRO_YAW_P
  124. # define ACRO_YAW_P 3.375f
  125. #endif
  126. #ifndef ACRO_LEVEL_MAX_ANGLE
  127. # define ACRO_LEVEL_MAX_ANGLE 3000
  128. #endif
  129. #ifndef ACRO_BALANCE_ROLL
  130. #define ACRO_BALANCE_ROLL 1.0f
  131. #endif
  132. #ifndef ACRO_BALANCE_PITCH
  133. #define ACRO_BALANCE_PITCH 1.0f
  134. #endif
  135. #ifndef ACRO_EXPO_DEFAULT
  136. #define ACRO_EXPO_DEFAULT 0.3f
  137. #endif
  138. // AUTO Mode
  139. #ifndef WP_YAW_BEHAVIOR_DEFAULT
  140. # define WP_YAW_BEHAVIOR_DEFAULT WP_YAW_BEHAVIOR_CORRECT_XTRACK
  141. #endif
  142. #ifndef AUTO_YAW_SLEW_RATE
  143. # define AUTO_YAW_SLEW_RATE 60 // degrees/sec
  144. #endif
  145. #ifndef YAW_LOOK_AHEAD_MIN_SPEED
  146. # define YAW_LOOK_AHEAD_MIN_SPEED 100 // minimum ground speed in cm/s required before vehicle is aimed at ground course
  147. #endif
  148. //////////////////////////////////////////////////////////////////////////////
  149. // Stabilize Rate Control
  150. //
  151. #ifndef ROLL_PITCH_INPUT_MAX
  152. # define ROLL_PITCH_INPUT_MAX 4500 // roll, pitch input range
  153. #endif
  154. #ifndef DEFAULT_ANGLE_MAX
  155. # define DEFAULT_ANGLE_MAX 4500 // ANGLE_MAX parameters default value
  156. #endif
  157. //////////////////////////////////////////////////////////////////////////////
  158. // Loiter position control gains
  159. //
  160. #ifndef POS_XY_P
  161. # define POS_XY_P 1.0f
  162. #endif
  163. //////////////////////////////////////////////////////////////////////////////
  164. // PosHold parameter defaults
  165. //
  166. #ifndef POSHOLD_ENABLED
  167. # define POSHOLD_ENABLED ENABLED // PosHold flight mode enabled by default
  168. #endif
  169. //////////////////////////////////////////////////////////////////////////////
  170. // Throttle control gains
  171. //
  172. #ifndef THR_DZ_DEFAULT
  173. # define THR_DZ_DEFAULT 100 // the deadzone above and below mid throttle while in althold or loiter
  174. #endif
  175. // default maximum vertical velocity and acceleration the pilot may request
  176. #ifndef PILOT_VELZ_MAX
  177. # define PILOT_VELZ_MAX 500 // maximum vertical velocity in cm/s
  178. #endif
  179. #ifndef PILOT_ACCEL_Z_DEFAULT
  180. # define PILOT_ACCEL_Z_DEFAULT 100 // vertical acceleration in cm/s/s while altitude is under pilot control
  181. #endif
  182. #ifndef AUTO_DISARMING_DELAY
  183. # define AUTO_DISARMING_DELAY 0
  184. #endif
  185. //////////////////////////////////////////////////////////////////////////////
  186. // Logging control
  187. //
  188. #ifndef LOGGING_ENABLED
  189. # define LOGGING_ENABLED ENABLED
  190. #endif
  191. // Default logging bitmask
  192. #ifndef DEFAULT_LOG_BITMASK
  193. # define DEFAULT_LOG_BITMASK \
  194. MASK_LOG_ATTITUDE_MED | \
  195. MASK_LOG_GPS | \
  196. MASK_LOG_PM | \
  197. MASK_LOG_CTUN | \
  198. MASK_LOG_NTUN | \
  199. MASK_LOG_RCIN | \
  200. MASK_LOG_IMU | \
  201. MASK_LOG_CMD | \
  202. MASK_LOG_CURRENT | \
  203. MASK_LOG_RCOUT | \
  204. MASK_LOG_OPTFLOW | \
  205. MASK_LOG_COMPASS | \
  206. MASK_LOG_CAMERA | \
  207. MASK_LOG_MOTBATT
  208. #endif
  209. // Enable/disable Fence
  210. #ifndef AC_FENCE
  211. #define AC_FENCE ENABLED
  212. #endif
  213. #ifndef AC_RALLY
  214. #define AC_RALLY DISABLED
  215. #endif
  216. #ifndef AC_TERRAIN
  217. #define AC_TERRAIN DISABLED // Requires Rally enabled as well
  218. #endif