@@ -33,9 +33,7 @@ void Estimator::clearState()
33
33
angular_velocity_buf[i].clear ();
34
34
35
35
if (pre_integrations[i] != nullptr )
36
- {
37
36
delete pre_integrations[i];
38
- }
39
37
pre_integrations[i] = nullptr ;
40
38
}
41
39
@@ -45,6 +43,15 @@ void Estimator::clearState()
45
43
ric[i] = Matrix3d::Identity ();
46
44
}
47
45
46
+ for (auto &it : all_image_frame)
47
+ {
48
+ if (it.second .pre_integration != nullptr )
49
+ {
50
+ delete it.second .pre_integration ;
51
+ it.second .pre_integration = nullptr ;
52
+ }
53
+ }
54
+
48
55
solver_flag = INITIAL;
49
56
first_imu = false ,
50
57
sum_of_back = 0 ;
@@ -1000,6 +1007,7 @@ void Estimator::slideWindow()
1000
1007
TicToc t_margin;
1001
1008
if (marginalization_flag == MARGIN_OLD)
1002
1009
{
1010
+ double t_0 = Headers[0 ].stamp .toSec ();
1003
1011
back_R0 = Rs[0 ];
1004
1012
back_P0 = Ps[0 ];
1005
1013
if (frame_count == WINDOW_SIZE)
@@ -1036,11 +1044,20 @@ void Estimator::slideWindow()
1036
1044
1037
1045
if (true || solver_flag == INITIAL)
1038
1046
{
1039
- double t_0 = Headers[0 ].stamp .toSec ();
1040
1047
map<double , ImageFrame>::iterator it_0;
1041
1048
it_0 = all_image_frame.find (t_0);
1042
1049
delete it_0->second .pre_integration ;
1050
+ it_0->second .pre_integration = nullptr ;
1051
+
1052
+ for (map<double , ImageFrame>::iterator it = all_image_frame.begin (); it != it_0; ++it)
1053
+ {
1054
+ if (it->second .pre_integration )
1055
+ delete it->second .pre_integration ;
1056
+ it->second .pre_integration = NULL ;
1057
+ }
1058
+
1043
1059
all_image_frame.erase (all_image_frame.begin (), it_0);
1060
+ all_image_frame.erase (t_0);
1044
1061
1045
1062
}
1046
1063
slideWindowOld ();
0 commit comments