Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduSub/Parameters.h
9602 views
1
#pragma once
2
3
#define AP_PARAM_VEHICLE_NAME sub
4
5
#include <AP_Common/AP_Common.h>
6
7
#include <AP_Arming/AP_Arming.h>
8
#include "actuators.h"
9
// Global parameter class.
10
//
11
class Parameters {
12
public:
13
// The version of the layout as described by the parameter enum.
14
//
15
// When changing the parameter enum in an incompatible fashion, this
16
// value should be incremented by one.
17
//
18
// The increment will prevent old parameters from being used incorrectly
19
// by newer code.
20
//
21
static const uint16_t k_format_version = 1;
22
23
// Parameter identities.
24
//
25
// The enumeration defined here is used to ensure that every parameter
26
// or parameter group has a unique ID number. This number is used by
27
// AP_Param to store and locate parameters in EEPROM.
28
//
29
// Note that entries without a number are assigned the next number after
30
// the entry preceding them. When adding new entries, ensure that they
31
// don't overlap.
32
//
33
// Try to group related variables together, and assign them a set
34
// range in the enumeration. Place these groups in numerical order
35
// at the end of the enumeration.
36
//
37
// WARNING: Care should be taken when editing this enumeration as the
38
// AP_Param load/save code depends on the values here to identify
39
// variables saved in EEPROM.
40
//
41
//
42
enum {
43
// Layout version number, always key zero.
44
//
45
k_param_format_version = 0,
46
k_param_software_type, // unused
47
48
k_param_g2, // 2nd block of parameters
49
50
k_param_sitl, // Simulation
51
k_param_osd, //OSD
52
53
// Telemetry
54
k_param_gcs0_unused = 10, // unused in ArduPilot-4.7
55
k_param_gcs1_unused, // unused in ArduPilot-4.7
56
k_param_gcs2_unused, // unused in ArduPilot-4.7
57
k_param_gcs3_unused, // unused in ArduPilot-4.7
58
k_param_sysid_this_mav_old,
59
k_param_sysid_my_gcs_old,
60
61
// Hardware/Software configuration
62
k_param_BoardConfig = 20, // Board configuration (Pixhawk/Linux/etc)
63
k_param_scheduler, // Scheduler (for debugging/perf_info)
64
k_param_logger, // AP_Logger Logging
65
k_param_serial_manager_old, // Serial ports, AP_SerialManager
66
k_param_notify, // Notify Library, AP_Notify
67
k_param_arming = 26, // Arming checks
68
k_param_can_mgr,
69
k_param_thr_arming_position,
70
71
// Sensor objects
72
k_param_ins = 30, // AP_InertialSensor
73
k_param_compass, // Compass
74
k_param_barometer, // Barometer/Depth Sensor
75
k_param_battery, // AP_BattMonitor
76
k_param_leak_detector, // Leak Detector
77
k_param_rangefinder, // Rangefinder
78
k_param_gps, // GPS
79
k_param_optflow, // Optical Flow
80
81
82
// Navigation libraries
83
k_param_ahrs = 50, // AHRS
84
k_param_NavEKF, // Extended Kalman Filter Inertial Navigation // remove
85
k_param_NavEKF2, // EKF2
86
k_param_attitude_control, // Attitude Control
87
k_param_pos_control, // Position Control
88
k_param_wp_nav, // Waypoint navigation
89
k_param_mission, // Mission library
90
k_param_fence_old, // only used for conversion
91
k_param_terrain, // Terrain database
92
k_param_rally, // Disabled
93
k_param_circle_nav, // Disabled
94
k_param_avoid, // Relies on proximity and fence
95
k_param_NavEKF3,
96
k_param_loiter_nav,
97
98
99
// Other external hardware interfaces
100
k_param_motors = 65, // Motors
101
k_param_relay, // Relay
102
k_param_camera, // Camera
103
k_param_camera_mount, // Camera gimbal
104
105
106
// RC_Channel settings (deprecated)
107
k_param_rc_1_old = 75,
108
k_param_rc_2_old,
109
k_param_rc_3_old,
110
k_param_rc_4_old,
111
k_param_rc_5_old,
112
k_param_rc_6_old,
113
k_param_rc_7_old,
114
k_param_rc_8_old,
115
k_param_rc_9_old,
116
k_param_rc_10_old,
117
k_param_rc_11_old,
118
k_param_rc_12_old,
119
k_param_rc_13_old,
120
k_param_rc_14_old,
121
122
// Joystick gain parameters
123
k_param_gain_default,
124
k_param_maxGain,
125
k_param_minGain,
126
k_param_numGainSettings,
127
k_param_cam_tilt_step, // deprecated
128
k_param_lights_step, // deprecated
129
130
// Joystick button mapping parameters
131
k_param_jbtn_0 = 95,
132
k_param_jbtn_1,
133
k_param_jbtn_2,
134
k_param_jbtn_3,
135
k_param_jbtn_4,
136
k_param_jbtn_5,
137
k_param_jbtn_6,
138
k_param_jbtn_7,
139
k_param_jbtn_8,
140
k_param_jbtn_9,
141
k_param_jbtn_10,
142
k_param_jbtn_11,
143
k_param_jbtn_12,
144
k_param_jbtn_13,
145
k_param_jbtn_14,
146
k_param_jbtn_15,
147
148
// 16 more for MANUAL_CONTROL extensions
149
k_param_jbtn_16,
150
k_param_jbtn_17,
151
k_param_jbtn_18,
152
k_param_jbtn_19,
153
k_param_jbtn_20,
154
k_param_jbtn_21,
155
k_param_jbtn_22,
156
k_param_jbtn_23,
157
k_param_jbtn_24,
158
k_param_jbtn_25,
159
k_param_jbtn_26,
160
k_param_jbtn_27,
161
k_param_jbtn_28,
162
k_param_jbtn_29,
163
k_param_jbtn_30,
164
k_param_jbtn_31,
165
166
// PID Controllers
167
k_param_p_pos_xy = 126, // deprecated
168
k_param_p_alt_hold, // deprecated
169
k_param_pi_vel_xy, // deprecated
170
k_param_p_vel_z, // deprecated
171
k_param_pid_accel_z, // deprecated
172
173
174
// Failsafes
175
k_param_failsafe_gcs = 140,
176
k_param_failsafe_leak, // leak failsafe behavior
177
k_param_failsafe_pressure, // internal pressure failsafe behavior
178
k_param_failsafe_pressure_max, // maximum internal pressure in pascal before failsafe is triggered
179
k_param_failsafe_temperature, // internal temperature failsafe behavior
180
k_param_failsafe_temperature_max, // maximum internal temperature in degrees C before failsafe is triggered
181
k_param_failsafe_terrain, // terrain failsafe behavior
182
k_param_fs_ekf_thresh,
183
k_param_fs_ekf_action,
184
k_param_fs_crash_check,
185
k_param_failsafe_battery_enabled, // unused - moved to AP_BattMonitor
186
k_param_fs_batt_mah, // unused - moved to AP_BattMonitor
187
k_param_fs_batt_voltage, // unused - moved to AP_BattMonitor
188
k_param_failsafe_pilot_input,
189
k_param_failsafe_pilot_input_timeout,
190
k_param_failsafe_gcs_timeout,
191
192
193
// Misc Sub settings
194
k_param_log_bitmask = 165,
195
k_param_angle_max = 167, // remove
196
k_param_rangefinder_gain, // deprecated
197
k_param_wp_yaw_behavior = 170,
198
k_param_xtrack_angle_limit, // Angle limit for crosstrack correction in Auto modes (degrees)
199
k_param_pilot_speed_up, // renamed from k_param_pilot_velocity_z_max
200
k_param_pilot_accel_z,
201
k_param_compass_enabled_deprecated,
202
k_param_surface_depth,
203
k_param_rc_speed, // Main output pwm frequency
204
k_param_gcs_pid_mask = 178,
205
k_param_throttle_filt,
206
k_param_throttle_deadzone, // Used in auto-throttle modes
207
k_param_terrain_follow = 182, // deprecated
208
k_param_rc_feel_rp,
209
k_param_throttle_gain,
210
k_param_cam_tilt_center, // deprecated
211
k_param_frame_configuration,
212
k_param_surface_max_throttle,
213
k_param_surface_nobaro_thrust,
214
// 200: flight modes
215
k_param_flight_mode1 = 200,
216
k_param_flight_mode2,
217
k_param_flight_mode3,
218
k_param_flight_mode4,
219
k_param_flight_mode5,
220
k_param_flight_mode6,
221
k_param_simple_modes,
222
k_param_flight_mode_chan,
223
#if AP_RSSI_ENABLED
224
k_param_rssi,
225
#endif
226
227
// Acro Mode parameters
228
k_param_acro_yaw_p = 220, // Used in all modes for get_pilot_desired_yaw_rate
229
k_param_acro_trainer,
230
k_param_acro_expo,
231
k_param_acro_rp_p,
232
k_param_acro_balance_roll,
233
k_param_acro_balance_pitch,
234
235
// RPM Sensor
236
k_param_rpm_sensor_old = 232, // unused - moved to vehicle
237
238
// RC_Mapper Library
239
k_param_rcmap, // Disabled
240
241
k_param_gcs4_unused, // unused in ArduPilot-4.7
242
k_param_gcs5_unused, // unused in ArduPilot-4.7
243
k_param_gcs6_unused, // unused in ArduPilot-4.7
244
245
k_param_cam_slew_limit = 237, // deprecated
246
k_param_lights_steps,
247
k_param_pilot_speed_dn,
248
k_param_rangefinder_signal_min,
249
k_param_surftrak_depth,
250
k_param_pilot_speed,
251
k_param_failsafe_throttle,
252
k_param_failsafe_throttle_value,
253
k_param_vehicle = 257, // vehicle common block of parameters
254
k_param__gcs = 258,
255
};
256
257
AP_Int16 format_version;
258
259
// Telemetry control
260
//
261
AP_Float throttle_filt;
262
263
#if AP_RANGEFINDER_ENABLED
264
AP_Int8 rangefinder_signal_min; // minimum signal quality for good rangefinder readings
265
AP_Float surftrak_depth; // surftrak will try to keep sub below this depth
266
#endif
267
268
AP_Int8 failsafe_leak; // leak detection failsafe behavior
269
AP_Int8 failsafe_gcs; // ground station failsafe behavior
270
AP_Int8 failsafe_pressure;
271
AP_Int8 failsafe_temperature;
272
AP_Int32 failsafe_pressure_max;
273
AP_Int8 failsafe_temperature_max;
274
AP_Int8 failsafe_terrain;
275
AP_Int8 failsafe_pilot_input; // pilot input failsafe behavior
276
AP_Float failsafe_pilot_input_timeout;
277
AP_Float failsafe_gcs_timeout; // ground station failsafe timeout (seconds)
278
279
AP_Int8 xtrack_angle_limit;
280
281
AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions
282
AP_Int8 rc_feel_rp; // controls vehicle response to user input with 0 being extremely soft and 100 begin extremely crisp
283
284
// Waypoints
285
//
286
AP_Int16 pilot_speed_up; // maximum vertical ascending velocity the pilot may request
287
AP_Int16 pilot_speed_dn; // maximum vertical descending velocity the pilot may request
288
AP_Int16 pilot_speed; // maximum horizontal (xy) velocity the pilot may request
289
AP_Int16 pilot_accel_z; // vertical acceleration the pilot may request
290
291
// Throttle
292
//
293
AP_Int16 throttle_deadzone;
294
AP_Int8 failsafe_throttle;
295
AP_Int16 failsafe_throttle_value;
296
AP_Int16 thr_arming_position;
297
298
299
// Misc
300
//
301
AP_Int32 log_bitmask;
302
303
AP_Int8 fs_ekf_action;
304
AP_Int8 fs_crash_check;
305
AP_Float fs_ekf_thresh;
306
AP_Int16 gcs_pid_mask;
307
308
AP_Int16 rc_speed; // speed of fast RC Channels in Hz
309
310
AP_Float gain_default;
311
AP_Float maxGain;
312
AP_Float minGain;
313
AP_Int8 numGainSettings;
314
AP_Float throttle_gain;
315
316
AP_Int16 lights_steps;
317
318
// Joystick button parameters
319
JSButton jbtn_0;
320
JSButton jbtn_1;
321
JSButton jbtn_2;
322
JSButton jbtn_3;
323
JSButton jbtn_4;
324
JSButton jbtn_5;
325
JSButton jbtn_6;
326
JSButton jbtn_7;
327
JSButton jbtn_8;
328
JSButton jbtn_9;
329
JSButton jbtn_10;
330
JSButton jbtn_11;
331
JSButton jbtn_12;
332
JSButton jbtn_13;
333
JSButton jbtn_14;
334
JSButton jbtn_15;
335
// 16 - 31 from manual_control extension
336
JSButton jbtn_16;
337
JSButton jbtn_17;
338
JSButton jbtn_18;
339
JSButton jbtn_19;
340
JSButton jbtn_20;
341
JSButton jbtn_21;
342
JSButton jbtn_22;
343
JSButton jbtn_23;
344
JSButton jbtn_24;
345
JSButton jbtn_25;
346
JSButton jbtn_26;
347
JSButton jbtn_27;
348
JSButton jbtn_28;
349
JSButton jbtn_29;
350
JSButton jbtn_30;
351
JSButton jbtn_31;
352
353
// Acro parameters
354
AP_Float acro_rp_p;
355
AP_Float acro_yaw_p;
356
AP_Float acro_balance_roll;
357
AP_Float acro_balance_pitch;
358
AP_Int8 acro_trainer;
359
AP_Float acro_expo;
360
361
#if AP_SUB_RC_ENABLED
362
363
// Flight modes
364
//
365
AP_Int8 flight_mode1;
366
AP_Int8 flight_mode2;
367
AP_Int8 flight_mode3;
368
AP_Int8 flight_mode4;
369
AP_Int8 flight_mode5;
370
AP_Int8 flight_mode6;
371
AP_Int8 simple_modes;
372
AP_Int8 flight_mode_chan;
373
#endif
374
375
AP_Float surface_depth;
376
AP_Int8 frame_configuration;
377
378
AP_Float surface_max_throttle;
379
380
// Note: keep initializers here in the same order as they are declared
381
// above.
382
Parameters()
383
{
384
}
385
};
386
387
/*
388
2nd block of parameters, to avoid going past 256 top level keys
389
*/
390
class ParametersG2 {
391
public:
392
ParametersG2(void);
393
394
// var_info for holding Parameter information
395
static const struct AP_Param::GroupInfo var_info[];
396
397
#if HAL_PROXIMITY_ENABLED
398
// proximity (aka object avoidance) library
399
AP_Proximity proximity;
400
#endif
401
402
// RC input channels
403
RC_Channels_Sub rc_channels;
404
405
// control over servo output ranges
406
SRV_Channels servo_channels;
407
408
AP_Float surface_nobaro_thrust;
409
Actuators actuators;
410
411
};
412
413
extern const AP_Param::Info var_info[];
414
415
// Sub-specific default parameters
416
static const struct AP_Param::defaults_table_struct defaults_table[] = {
417
{ "BRD_SAFETY_DEFLT", 0 },
418
{ "ARMING_SKIPCHK", (~(uint32_t(AP_Arming::Check::RC) |
419
uint32_t(AP_Arming::Check::VOLTAGE) |
420
uint32_t(AP_Arming::Check::BATTERY))
421
) & ((1U<<24)-1)}, // keep within float range but disable future checks
422
{ "CIRCLE_RATE", 2.0f},
423
{ "ATC_ACCEL_Y_MAX", 110000.0f},
424
{ "ATC_RATE_Y_MAX", 180.0f},
425
{ "RC3_TRIM", 1500},
426
{ "COMPASS_OFFS_MAX", 1000},
427
{ "INS_GYR_CAL", 0},
428
{ "RCMAP_ROLL", 2},
429
{ "RCMAP_PITCH", 1},
430
{ "RCMAP_FORWARD", 5},
431
{ "RCMAP_LATERAL", 6},
432
#if HAL_MOUNT_ENABLED
433
{ "MNT1_TYPE", 1},
434
{ "MNT1_DEFLT_MODE", MAV_MOUNT_MODE_RC_TARGETING},
435
{ "MNT1_RC_RATE", 30},
436
#endif
437
{ "RC7_OPTION", 214}, // MOUNT1_YAW
438
{ "RC8_OPTION", 213}, // MOUNT1_PITCH
439
{ "MOT_PWM_MIN", 1100},
440
{ "MOT_PWM_MAX", 1900},
441
{ "PSC_JERK_D", 50.0f},
442
{ "WPNAV_SPEED", 100.0f},
443
{ "PILOT_SPEED_UP", 100.0f},
444
{ "PSC_NE_VEL_P", 6.0f},
445
{ "EK3_SRC1_VELZ", 0},
446
#if AP_SUB_RC_ENABLED
447
{ "RC_PROTOCOLS", 0},
448
#endif
449
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
450
{ "BATT_MONITOR", 4},
451
{ "BATT_CAPACITY", 0},
452
{ "LEAK1_PIN", 27},
453
{ "SCHED_LOOP_RATE", 200},
454
{ "SERVO13_FUNCTION", 181}, // k_lights1
455
{ "SERVO14_FUNCTION", 182}, // k_lights2
456
{ "SERVO16_FUNCTION", 7}, // k_mount_tilt
457
{ "SERVO16_REVERSED", 1},
458
#else
459
#if AP_BARO_PROBE_EXT_PARAMETER_ENABLED
460
{ "BARO_PROBE_EXT", 768},
461
#endif
462
{ "SERVO9_FUNCTION", 59}, // k_rcin9, lights 1
463
{ "SERVO10_FUNCTION", 7}, // k_mount_tilt
464
#endif
465
};
466
467