forked from zzy0713/VINS-GPS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathestimator.h
134 lines (103 loc) · 3.22 KB
/
estimator.h
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
//
// Created by grn on 11/5/18.
//
#ifndef VINS_ESTIMATOR_H
#define VINS_ESTIMATOR_H
#include "parameters.h"
#include "feature_manager.h"
#include "utility/utility.h"
#include "utility/tic_toc.h"
#include "Coosys.h"
#include "initial/solve_5pts.h"
#include "initial/initial_sfm.h"
#include "initial/initial_alignment.h"
#include "initial/initial_ex_rotation.h"
#include "msgg/Header.h"
#include "msgg/Float32.h"
#include <ceres/ceres.h>
#include "factor/gps_factor.h"
#include "factor/imu_factor.h"
#include "factor/pose_local_parameterization.h"
#include "factor/projection_factor.h"
#include "factor/projection_td_factor.h"
#include <unordered_map>
#include <queue>
#include <opencv2/core/eigen.hpp>
class Estimator
{
public:
Estimator();
void setParameter();
// interface
void processIMU(double t, const Vector3d &linear_acceleration, const Vector3d &angular_velocity);
void processImage(const map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> &image, const std_msgs::Header &header);
// internal
void clearState();
bool initialStructure();
bool visualInitialAlign();
bool relativePose(Matrix3d &relative_R, Vector3d &relative_T, int &l);
void slideWindow();
void solveOdometry();
void slideWindowNew();
void slideWindowOld();
void optimization();
void vector2double();
void double2vector();
bool failureDetection();
enum SolverFlag
{
INITIAL,
NON_LINEAR
};
enum MarginalizationFlag
{
MARGIN_OLD = 0,
MARGIN_SECOND_NEW = 1
};
SolverFlag solver_flag;
MarginalizationFlag marginalization_flag;
Vector3d g;
MatrixXd Ap[2], backup_A;
VectorXd bp[2], backup_b;
Matrix3d ric[NUM_OF_CAM];
Vector3d tic[NUM_OF_CAM];
Vector3d Ps[(WINDOW_SIZE + 1)];
Vector3d Vs[(WINDOW_SIZE + 1)];
Matrix3d Rs[(WINDOW_SIZE + 1)];
Vector3d Bas[(WINDOW_SIZE + 1)];
Vector3d Bgs[(WINDOW_SIZE + 1)];
double td;
Matrix3d back_R0, last_R, last_R0;
Vector3d back_P0, last_P, last_P0;
std_msgs::Header Headers[(WINDOW_SIZE + 1)];
IntegrationBase *pre_integrations[(WINDOW_SIZE + 1)];
Vector3d acc_0, gyr_0;
vector<double> dt_buf[(WINDOW_SIZE + 1)];
vector<Vector3d> linear_acceleration_buf[(WINDOW_SIZE + 1)];
vector<Vector3d> angular_velocity_buf[(WINDOW_SIZE + 1)];
int frame_count;
int sum_of_outlier, sum_of_back, sum_of_front, sum_of_invalid;
FeatureManager f_manager;
MotionEstimator m_estimator;
InitialEXRotation initial_ex_rotation;
bool first_imu;
bool is_valid, is_key;
bool failure_occur;
vector<Vector3d> point_cloud;
vector<Vector3d> margin_cloud;
vector<Vector3d> key_poses;
double initial_timestamp;
double fir_gps[3]={0.0};
double para_Pose[WINDOW_SIZE + 1][SIZE_POSE];
double para_SpeedBias[WINDOW_SIZE + 1][SIZE_SPEEDBIAS];
double para_Feature[NUM_OF_F][SIZE_FEATURE];
double para_Ex_Pose[NUM_OF_CAM][SIZE_POSE];
double para_Retrive_Pose[SIZE_POSE];
double para_Td[1][1];
double para_Tr[1][1];
int loop_window_index;
vector<gps_struct> gpsvec;
map<double, ImageFrame> all_image_frame;
IntegrationBase *tmp_pre_integration;
};
#endif //VINS_ESTIMATOR_H