Skip to content

Commit 536ad4d

Browse files
committed
add range finder consistency replay script
uses RangeFinderConsistencyCheck class on flight data from .ulg log file
1 parent 8810136 commit 536ad4d

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
File: range_finder_consistency_check.py
6+
Author: Mathieu Bresciani
7+
Email: brescianimathieu@gmail.com
8+
Github: https://github.com/bresch
9+
Description:
10+
"""
11+
12+
import numpy as np
13+
import matplotlib.pylab as plt
14+
from data_extractor import getAllData
15+
from RangeFinderConsistencyCheck import RangeFinderConsistencyCheck
16+
17+
def run(logfile):
18+
(t, rng, vz, vz_var) = getAllData(logfile)
19+
20+
rng_kin = RangeFinderConsistencyCheck()
21+
rng_kin._vel_bottom_gate = 0.2
22+
23+
n = len(t)
24+
inn = [0.0]
25+
rng_var = [0.0]
26+
test_ratio = [0.0]
27+
signed_test_ratio_lpf = [0.0]
28+
is_consistent = [False]
29+
30+
for k in range(1, n):
31+
rng_var.append(0.1**2 + (0.05*rng[k])**2)
32+
rng_kin.update(rng[k], rng_var[k], vz[k], vz_var[k], t[k]*1e6)
33+
inn.append(rng_kin.getInnov())
34+
test_ratio.append(rng_kin._vel_bottom_test_ratio)
35+
signed_test_ratio_lpf.append(rng_kin.getSignedTestRatioLpf())
36+
is_consistent.append(rng_kin.isKinematicallyConsistent())
37+
38+
plotData(t, rng, rng_var, is_consistent, vz, inn, test_ratio, signed_test_ratio_lpf)
39+
40+
def plotData(t, rng, rng_var, is_consistent, vz, inn, test_ratio, signed_test_ratio_lpf):
41+
n_plots = 4
42+
ax1 = plt.subplot(n_plots, 1, 1)
43+
ax1.plot(t, rng)
44+
ax1.plot(t, rng+np.sqrt(rng_var), 'r--')
45+
ax1.plot(t, rng-np.sqrt(rng_var), 'r--')
46+
ax1.legend(["rng"])
47+
ax1.grid()
48+
49+
ax2 = plt.subplot(n_plots, 1, 2, sharex=ax1)
50+
ax2.plot(t, test_ratio)
51+
ax2.plot(t, signed_test_ratio_lpf)
52+
ax2.legend(["test_ratio", "signed_test_ratio_lpf"])
53+
ax2.set_ylim(-5, 5)
54+
ax2.grid()
55+
56+
ax3 = plt.subplot(n_plots, 1, 3, sharex=ax1)
57+
ax3.plot(t, vz)
58+
ax3.plot(t, vz+inn)
59+
ax3.set_ylim(-5, 5)
60+
ax3.legend(["vz", "rng_dot"])
61+
62+
ax4 = plt.subplot(n_plots, 1, 4, sharex=ax1)
63+
ax4.plot(t, is_consistent)
64+
ax4.legend(["is_consistent"])
65+
66+
plt.show()
67+
68+
if __name__ == '__main__':
69+
import os
70+
import argparse
71+
72+
# Get the path of this script (without file name)
73+
script_path = os.path.split(os.path.realpath(__file__))[0]
74+
75+
# Parse arguments
76+
parser = argparse.ArgumentParser(
77+
description='Estimate mag biases from ULog file')
78+
79+
# Provide parameter file path and name
80+
parser.add_argument('logfile', help='Full ulog file path, name and extension', type=str)
81+
args = parser.parse_args()
82+
83+
logfile = os.path.abspath(args.logfile) # Convert to absolute path
84+
85+
run(logfile)

0 commit comments

Comments
 (0)