ekf2 0.1.0

Safe idiomatic Rust API for PX4 EKF2 navigation filter
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
use ekf2_sys as ffi;

use super::*;

impl<'a> ParamsMut<'a> {
    #[inline]
    pub fn set_gyro_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gyro_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_accel_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_gyro_bias_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gyro_bias_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_accel_bias_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_gyro_bias_init(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gyro_bias_init(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_init(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_accel_bias_init(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_tilt_error_init_rad(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_angerr_init(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_delay_max_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_delay_max(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_predict_interval_us(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_predict_us(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_ctrl_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_imu_ctrl(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_control(&mut self, v: ImuControl) {
        self.set_imu_ctrl_raw(v.bits());
    }

    #[inline]
    pub fn set_velocity_limit_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_vel_lim(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_position_sensor_ref_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_position_sensor_ref(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_position_sensor_ref(&mut self, v: PositionReference) {
        self.set_position_sensor_ref_raw(v as i32);
    }

    #[inline]
    pub fn set_no_aid_timeout_us(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_noaid_tout(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_no_aid_noise_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_noaid_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_heading_innov_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_hdg_gate(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_heading_noise_rad(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_head_noise(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_limit_m_s2(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_abl_lim(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_learning_accel_limit_m_s2(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_abl_acclim(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_learning_gyro_limit_rad_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_abl_gyrlim(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_accel_bias_learning_tau_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_abl_tau(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_gyro_bias_limit_rad_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gyr_b_lim(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_pos_body_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_imu_pos_body_x(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_pos_body_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_imu_pos_body_y(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_pos_body_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_imu_pos_body_z(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_imu_pos_body(&mut self, v: [f32; 3]) {
        self.set_imu_pos_body_x(v[0]);
        self.set_imu_pos_body_y(v[1]);
        self.set_imu_pos_body_z(v[2]);
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_baro_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_ctrl(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_baro_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_control(&mut self, v: BaroControl) {
        self.set_baro_ctrl(v as i32);
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_baro_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_innov_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_baro_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_baro_bias_nsd(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_baro_bias_nsd(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_ground_effect_deadzone_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gnd_eff_dz(self.ekf_ptr, v) }
    }

    #[cfg(feature = "barometer")]
    #[inline]
    pub fn set_ground_effect_max_hgt_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gnd_max_hgt(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_pcoef_xp(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_pcoef_xp(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_pcoef_xn(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_pcoef_xn(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_pcoef_yp(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_pcoef_yp(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_pcoef_yn(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_pcoef_yn(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_pcoef_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_pcoef_z(self.ekf_ptr, v) }
    }

    #[cfg(feature = "baro-compensation")]
    #[inline]
    pub fn set_baro_aspd_max_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_aspd_max(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_pos_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_vel_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_vel_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_pos_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_vel_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_vel_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_mode_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_gps_mode(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_mode(&mut self, v: GnssMode) {
        self.set_gps_mode_raw(v as i32);
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_body_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_pos_body_x(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_body_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_pos_body_y(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_body_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_pos_body_z(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_pos_body(&mut self, v: [f32; 3]) {
        self.set_gps_pos_body_x(v[0]);
        self.set_gps_pos_body_y(v[1]);
        self.set_gps_pos_body_z(v[2]);
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_hgt_bias_nsd(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gps_hgt_bias_nsd(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_ctrl(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_gps_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_control(&mut self, v: GnssControl) {
        self.set_gps_ctrl(v.bits());
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_check_mask(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_gps_check(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gps_check_control(&mut self, v: GnssCheckControl) {
        self.set_gps_check_mask(v.bits());
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_eph_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_eph(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_epv_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_epv(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_sacc_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_sacc(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_nsats(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_req_nsats(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_pdop(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_pdop(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_h_drift_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_hdrift(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_v_drift_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_req_vdrift(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_fix_type(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_req_fix(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_required_fix(&mut self, v: GnssFixType) {
        self.set_required_fix_type(v as i32);
    }

    #[cfg(feature = "gnss")]
    #[inline]
    pub fn set_gsf_tas_default_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gsf_tas(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gnss-yaw")]
    #[inline]
    pub fn set_gnss_heading_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_gnss_heading_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_declination_deg(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_decl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_innov_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_decl_type_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_decl_type(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_decl_type(&mut self, v: MagDeclinationControl) {
        self.set_mag_decl_type_raw(v.bits());
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_fusion_type_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_mag_type(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_fusion_type(&mut self, v: MagFusionType) {
        self.set_mag_fusion_type_raw(v as i32);
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_check_mask_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_mag_check(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_check_mask(&mut self, v: MagCheckControl) {
        self.set_mag_check_mask_raw(v.bits());
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_check_strength_gauss(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_chk_str(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_check_inclination_deg(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_chk_inc(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_earth_process_noise_gauss_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_e_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_body_process_noise_gauss_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_b_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_mag_accel_limit_m_s2(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mag_acclim(self.ekf_ptr, v) }
    }

    #[cfg(feature = "magnetometer")]
    #[inline]
    pub fn set_synthetic_mag_z_enabled(&mut self, enabled: bool) {
        unsafe { ffi::ekf2_param_set_synt_mag_z(self.ekf_ptr, enabled as i32) }
    }

    #[inline]
    pub fn set_hgt_ref_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_hgt_ref(self.ekf_ptr, v) }
    }

    #[inline]
    pub fn set_hgt_ref(&mut self, v: HeightReference) {
        self.set_hgt_ref_raw(v as i32);
    }

    #[cfg(feature = "airspeed")]
    #[inline]
    pub fn set_eas_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_eas_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "airspeed")]
    #[inline]
    pub fn set_airspeed_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_asp_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "airspeed")]
    #[inline]
    pub fn set_tas_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_tas_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "airspeed")]
    #[inline]
    pub fn set_airspeed_fusion_threshold_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_arsp_thr(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_ctrl_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_rng_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_ctrl(&mut self, v: RangeControl) {
        self.set_range_ctrl_raw(v as i32);
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_noise_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_pitch_rad(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_pitch(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_scale_per_meter(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_sfe(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_aid_max_hgt_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_a_hmax(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_aid_max_vel_m_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_a_vmax(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_quality_min_duration_s(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_qlty_t(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_kinematic_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_k_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_fog_distance_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_fog(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_pos_body_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_pos_body_x(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_pos_body_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_pos_body_y(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_pos_body_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_rng_pos_body_z(self.ekf_ptr, v) }
    }

    #[cfg(feature = "range-finder")]
    #[inline]
    pub fn set_range_pos_body(&mut self, v: [f32; 3]) {
        self.set_range_pos_body_x(v[0]);
        self.set_range_pos_body_y(v[1]);
        self.set_range_pos_body_z(v[2]);
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_ctrl_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_ev_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_ctrl(&mut self, v: ExternalVisionControl) {
        self.set_ev_ctrl_raw(v.bits());
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_ev_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_vel_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_evv_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_evp_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_att_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_eva_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_quality_min(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_ev_qmin(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_vel_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_evv_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_evp_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_hgt_bias_nsd(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_ev_hgt_bias_nsd(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_body_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_ev_pos_body_x(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_body_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_ev_pos_body_y(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_body_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_ev_pos_body_z(self.ekf_ptr, v) }
    }

    #[cfg(feature = "external-vision")]
    #[inline]
    pub fn set_ev_pos_body(&mut self, v: [f32; 3]) {
        self.set_ev_pos_body_x(v[0]);
        self.set_ev_pos_body_y(v[1]);
        self.set_ev_pos_body_z(v[2]);
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_ctrl_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_of_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_ctrl(&mut self, v: OpticalFlowControl) {
        self.set_of_ctrl_raw(v as i32);
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_gyro_source_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_of_gyr_src(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_gyro_source(&mut self, v: FlowGyroSource) {
        self.set_of_gyro_source_raw(v as i32);
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_of_delay(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_noise_min(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_of_n_min(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_noise_max(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_of_n_max(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_quality_min(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_of_qmin(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_quality_min_ground(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_of_qmin_gnd(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_of_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_of_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_flow_pos_body_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_flow_pos_body_x(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_flow_pos_body_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_flow_pos_body_y(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_flow_pos_body_z(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_flow_pos_body_z(self.ekf_ptr, v) }
    }

    #[cfg(feature = "optical-flow")]
    #[inline]
    pub fn set_flow_pos_body(&mut self, v: [f32; 3]) {
        self.set_flow_pos_body_x(v[0]);
        self.set_flow_pos_body_y(v[1]);
        self.set_flow_pos_body_z(v[2]);
    }

    #[cfg(feature = "wind")]
    #[inline]
    pub fn set_wind_nsd(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_wind_nsd(self.ekf_ptr, v) }
    }

    #[cfg(feature = "sideslip")]
    #[inline]
    pub fn set_sideslip_fusion_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_fuse_beta(self.ekf_ptr, v) }
    }

    #[cfg(feature = "sideslip")]
    #[inline]
    pub fn set_sideslip_fusion_enabled(&mut self, enabled: bool) {
        self.set_sideslip_fusion_raw(enabled as i32);
    }

    #[cfg(feature = "sideslip")]
    #[inline]
    pub fn set_sideslip_gate(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_beta_gate(self.ekf_ptr, v) }
    }

    #[cfg(feature = "sideslip")]
    #[inline]
    pub fn set_sideslip_noise_rad(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_beta_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "terrain")]
    #[inline]
    pub fn set_terrain_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_terr_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "terrain")]
    #[inline]
    pub fn set_terrain_gradient(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_terr_grad(self.ekf_ptr, v) }
    }

    #[cfg(any(
        feature = "terrain",
        feature = "range-finder",
        feature = "optical-flow"
    ))]
    #[inline]
    pub fn set_min_range_m(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_min_rng(self.ekf_ptr, v) }
    }

    #[cfg(feature = "gravity-fusion")]
    #[inline]
    pub fn set_gravity_noise_m_s2(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_grav_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_ctrl_raw(&mut self, v: i32) {
        unsafe { ffi::ekf2_param_set_drag_ctrl(self.ekf_ptr, v) }
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_fusion_enabled(&mut self, enabled: bool) {
        self.set_drag_ctrl_raw(enabled as i32);
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_noise(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_drag_noise(self.ekf_ptr, v) }
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_bcoef_x(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_bcoef_x(self.ekf_ptr, v) }
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_bcoef_y(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_bcoef_y(self.ekf_ptr, v) }
    }

    #[cfg(feature = "drag-fusion")]
    #[inline]
    pub fn set_drag_mcoef(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_mcoef(self.ekf_ptr, v) }
    }

    #[cfg(feature = "aux-vel")]
    #[inline]
    pub fn set_aux_vel_delay_ms(&mut self, v: f32) {
        unsafe { ffi::ekf2_param_set_avel_delay(self.ekf_ptr, v) }
    }
}