-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
309 lines (260 loc) · 11.4 KB
/
config.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
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
import pandas as pd
import numpy as np
from threading import Thread
import cv2
import os, sys
import time
import glob
from collections import defaultdict, namedtuple
import matplotlib.pyplot as plt
from itertools import chain, compress
from queue import Queue
# MSCKF config
class OptimizationConfigKITTI(object):
"""
Configuration parameters for 3d feature position optimization.
"""
def __init__(self):
self.translation_threshold = -1.0 # 0.2
self.huber_epsilon = 0.01
self.estimation_precision = 5e-7
self.initial_damping = 1e-3
self.outer_loop_max_iteration = 5 # 10
self.inner_loop_max_iteration = 5 # 10
# All configuration parameters
class ConfigKITTI(object):
def __init__(self):
# feature position optimization
self.optimization_config = OptimizationConfigKITTI()
## image processor
self.grid_row = 4
self.grid_col = 5
self.grid_num = self.grid_row * self.grid_col
self.grid_min_feature_num = 3
self.grid_max_feature_num = 5
self.fast_threshold = 15
self.ransac_threshold = 3
self.stereo_threshold = 5
self.max_iteration = 30
self.track_precision = 0.01
self.pyramid_levels = 3
self.patch_size = 15
self.win_size = (self.patch_size, self.patch_size)
self.lk_params = dict(
winSize=self.win_size,
maxLevel=self.pyramid_levels,
criteria=(
cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
self.max_iteration,
self.track_precision),
flags=cv2.OPTFLOW_USE_INITIAL_FLOW)
## msckf vio
# gravity
self.gravity_acc = 9.81
self.gravity = np.array([0.0, 0.0, -self.gravity_acc])
# Framte rate of the stereo images. This variable is only used to
# determine the timing threshold of each iteration of the filter.
self.frame_rate = 20
# Maximum number of camera states to be stored
self.max_cam_state_size = 20
# The position uncertainty threshold is used to determine
# when to reset the system online. Otherwise, the ever-increaseing
# uncertainty will make the estimation unstable.
# Note this online reset will be some dead-reckoning.
# Set this threshold to nonpositive to disable online reset.
self.position_std_threshold = 8.0
# Threshold for determine keyframes
self.rotation_threshold = 0.2618
self.translation_threshold = 0.4
self.tracking_rate_threshold = 0.5
# Noise related parameters (Use variance instead of standard deviation)
self.gyro_noise = 10.0 ** 2
self.acc_noise = 10.0 ** 2
self.gyro_bias_noise = 1e-5 ** 2
self.acc_bias_noise = 1e-5 ** 2
self.observation_noise = 0.035 ** 2
# initial state
self.velocity = np.zeros(3)
# The initial covariance of orientation and position can be
# set to 0. But for velocity, bias and extrinsic parameters,
# there should be nontrivial uncertainty.
self.velocity_cov = 0.25
self.gyro_bias_cov = 1e-5
self.acc_bias_cov = 1e-5
self.extrinsic_rotation_cov = 3.0462e-4
self.extrinsic_translation_cov = 2.5e-5
## calibration parameters
# T_imu_cam: takes a vector from the IMU frame to the cam frame.
# see https://github.com/ethz-asl/kalibr/wiki/yaml-formats
# TODO: update to correct KITTI transform
# self.T_imu_cam0 = np.array([
# [ 0.014865542981794, 0.999557249008346, -0.025774436697440, 0.065222909535531],
# [-0.999880929698575, 0.014967213324719, 0.003756188357967, -0.020706385492719],
# [ 0.004140296794224, 0.025715529947966, 0.999660727177902, -0.008054602460030],
# [ 0, 0, 0, 1.000000000000000]])
self.T_imu_cam0 = np.identity(4)
self.cam0_camera_model = 'pinhole'
self.cam0_distortion_model = 'radtan'
self.cam0_distortion_coeffs = np.array(
[0.0, 0.0, 0.0, 0.0])
self.cam0_intrinsics = np.array([718.856, 718.856, 607.1928, 185.2157])
self.cam0_resolution = np.array([1241, 376])
self.T_imu_body = np.identity(4)
class ConfigKITTI360(object):
def __init__(self):
# feature position optimization
self.optimization_config = OptimizationConfigKITTI()
## image processor
self.grid_row = 4
self.grid_col = 5
self.grid_num = self.grid_row * self.grid_col
self.grid_min_feature_num = 3
self.grid_max_feature_num = 5
self.fast_threshold = 15
self.ransac_threshold = 3
self.stereo_threshold = 5
self.max_iteration = 30
self.track_precision = 0.01
self.pyramid_levels = 3
self.patch_size = 15
self.win_size = (self.patch_size, self.patch_size)
self.lk_params = dict(
winSize=self.win_size,
maxLevel=self.pyramid_levels,
criteria=(
cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
self.max_iteration,
self.track_precision),
flags=cv2.OPTFLOW_USE_INITIAL_FLOW)
## msckf vio
# gravity
self.gravity_acc = 9.81
self.gravity = np.array([0.0, 0.0, -self.gravity_acc])
# Framte rate of the stereo images. This variable is only used to
# determine the timing threshold of each iteration of the filter.
self.frame_rate = 20
# Maximum number of camera states to be stored
self.max_cam_state_size = 20
# The position uncertainty threshold is used to determine
# when to reset the system online. Otherwise, the ever-increaseing
# uncertainty will make the estimation unstable.
# Note this online reset will be some dead-reckoning.
# Set this threshold to nonpositive to disable online reset.
self.position_std_threshold = 8.0
# Threshold for determine keyframes
self.rotation_threshold = 0.2618
self.translation_threshold = 0.4
self.tracking_rate_threshold = 0.5
# Noise related parameters (Use variance instead of standard deviation)
self.gyro_noise = 10.0 ** 2
self.acc_noise = 10.0 ** 2
self.gyro_bias_noise = 1e-5 ** 2
self.acc_bias_noise = 1e-5 ** 2
self.observation_noise = 0.035 ** 2
# initial state
self.velocity = np.zeros(3)
# The initial covariance of orientation and position can be
# set to 0. But for velocity, bias and extrinsic parameters,
# there should be nontrivial uncertainty.
self.velocity_cov = 0.25
self.gyro_bias_cov = 1e-5
self.acc_bias_cov = 1e-5
self.extrinsic_rotation_cov = 3.0462e-4
self.extrinsic_translation_cov = 2.5e-5
## calibration parameters
# T_imu_cam: takes a vector from the IMU frame to the cam frame.
# see https://github.com/ethz-asl/kalibr/wiki/yaml-formats
# TODO: update to correct KITTI transform
self.T_cam0_imu = np.array([
[ 0.0, -1.0, 0.0, 0.0],
[1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])
self.T_imu_cam0 = np.linalg.inv(self.T_cam0_imu)
self.cam0_camera_model = 'pinhole'
self.cam0_distortion_model = 'radtan'
self.cam0_distortion_coeffs = np.array(
[0.0, 0.0, 0.0, 0.0])
self.cam0_intrinsics = np.array([552.554261, 552.554261, 682.049453, 238.769549])
self.cam0_resolution = np.array([1392, 512])
self.T_imu_body = np.identity(4)
class ConfigHKMedUrban(object):
def __init__(self):
# feature position optimization
self.optimization_config = OptimizationConfigKITTI()
## image processor
self.grid_row = 4
self.grid_col = 5
self.grid_num = self.grid_row * self.grid_col
self.grid_min_feature_num = 3
self.grid_max_feature_num = 5
self.fast_threshold = 15
self.ransac_threshold = 3
self.stereo_threshold = 5
self.max_iteration = 30
self.track_precision = 0.01
self.pyramid_levels = 3
self.patch_size = 15
self.win_size = (self.patch_size, self.patch_size)
self.lk_params = dict(
winSize=self.win_size,
maxLevel=self.pyramid_levels,
criteria=(
cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT,
self.max_iteration,
self.track_precision),
flags=cv2.OPTFLOW_USE_INITIAL_FLOW)
## msckf vio
# gravity
self.gravity_acc = 9.81
self.gravity = np.array([0.0, 0.0, -self.gravity_acc])
# Framte rate of the stereo images. This variable is only used to
# determine the timing threshold of each iteration of the filter.
self.frame_rate = 20
# Maximum number of camera states to be stored
self.max_cam_state_size = 20
# The position uncertainty threshold is used to determine
# when to reset the system online. Otherwise, the ever-increaseing
# uncertainty will make the estimation unstable.
# Note this online reset will be some dead-reckoning.
# Set this threshold to nonpositive to disable online reset.
self.position_std_threshold = 8.0
# Threshold for determine keyframes
self.rotation_threshold = 0.2618
self.translation_threshold = 0.4
self.tracking_rate_threshold = 0.5
# Noise related parameters (Use variance instead of standard deviation)
self.gyro_noise = 10.0 ** 2
self.acc_noise = 10.0 ** 2
self.gyro_bias_noise = 1e-5 ** 2
self.acc_bias_noise = 1e-5 ** 2
self.observation_noise = 0.035 ** 2
# initial state
self.velocity = np.zeros(3)
# The initial covariance of orientation and position can be
# set to 0. But for velocity, bias and extrinsic parameters,
# there should be nontrivial uncertainty.
self.velocity_cov = 0.25
self.gyro_bias_cov = 1e-5
self.acc_bias_cov = 1e-5
self.extrinsic_rotation_cov = 3.0462e-4
self.extrinsic_translation_cov = 2.5e-5
## calibration parameters
# T_imu_cam: takes a vector from the IMU frame to the cam frame.
# see https://github.com/ethz-asl/kalibr/wiki/yaml-formats
# TODO: update to correct KITTI transform
self.T_cam0_imu = np.array([
[9.9885234402635936e-01, 1.3591158885981787e-03, 4.7876378696062108e-02, -8.4994249456545504e-02],
[-4.7864188349269129e-02, -7.9091258538426246e-03,
9.9882253939420773e-01, 6.6169337079143220e-01],
[1.7361758877140372e-03, -9.9996779874765440e-01,
-7.8349959194297103e-03, -3.0104266183335913e+00],
[0.0, 0.0, 0.0, 1.0]])
self.T_imu_cam0 = np.linalg.inv(self.T_cam0_imu)
self.cam0_camera_model = 'pinhole'
self.cam0_distortion_model = 'radtan'
self.cam0_distortion_coeffs = np.array(
[-0.0442856, 0.0133574, 0.0, 0.0])
self.cam0_intrinsics = np.array([264.9425, 264.79, 334.3975, 183.162])
self.cam0_resolution = np.array([672, 376])
self.T_imu_body = np.identity(4)