Parameters.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. #pragma once
  2. #include <AP_Common/AP_Common.h>
  3. #include <AP_Gripper/AP_Gripper.h>
  4. #ifdef ENABLE_SCRIPTING
  5. #include <AP_Scripting/AP_Scripting.h>
  6. #endif
  7. // Global parameter class.
  8. //
  9. class Parameters {
  10. public:
  11. // The version of the layout as described by the parameter enum.
  12. //
  13. // When changing the parameter enum in an incompatible fashion, this
  14. // value should be incremented by one.
  15. //
  16. // The increment will prevent old parameters from being used incorrectly
  17. // by newer code.
  18. //
  19. static const uint16_t k_format_version = 1;
  20. // Parameter identities.
  21. //
  22. // The enumeration defined here is used to ensure that every parameter
  23. // or parameter group has a unique ID number. This number is used by
  24. // AP_Param to store and locate parameters in EEPROM.
  25. //
  26. // Note that entries without a number are assigned the next number after
  27. // the entry preceding them. When adding new entries, ensure that they
  28. // don't overlap.
  29. //
  30. // Try to group related variables together, and assign them a set
  31. // range in the enumeration. Place these groups in numerical order
  32. // at the end of the enumeration.
  33. //
  34. // WARNING: Care should be taken when editing this enumeration as the
  35. // AP_Param load/save code depends on the values here to identify
  36. // variables saved in EEPROM.
  37. //
  38. //
  39. enum {
  40. // Layout version number, always key zero.
  41. //
  42. k_param_format_version = 0,
  43. k_param_software_type, // unusued
  44. k_param_g2, // 2nd block of parameters
  45. k_param_sitl, // Simulation
  46. // Telemetry
  47. k_param_gcs0 = 10,
  48. k_param_gcs1,
  49. k_param_gcs2,
  50. k_param_gcs3,
  51. k_param_sysid_this_mav,
  52. k_param_sysid_my_gcs,
  53. // Hardware/Software configuration
  54. k_param_BoardConfig = 20, // Board configuration (PX4/Linux/etc)
  55. k_param_scheduler, // Scheduler (for debugging/perf_info)
  56. k_param_logger, // AP_Logger Logging
  57. k_param_serial_manager, // Serial ports, AP_SerialManager
  58. k_param_notify, // Notify Library, AP_Notify
  59. k_param_arming = 26, // Arming checks
  60. k_param_BoardConfig_CAN,
  61. // Sensor objects
  62. k_param_ins = 30, // AP_InertialSensor
  63. k_param_compass, // Compass
  64. k_param_barometer, // Barometer/Depth Sensor
  65. k_param_battery, // AP_BattMonitor
  66. k_param_leak_detector, // Leak Detector
  67. k_param_rangefinder, // Rangefinder
  68. k_param_gps, // GPS
  69. k_param_optflow, // Optical Flow
  70. // Navigation libraries
  71. k_param_ahrs = 50, // AHRS
  72. k_param_NavEKF, // Extended Kalman Filter Inertial Navigation // remove
  73. k_param_NavEKF2, // EKF2
  74. k_param_attitude_control, // Attitude Control
  75. k_param_pos_control, // Position Control
  76. k_param_wp_nav, // Waypoint navigation
  77. k_param_mission, // Mission library
  78. k_param_fence, // Fence Library
  79. k_param_terrain, // Terrain database
  80. k_param_rally, // Disabled
  81. k_param_circle_nav, // Disabled
  82. k_param_avoid, // Relies on proximity and fence
  83. k_param_NavEKF3,
  84. k_param_loiter_nav,
  85. // Other external hardware interfaces
  86. k_param_motors = 65, // Motors
  87. k_param_relay, // Relay
  88. k_param_camera, // Camera
  89. k_param_camera_mount, // Camera gimbal
  90. // RC_Channel settings (deprecated)
  91. k_param_rc_1_old = 75,
  92. k_param_rc_2_old,
  93. k_param_rc_3_old,
  94. k_param_rc_4_old,
  95. k_param_rc_5_old,
  96. k_param_rc_6_old,
  97. k_param_rc_7_old,
  98. k_param_rc_8_old,
  99. k_param_rc_9_old,
  100. k_param_rc_10_old,
  101. k_param_rc_11_old,
  102. k_param_rc_12_old,
  103. k_param_rc_13_old,
  104. k_param_rc_14_old,
  105. // Joystick gain parameters
  106. k_param_gain_default,
  107. k_param_maxGain,
  108. k_param_minGain,
  109. k_param_numGainSettings,
  110. k_param_cam_tilt_step, // deprecated
  111. k_param_lights_step, // deprecated
  112. // Joystick button mapping parameters
  113. k_param_jbtn_0 = 95,
  114. k_param_jbtn_1,
  115. k_param_jbtn_2,
  116. k_param_jbtn_3,
  117. k_param_jbtn_4,
  118. k_param_jbtn_5,
  119. k_param_jbtn_6,
  120. k_param_jbtn_7,
  121. k_param_jbtn_8,
  122. k_param_jbtn_9,
  123. k_param_jbtn_10,
  124. k_param_jbtn_11,
  125. k_param_jbtn_12,
  126. k_param_jbtn_13,
  127. k_param_jbtn_14,
  128. k_param_jbtn_15,
  129. // PID Controllers
  130. k_param_p_pos_xy = 126, // deprecated
  131. k_param_p_alt_hold, // deprecated
  132. k_param_pi_vel_xy, // deprecated
  133. k_param_p_vel_z, // deprecated
  134. k_param_pid_accel_z, // deprecated
  135. // Failsafes
  136. k_param_failsafe_gcs = 140,
  137. k_param_failsafe_leak, // leak failsafe behavior
  138. k_param_failsafe_pressure, // internal pressure failsafe behavior
  139. k_param_failsafe_pressure_max, // maximum internal pressure in pascal before failsafe is triggered
  140. k_param_failsafe_temperature, // internal temperature failsafe behavior
  141. k_param_failsafe_temperature_max, // maximum internal temperature in degrees C before failsafe is triggered
  142. k_param_failsafe_terrain, // terrain failsafe behavior
  143. k_param_fs_ekf_thresh,
  144. k_param_fs_ekf_action,
  145. k_param_fs_crash_check,
  146. k_param_failsafe_battery_enabled, // unused - moved to AP_BattMonitor
  147. k_param_fs_batt_mah, // unused - moved to AP_BattMonitor
  148. k_param_fs_batt_voltage, // unused - moved to AP_BattMonitor
  149. k_param_failsafe_pilot_input,
  150. k_param_failsafe_pilot_input_timeout,
  151. // Misc Sub settings
  152. k_param_log_bitmask = 165,
  153. k_param_angle_max = 167,
  154. k_param_rangefinder_gain,
  155. k_param_wp_yaw_behavior = 170,
  156. k_param_xtrack_angle_limit, // Angle limit for crosstrack correction in Auto modes (degrees)
  157. k_param_pilot_speed_up, // renamed from k_param_pilot_velocity_z_max
  158. k_param_pilot_accel_z,
  159. k_param_compass_enabled_deprecated,
  160. k_param_surface_depth,
  161. k_param_rc_speed, // Main output pwm frequency
  162. k_param_gcs_pid_mask = 178,
  163. k_param_throttle_filt,
  164. k_param_throttle_deadzone, // Used in auto-throttle modes
  165. k_param_terrain_follow = 182,
  166. k_param_rc_feel_rp,
  167. k_param_throttle_gain,
  168. k_param_cam_tilt_center, // deprecated
  169. k_param_frame_configuration,
  170. // Acro Mode parameters
  171. k_param_acro_yaw_p = 220, // Used in all modes for get_pilot_desired_yaw_rate
  172. k_param_acro_trainer,
  173. k_param_acro_expo,
  174. k_param_acro_rp_p,
  175. k_param_acro_balance_roll,
  176. k_param_acro_balance_pitch,
  177. // RPM Sensor
  178. k_param_rpm_sensor = 232, // Disabled
  179. // RC_Mapper Library
  180. k_param_rcmap, // Disabled
  181. k_param_cam_slew_limit = 237, // deprecated
  182. k_param_lights_steps,
  183. k_param_pilot_speed_dn,
  184. };
  185. AP_Int16 format_version;
  186. // Telemetry control
  187. //
  188. AP_Int16 sysid_this_mav;
  189. AP_Int16 sysid_my_gcs;
  190. AP_Float throttle_filt;
  191. #if RANGEFINDER_ENABLED == ENABLED
  192. AP_Float rangefinder_gain;
  193. #endif
  194. AP_Int8 failsafe_leak; // leak detection failsafe behavior
  195. AP_Int8 failsafe_gcs; // ground station failsafe behavior
  196. AP_Int8 failsafe_pressure;
  197. AP_Int8 failsafe_temperature;
  198. AP_Int32 failsafe_pressure_max;
  199. AP_Int8 failsafe_temperature_max;
  200. AP_Int8 failsafe_terrain;
  201. AP_Int8 failsafe_pilot_input; // pilot input failsafe behavior
  202. AP_Float failsafe_pilot_input_timeout;
  203. AP_Int8 xtrack_angle_limit;
  204. AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions
  205. AP_Int8 rc_feel_rp; // controls vehicle response to user input with 0 being extremely soft and 100 begin extremely crisp
  206. // Waypoints
  207. //
  208. AP_Int16 pilot_speed_up; // maximum vertical ascending velocity the pilot may request
  209. AP_Int16 pilot_speed_dn; // maximum vertical descending velocity the pilot may request
  210. AP_Int16 pilot_accel_z; // vertical acceleration the pilot may request
  211. // Throttle
  212. //
  213. AP_Int16 throttle_deadzone;
  214. // Misc
  215. //
  216. AP_Int32 log_bitmask;
  217. AP_Int8 fs_ekf_action;
  218. AP_Int8 fs_crash_check;
  219. AP_Float fs_ekf_thresh;
  220. AP_Int16 gcs_pid_mask;
  221. #if AP_TERRAIN_AVAILABLE && AC_TERRAIN
  222. AP_Int8 terrain_follow;
  223. #endif
  224. AP_Int16 rc_speed; // speed of fast RC Channels in Hz
  225. AP_Float gain_default;
  226. AP_Float maxGain;
  227. AP_Float minGain;
  228. AP_Int8 numGainSettings;
  229. AP_Float throttle_gain;
  230. AP_Int16 lights_steps;
  231. // Joystick button parameters
  232. JSButton jbtn_0;
  233. JSButton jbtn_1;
  234. JSButton jbtn_2;
  235. JSButton jbtn_3;
  236. JSButton jbtn_4;
  237. JSButton jbtn_5;
  238. JSButton jbtn_6;
  239. JSButton jbtn_7;
  240. JSButton jbtn_8;
  241. JSButton jbtn_9;
  242. JSButton jbtn_10;
  243. JSButton jbtn_11;
  244. JSButton jbtn_12;
  245. JSButton jbtn_13;
  246. JSButton jbtn_14;
  247. JSButton jbtn_15;
  248. // Acro parameters
  249. AP_Float acro_rp_p;
  250. AP_Float acro_yaw_p;
  251. AP_Float acro_balance_roll;
  252. AP_Float acro_balance_pitch;
  253. AP_Int8 acro_trainer;
  254. AP_Float acro_expo;
  255. AP_Float surface_depth;
  256. AP_Int8 frame_configuration;
  257. // Note: keep initializers here in the same order as they are declared
  258. // above.
  259. Parameters()
  260. {
  261. }
  262. };
  263. /*
  264. 2nd block of parameters, to avoid going past 256 top level keys
  265. */
  266. class ParametersG2 {
  267. public:
  268. ParametersG2(void);
  269. // var_info for holding Parameter information
  270. static const struct AP_Param::GroupInfo var_info[];
  271. #if GRIPPER_ENABLED
  272. AP_Gripper gripper;
  273. #endif
  274. #if PROXIMITY_ENABLED == ENABLED
  275. // proximity (aka object avoidance) library
  276. AP_Proximity proximity;
  277. #endif
  278. // RC input channels
  279. RC_Channels_Sub rc_channels;
  280. // control over servo output ranges
  281. SRV_Channels servo_channels;
  282. #ifdef ENABLE_SCRIPTING
  283. AP_Scripting scripting;
  284. #endif // ENABLE_SCRIPTING
  285. };
  286. extern const AP_Param::Info var_info[];