Commit 74d13e2 1 parent b5c8c55 commit 74d13e2 Copy full SHA for 74d13e2
File tree 3 files changed +17
-8
lines changed
3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -94,16 +94,16 @@ class Accumulator {
94
94
template <typename ContentType>
95
95
ContentType get_prev (Buffer<ContentType>& source, double t) {
96
96
int k_t = before_t (source, t) + 1 ;
97
+ if (k_t >= source.content .size ()) k_t = source.content .size () - 1 ;
97
98
98
- // Get leftest State right to t (sorted new to old)
99
- for (int k = k_t ; k < source. content . size (); ++ k) {
99
+ // Get leftest (newest) content right (previous) to t (sorted new to old)
100
+ for (int k = k_t ; k >= 0 ; -- k) {
100
101
ContentType cnt = source.content [k];
101
102
if (t > cnt.time ) return cnt;
102
103
}
103
104
104
- // If not a state found, push an empty one at t
105
- this ->add (ContentType (), t);
106
- return source.front ();
105
+ // If not a content found, push an empty one at t
106
+ return ContentType ();
107
107
}
108
108
109
109
// Process LiDAR pointcloud message
Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ extern struct Params Config;
72
72
// ///////////////////////////////
73
73
74
74
State Accumulator::get_prev_state (double t) {
75
+ if (this ->BUFFER_X .empty ()) {
76
+ State X = Localizator::getInstance ().latest_state ();
77
+ Accumulator::getInstance ().add (X, t);
78
+ X.time = t;
79
+ return X;
80
+ }
81
+
75
82
return this ->get_prev (this ->BUFFER_X , t);
76
83
}
77
84
Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ extern struct Params Config;
64
64
// Initialize
65
65
if (not this ->initialized ) {
66
66
if (imus.empty ()) return ;
67
- IMU initial_IMU = IMU (); // imus.back();
68
- // IMU initial_IMU = imus.back();
67
+ IMU initial_IMU = imus.back ();
69
68
this ->initialize (initial_IMU);
70
69
}
71
70
@@ -85,7 +84,10 @@ extern struct Params Config;
85
84
State Localizator::latest_state () {
86
85
// If no integrated, return empty state
87
86
if (this ->last_time_integrated < 0 )
88
- return State (Accumulator::getInstance ().initial_time );
87
+ return State (
88
+ this ->get_x (),
89
+ Accumulator::getInstance ().initial_time
90
+ );
89
91
90
92
// If no updates, return integrated state
91
93
if (this ->last_time_updated < 0 )
You can’t perform that action at this time.
0 commit comments