Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduPlane/Parameters.h
9659 views
1
#pragma once
2
3
#define AP_PARAM_VEHICLE_NAME plane
4
5
#include <AP_Common/AP_Common.h>
6
7
// Global parameter class.
8
//
9
class Parameters {
10
public:
11
12
/*
13
* The value of k_format_version determines whether the existing
14
* eeprom data is considered valid. You should only change this
15
* value under the following circumstances:
16
*
17
* 1) the meaning of an existing eeprom parameter changes
18
*
19
* 2) the value of an existing k_param_* enum value changes
20
*
21
* Adding a new parameter should _not_ require a change to
22
* k_format_version except under special circumstances. If you
23
* change it anyway then all ArduPlane users will need to reload all
24
* their parameters. We want that to be an extremely rare
25
* thing. Please do not just change it "just in case".
26
*
27
* To determine if a k_param_* value has changed, use the rules of
28
* C++ enums to work out the value of the neighboring enum
29
* values. If you don't know the C++ enum rules then please ask for
30
* help.
31
*/
32
33
//////////////////////////////////////////////////////////////////
34
// STOP!!! DO NOT CHANGE THIS VALUE UNTIL YOU FULLY UNDERSTAND THE
35
// COMMENTS ABOVE. IF UNSURE, ASK ANOTHER DEVELOPER!!!
36
static const uint16_t k_format_version = 13;
37
//////////////////////////////////////////////////////////////////
38
39
enum class ThrFailsafe {
40
Disabled = 0,
41
Enabled = 1,
42
EnabledNoFS = 2
43
};
44
45
enum {
46
// Layout version number, always key zero.
47
//
48
k_param_format_version = 0,
49
k_param_software_type, // unused;
50
k_param_num_resets, // unused
51
k_param_NavEKF2,
52
k_param_g2,
53
k_param_avoidance_adsb,
54
k_param_landing,
55
k_param_NavEKF3,
56
k_param_can_mgr,
57
k_param_osd,
58
59
// Misc
60
//
61
k_param_auto_trim = 10, // unused
62
k_param_log_bitmask_old, // unused
63
k_param_pitch_trim,
64
k_param_mix_mode,
65
k_param_reverse_elevons, // unused
66
k_param_reverse_ch1_elevon, // unused
67
k_param_reverse_ch2_elevon, // unused
68
k_param_flap_1_percent,
69
k_param_flap_1_speed,
70
k_param_flap_2_percent,
71
k_param_flap_2_speed,
72
k_param_reset_switch_chan, // unused - moved to RC option
73
k_param_manual_level, // unused
74
k_param_land_pitch_cd, // unused - moved to AP_Landing
75
k_param_ins_old, // *** Deprecated, remove with next eeprom number change
76
k_param_stick_mixing,
77
k_param_reset_mission_chan, // unused - moved to RC option
78
k_param_land_flare_alt, // unused - moved to AP_Landing
79
k_param_land_flare_sec, // unused - moved to AP_Landing
80
k_param_crosstrack_min_distance, // unused
81
k_param_rudder_steer, // unused
82
k_param_throttle_nudge,
83
k_param_alt_offset,
84
k_param_ins, // libraries/AP_InertialSensor variables
85
k_param_takeoff_throttle_min_speed,
86
k_param_takeoff_throttle_min_accel,
87
k_param_takeoff_heading_hold, // unused
88
k_param_level_roll_limit,
89
k_param_hil_servos_unused, // unused
90
k_param_vtail_output, // unused
91
k_param_nav_controller, // unused
92
k_param_elevon_output, // unused
93
k_param_att_controller, // unused
94
k_param_mixing_gain,
95
k_param_scheduler,
96
k_param_relay,
97
k_param_takeoff_throttle_delay,
98
k_param_mode_takeoff, // was skip_gyro_cal
99
k_param_auto_fbw_steer, // unused
100
k_param_waypoint_max_radius,
101
k_param_ground_steer_alt,
102
k_param_ground_steer_dps,
103
k_param_rally_limit_km_old, //unused anymore -- just holding this index
104
k_param_hil_err_limit_unused, // unused
105
k_param_sonar_old, // unused
106
k_param_log_bitmask,
107
k_param_BoardConfig,
108
k_param_rssi_range, // unused, replaced by rssi_ library parameters
109
k_param_flapin_channel_old, // unused, moved to RC_OPTION
110
k_param_flaperon_output, // unused
111
k_param_gps,
112
k_param_autotune_level,
113
k_param_rally,
114
k_param_serial0_baud, // deprecated
115
k_param_serial1_baud, // deprecated
116
k_param_serial2_baud, // deprecated
117
k_param_takeoff_tdrag_elevator,
118
k_param_takeoff_tdrag_speed1,
119
k_param_takeoff_rotate_speed,
120
k_param_takeoff_throttle_slewrate,
121
k_param_takeoff_throttle_max,
122
k_param_rangefinder,
123
k_param_terrain,
124
k_param_terrain_follow,
125
k_param_stab_pitch_down_cd_old, // deprecated
126
k_param_alt_slope_min,
127
k_param_stab_pitch_down,
128
k_param_terrain_lookahead,
129
k_param_fbwa_tdrag_chan, // unused - moved to RC option
130
k_param_rangefinder_landing,
131
k_param_land_flap_percent, // unused - moved to AP_Landing
132
k_param_takeoff_flap_percent,
133
k_param_flap_slewrate,
134
k_param_rtl_autoland,
135
k_param_override_channel,
136
k_param_stall_prevention,
137
k_param_optflow,
138
k_param_cli_enabled_old, // unused - CLI removed
139
k_param_trim_rc_at_start, // unused
140
k_param_hil_mode_unused, // unused
141
k_param_land_disarm_delay, // unused - moved to AP_Landing
142
k_param_alt_slope_max_height,
143
k_param_rudder_only,
144
k_param_gcs3_unused, // unused in ArduPilot-4.7
145
k_param_gcs_pid_mask,
146
k_param_crash_detection_enable,
147
k_param_land_abort_throttle_enable, // unused - moved to AP_Landing
148
k_param_rssi = 97,
149
k_param_rpm_sensor_old, // unused - moved to vehicle
150
k_param_parachute,
151
k_param_arming = 100,
152
k_param_parachute_channel, // unused - moved to RC option
153
k_param_crash_accel_threshold,
154
k_param_override_safety, // unused
155
k_param_land_throttle_slewrate, // 104 unused - moved to AP_Landing
156
157
// 105: Extra parameters
158
k_param_fence_retalt = 105,
159
k_param_fence_autoenable,
160
k_param_fence_ret_rally,
161
k_param_q_attitude_control,
162
k_param_takeoff_pitch_limit_reduction_sec,
163
164
// 110: Telemetry control
165
//
166
k_param_gcs0_unused = 110, // unused in ArduPilot-4.7
167
k_param_gcs1_unused, // unused in ArduPilot-4.7
168
k_param_sysid_this_mav_old,
169
k_param_sysid_my_gcs_old,
170
k_param_serial1_baud_old, // deprecated
171
k_param_telem_delay_old,
172
k_param_serial0_baud_old, // deprecated
173
k_param_gcs2_unused, // unused in ArduPilot-4.7
174
k_param_serial2_baud_old, // deprecated
175
k_param_serial2_protocol, // deprecated
176
177
// 120: Fly-by-wire control
178
//
179
k_param_airspeed_min = 120,
180
k_param_airspeed_max,
181
k_param_cruise_alt_floor,
182
k_param_flybywire_elev_reverse,
183
k_param_alt_control_algorithm, // unused
184
k_param_flybywire_climb_rate,
185
k_param_acro_roll_rate,
186
k_param_acro_pitch_rate,
187
k_param_acro_locking,
188
k_param_use_reverse_thrust = 129,
189
190
//
191
// 130: Sensor parameters
192
//
193
k_param_imu = 130, // unused
194
k_param_altitude_mix, // deprecated
195
196
k_param_compass_enabled_deprecated,
197
k_param_compass,
198
k_param_battery_monitoring, // unused
199
k_param_volt_div_ratio, // unused
200
k_param_curr_amp_per_volt, // unused
201
k_param_input_voltage, // deprecated, can be deleted
202
k_param_pack_capacity, // unused
203
k_param_sonar_enabled_old, // unused
204
k_param_ahrs, // AHRS group
205
k_param_barometer, // barometer ground calibration
206
k_param_airspeed, // only used for parameter conversion; AP_Airspeed parameters moved to AP_Vehicle
207
k_param_curr_amp_offset,
208
k_param_NavEKF, // deprecated - remove
209
k_param_mission, // mission library
210
k_param_serial_manager_old, // serial manager library
211
k_param_NavEKF2_old, // deprecated - remove
212
k_param_land_pre_flare_alt, // unused - moved to AP_Landing
213
k_param_land_pre_flare_airspeed = 149, // unused - moved to AP_Landing
214
215
//
216
// 150: Navigation parameters
217
//
218
k_param_crosstrack_gain = 150, // unused
219
k_param_crosstrack_entry_angle, // unused
220
k_param_roll_limit,
221
k_param_pitch_limit_max,
222
k_param_pitch_limit_min,
223
k_param_airspeed_cruise,
224
k_param_RTL_altitude,
225
k_param_inverted_flight_ch_unused, // unused
226
k_param_min_groundspeed,
227
k_param_crosstrack_use_wind, // unused
228
229
230
//
231
// Camera and mount parameters
232
//
233
k_param_camera = 160,
234
k_param_camera_mount,
235
k_param_camera_mount2, // unused
236
k_param_adsb,
237
k_param_notify,
238
k_param_land_pre_flare_sec = 165, // unused - moved to AP_Landing
239
240
//
241
// Battery monitoring parameters
242
//
243
k_param_battery = 166,
244
k_param_rssi_pin, // unused, replaced by rssi_ library parameters - 167
245
k_param_battery_volt_pin, // unused - 168
246
k_param_battery_curr_pin, // unused - 169
247
248
//
249
// 170: Radio settings - all unused now
250
//
251
k_param_rc_1_old = 170,
252
k_param_rc_2_old,
253
k_param_rc_3_old,
254
k_param_rc_4_old,
255
k_param_rc_5_old,
256
k_param_rc_6_old,
257
k_param_rc_7_old,
258
k_param_rc_8_old,
259
k_param_rc_9_old,
260
k_param_rc_10_old,
261
k_param_rc_11_old,
262
263
k_param_throttle_min,
264
k_param_throttle_max,
265
k_param_throttle_fs_enabled,
266
k_param_throttle_fs_value,
267
k_param_throttle_cruise,
268
269
k_param_fs_action_short,
270
k_param_fs_action_long,
271
k_param_gcs_heartbeat_fs_enabled,
272
k_param_throttle_slewrate,
273
k_param_throttle_suppress_manual,
274
k_param_throttle_passthru_stabilize,
275
k_param_rc_12_old,
276
k_param_fs_batt_voltage, // unused - moved to AP_BattMonitor
277
k_param_fs_batt_mah, // unused - moved to AP_BattMonitor
278
k_param_fs_timeout_short_unused, // unused
279
k_param_fs_timeout_long,
280
k_param_rc_13_old,
281
k_param_rc_14_old,
282
k_param_tuning,
283
284
//
285
// 200: Feed-forward gains
286
//
287
k_param_kff_pitch_compensation = 200, // unused
288
k_param_kff_rudder_mix,
289
k_param_kff_pitch_to_throttle, // unused
290
k_param_kff_throttle_to_pitch,
291
k_param_scaling_speed,
292
k_param_quadplane,
293
k_param_rtl_radius,
294
k_param_land_then_servos_neutral, // unused - moved to AP_Landing
295
k_param_rc_15_old,
296
k_param_rc_16_old,
297
298
//
299
// 210: flight modes
300
//
301
k_param_flight_mode_channel = 210,
302
k_param_flight_mode1,
303
k_param_flight_mode2,
304
k_param_flight_mode3,
305
k_param_flight_mode4,
306
k_param_flight_mode5,
307
k_param_flight_mode6,
308
k_param_initial_mode,
309
k_param_land_slope_recalc_shallow_threshold, // unused - moved to AP_Landing
310
k_param_land_slope_recalc_steep_threshold_to_abort, // unused - moved to AP_Landing
311
312
//
313
// 220: Waypoint data
314
//
315
k_param_waypoint_mode = 220, // unused
316
k_param_command_total, // unused
317
k_param_command_index, // unused
318
k_param_waypoint_radius,
319
k_param_loiter_radius,
320
k_param_fence_action,
321
k_param_fence_total,
322
k_param_fence_channel, // unused - moved to RC option
323
k_param_fence_minalt,
324
k_param_fence_maxalt,
325
326
// other objects
327
k_param_sitl = 230,
328
k_param_afs,
329
k_param_rollController,
330
k_param_pitchController,
331
k_param_yawController,
332
k_param_L1_controller,
333
k_param_rcmap,
334
k_param_TECS_controller,
335
k_param_rally_total_old, //unused
336
k_param_steerController,
337
338
//
339
// 240: PID Controllers
340
k_param_pidNavRoll = 240, // unused
341
k_param_pidServoRoll, // unused
342
k_param_pidServoPitch, // unused
343
k_param_pidNavPitchAirspeed, // unused
344
k_param_pidServoRudder, // unused
345
k_param_pidTeThrottle, // unused
346
k_param_pidNavPitchAltitude, // unused
347
k_param_pidWheelSteer, // unused
348
349
k_param_mixing_offset,
350
k_param_dspoiler_rud_rate,
351
k_param_airspeed_stall,
352
353
k_param_logger = 253, // Logging Group
354
355
// 254,255: reserved
356
357
k_param_vehicle = 257, // vehicle common block of parameters
358
k_param_gcs4_unused, // unused in ArduPilot-4.7
359
k_param_gcs5_unused, // unused in ArduPilot-4.7
360
k_param_gcs6_unused, // unused in ArduPilot-4.7
361
k_param_fence, // vehicle fence - unused
362
k_param_acro_yaw_rate,
363
k_param_takeoff_throttle_max_t,
364
k_param_autotune_options,
365
k_param_takeoff_throttle_min,
366
k_param_takeoff_options,
367
k_param_takeoff_throttle_idle,
368
369
k_param_pullup = 270,
370
k_param_quicktune,
371
k_param_mode_autoland,
372
k_param__gcs,
373
374
};
375
376
AP_Int16 format_version;
377
378
AP_Enum<RtlAutoland> rtl_autoland;
379
380
AP_Int8 crash_accel_threshold;
381
382
// Feed-forward gains
383
//
384
AP_Float kff_rudder_mix;
385
AP_Float kff_pitch_to_throttle;
386
AP_Float kff_throttle_to_pitch;
387
AP_Float ground_steer_alt;
388
AP_Int16 ground_steer_dps;
389
AP_Float stab_pitch_down;
390
391
// speed used for speed scaling
392
AP_Float scaling_speed;
393
394
// Waypoints
395
//
396
AP_Int16 waypoint_radius;
397
AP_Int16 waypoint_max_radius;
398
AP_Int16 rtl_radius;
399
400
// Fly-by-wire
401
//
402
AP_Int8 flybywire_elev_reverse;
403
AP_Int8 flybywire_climb_rate;
404
405
// Throttle
406
//
407
AP_Int8 throttle_suppress_manual;
408
AP_Int8 throttle_passthru_stabilize;
409
AP_Enum<ThrFailsafe> throttle_fs_enabled;
410
AP_Int16 throttle_fs_value;
411
AP_Int8 throttle_nudge;
412
AP_Int32 use_reverse_thrust;
413
414
// Failsafe
415
AP_Int8 fs_action_short;
416
AP_Int8 fs_action_long;
417
AP_Float fs_timeout_long;
418
AP_Int8 gcs_heartbeat_fs_enabled;
419
420
// Flight modes
421
//
422
AP_Int8 flight_mode_channel;
423
AP_Int8 flight_mode1;
424
AP_Int8 flight_mode2;
425
AP_Int8 flight_mode3;
426
AP_Int8 flight_mode4;
427
AP_Int8 flight_mode5;
428
AP_Int8 flight_mode6;
429
AP_Int8 initial_mode;
430
431
// Navigational manoeuvring limits
432
//
433
AP_Int16 alt_offset;
434
AP_Int16 acro_roll_rate;
435
AP_Int16 acro_pitch_rate;
436
AP_Int16 acro_yaw_rate;
437
AP_Int8 acro_locking;
438
439
// Misc
440
//
441
AP_Int8 rudder_only;
442
AP_Float mixing_gain;
443
AP_Int16 mixing_offset;
444
AP_Int16 dspoiler_rud_rate;
445
AP_Int32 log_bitmask;
446
AP_Float RTL_altitude;
447
AP_Float pitch_trim;
448
AP_Float cruise_alt_floor;
449
450
AP_Int8 flap_1_percent;
451
AP_Int8 flap_1_speed;
452
AP_Int8 flap_2_percent;
453
AP_Int8 flap_2_speed;
454
AP_Int8 takeoff_flap_percent;
455
AP_Enum<StickMixing> stick_mixing;
456
AP_Float takeoff_throttle_min_speed;
457
AP_Float takeoff_throttle_min_accel;
458
AP_Int8 takeoff_throttle_delay;
459
AP_Int8 takeoff_tdrag_elevator;
460
AP_Float takeoff_tdrag_speed1;
461
AP_Float takeoff_rotate_speed;
462
AP_Int8 takeoff_throttle_slewrate;
463
AP_Float takeoff_pitch_limit_reduction_sec;
464
AP_Int8 level_roll_limit;
465
#if AP_TERRAIN_AVAILABLE
466
AP_Int32 terrain_follow;
467
AP_Int16 terrain_lookahead;
468
#endif
469
AP_Int16 alt_slope_min;
470
AP_Float alt_slope_max_height;
471
AP_Int8 rangefinder_landing;
472
AP_Int8 flap_slewrate;
473
#if HAL_WITH_IO_MCU
474
AP_Int8 override_channel;
475
#endif
476
AP_Int16 gcs_pid_mask;
477
};
478
479
/*
480
2nd block of parameters, to avoid going past 256 top level keys
481
*/
482
class ParametersG2 {
483
public:
484
ParametersG2(void);
485
486
// var_info for holding Parameter information
487
static const struct AP_Param::GroupInfo var_info[];
488
489
// just to make compilation easier when all things are compiled out...
490
uint8_t unused_integer;
491
492
// button reporting library
493
#if HAL_BUTTON_ENABLED
494
AP_Button *button_ptr;
495
#endif
496
497
#if AP_ICENGINE_ENABLED
498
// internal combustion engine control
499
AP_ICEngine ice_control;
500
#endif
501
502
// RC input channels
503
RC_Channels_Plane rc_channels;
504
505
// control over servo output ranges
506
SRV_Channels servo_channels;
507
508
#if HAL_SOARING_ENABLED
509
// ArduSoar parameters
510
SoaringController soaring_controller;
511
#endif
512
513
// dual motor tailsitter rudder to differential thrust scaling: 0-100%
514
AP_Int8 rudd_dt_gain;
515
516
// mask of channels to do manual pass-thru for
517
AP_Int32 manual_rc_mask;
518
519
// home reset altitude threshold
520
AP_Int8 home_reset_threshold;
521
522
AP_Int32 flight_options;
523
524
AP_Int16 waypoint_climb_slope_height_min;
525
526
AP_Int8 takeoff_throttle_accel_count;
527
AP_Int8 takeoff_timeout;
528
529
#if AP_LANDINGGEAR_ENABLED
530
AP_LandingGear landing_gear;
531
#endif
532
533
#if AC_PRECLAND_ENABLED
534
AC_PrecLand precland;
535
#endif
536
537
// crow flaps weighting
538
AP_Int8 crow_flap_weight_outer;
539
AP_Int8 crow_flap_weight_inner;
540
AP_Int8 crow_flap_options;
541
AP_Int8 crow_flap_aileron_matching;
542
543
// Forward throttle battery voltage compensation
544
class FWD_BATT_CMP {
545
public:
546
// Calculate the throttle scale to compensate for battery voltage drop
547
void update();
548
549
// Apply throttle scale to min and max limits
550
void apply_min_max(int8_t &min_throttle, int8_t &max_throttle) const;
551
552
// Apply throttle scale to throttle demand
553
float apply_throttle(float throttle) const;
554
555
AP_Float batt_voltage_max;
556
AP_Float batt_voltage_min;
557
AP_Float batt_voltage_throttle_cutoff;
558
AP_Int8 batt_idx;
559
560
private:
561
bool enabled;
562
float ratio;
563
} fwd_batt_cmp;
564
565
566
#if AP_PLANE_OFFBOARD_GUIDED_SLEW_ENABLED
567
// guided yaw heading PID
568
AC_PID guidedHeading{5000.0, 0.0, 0.0, 0 , 10.0, 5.0, 5.0 , 5.0 , 0.0};
569
#endif
570
571
AP_Float guided_timeout;
572
573
#if AP_SCRIPTING_ENABLED && AP_FOLLOW_ENABLED
574
AP_Follow follow;
575
#endif
576
577
AP_Float fs_ekf_thresh;
578
579
// min initial climb in RTL
580
AP_Int16 rtl_climb_min;
581
582
AP_Int8 man_expo_roll;
583
AP_Int8 man_expo_pitch;
584
AP_Int8 man_expo_rudder;
585
586
AP_Int32 oneshot_mask;
587
588
AP_Int8 axis_bitmask; // axes to be autotuned
589
590
#if AP_RANGEFINDER_ENABLED
591
// orientation of rangefinder to use for landing
592
AP_Int8 rangefinder_land_orient;
593
#endif
594
595
#if AP_PLANE_SYSTEMID_ENABLED
596
AP_SystemID systemid;
597
#endif
598
};
599
600
extern const AP_Param::Info var_info[];
601
602