-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuning.py
101 lines (93 loc) · 3.22 KB
/
tuning.py
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
import numpy as np
# Common initial state covariance parameters
def get_P0(scale: float = 100.0) -> np.ndarray:
"""Get initial state covariance matrix"""
base_values = np.array([
0.4, # xi_g position
0.4, # eta_g position
0.06, # theta_g heading
0.25, # xi_a position
0.25, # eta_a position
0.06 # theta_a heading
])
return scale * np.diag(base_values**2)
# LKF Parameters
def get_LKF_Q() -> np.ndarray:
"""Get LKF process noise covariance matrix - increased uncertainty"""
return np.diag([
0.45**2, # xi_g noise - increased
0.45**2, # eta_g noise - increased
1.2**2, # theta_g noise - significantly increased
0.35**2, # xi_a noise - slightly increased
0.35**2, # eta_a noise - slightly increased
1.0**2 # theta_a noise - slightly increased
])
def get_LKF_R() -> np.ndarray:
"""Get LKF measurement noise covariance matrix - increased uncertainty"""
return np.diag([
0.08**2, # azimuth_g noise - increased
10.0**2, # range noise - increased
0.08**2, # azimuth_a noise - increased
7.0**2, # xi_a GPS noise - increased
7.0**2 # eta_a GPS noise - increased
])
# EKF Parameters
def get_EKF_Q() -> np.ndarray:
"""Get EKF process noise covariance matrix"""
return np.diag([
0.03**2, # xi_g noise - matched to LKF
0.03**2, # eta_g noise
0.1**2, # theta_g noise
0.025**2, # xi_a noise
0.025**2, # eta_a noise
0.08**2 # theta_a noise
])
def get_EKF_R() -> np.ndarray:
"""Get EKF measurement noise covariance matrix"""
return np.diag([
0.02**2, # azimuth_g noise
4.0**2, # range noise
0.02**2, # azimuth_a noise
3.0**2, # xi_a GPS noise
3.0**2 # eta_a GPS noise
])
# Noise generator parameters
def get_state_noise_std() -> np.ndarray:
"""Get state noise standard deviations"""
return np.array([
0.3, # xi_g noise
0.3, # eta_g noise
0.15, # theta_g noise (radians)
0.3, # xi_a noise
0.3, # eta_a noise
0.15 # theta_a noise (radians)
])
def get_meas_noise_std() -> np.ndarray:
"""Get measurement noise standard deviations"""
return np.array([
0.02, # azimuth_g noise (radians)
8.0, # range noise (meters)
0.02, # azimuth_a noise (radians)
6.0, # xi_a GPS noise (meters)
6.0 # eta_a GPS noise (meters)
])
# UKF Parameters
def get_UKF_Q() -> np.ndarray:
"""Get UKF process noise covariance matrix"""
return np.diag([
0.015, # xi_g noise - even tighter
0.015, # eta_g noise
0.05, # theta_g noise - much tighter heading
0.01, # xi_a noise - very tight for UAV
0.01, # eta_a noise
0.05 # theta_a noise
])**2
def get_UKF_R() -> np.ndarray:
"""Get UKF measurement noise covariance matrix"""
return np.diag([
0.01**2, # azimuth_g noise - trust angles even more
2.0**2, # range noise - trust range more
0.01**2, # azimuth_a noise
1.0**2, # xi_a GPS noise - very tight
1.0**2 # eta_a GPS noise
])