127 {
128 float distance_traveled_in_meter = velocity * time_diff;
129 float vehicle_yaw_changed = yaw_rate * time_diff;
130
131
132
133
134
135
136 if (!IsTravelingStraight(vehicle_yaw_changed)) {
137 AINFO <<
"Do not calibate if not moving straight: "
138 << "yaw angle changed " << vehicle_yaw_changed;
139 vp_buffer_.clear();
140 return false;
141 }
142
143 VanishingPoint vp_cur;
144 VanishingPoint vp_work;
145
146
147 if (!GetVanishingPoint(lane, &vp_cur)) {
148 AINFO <<
"Lane is not valid for calibration.";
149 return false;
150 }
151 vp_cur.distance_traveled = distance_traveled_in_meter;
152
153
154
155 PushVanishingPoint(vp_cur);
156 if (!PopVanishingPoint(&vp_work)) {
157 AINFO <<
"Driving distance is not long enough";
158 return false;
159 }
160
161
162 pitch_cur_ = 0.0f;
163 if (!GetPitchFromVanishingPoint(vp_work, &pitch_cur_)) {
164 AINFO <<
"Failed to estimate pitch from vanishing point.";
165 return false;
166 }
167
168 vanishing_row_ = vp_work.pixel_pos[1];
169
170
171 if (!AddPitchToHistogram(pitch_cur_)) {
172 AINFO <<
"Calculated pitch is out-of-range.";
173 return false;
174 }
175
176 accumulated_straight_driving_in_meter_ += distance_traveled_in_meter;
177
178 if (accumulated_straight_driving_in_meter_ >
182 const float cy = k_mat_[5];
183 const float fy = k_mat_[4];
184 vanishing_row_ = tanf(pitch_estimation_) * fy + cy;
185 accumulated_straight_driving_in_meter_ = 0.0f;
186 return true;
187 }
188 return false;
189}
float get_val_estimation() const
float min_distance_to_update_calibration_in_meter