Apollo 10.0
自动驾驶开放平台
lane_based_calibrator.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <deque>
19#include <utility>
20
24
25namespace apollo {
26namespace perception {
27namespace camera {
28
29const float kYawRateDefault = 0.0f;
30const float kVelocityDefault = 8.333f; // m/s
31const float kTimeDiffDefault = 0.067f; // in seconds, 15FPS
32
33void GetYawVelocityInfo(const float &time_diff, const double cam_coord_cur[3],
34 const double cam_coord_pre[3],
35 const double cam_coord_pre_pre[3], float *yaw_rate,
36 float *velocity);
37
65
67 int image_width = 0;
68 int image_height = 0;
69 float focal_x = 0.0f;
70 float focal_y = 0.0f;
71 float cx = 0.0f;
72 float cy = 0.0f;
73};
74
76 public:
77 static const int kMaxNrHistoryFrames = 1000;
78
79 LaneBasedCalibrator() { vp_buffer_.clear(); }
80
82
83 void Init(const LocalCalibratorInitOptions &options,
84 const CalibratorParams *params = nullptr);
85
86 void ClearUp();
87
88 // Main function. process every frame, return true if get valid
89 // estimation. suppose the points in lane are already sorted.
90 bool Process(const EgoLane &lane, const float &velocity,
91 const float &yaw_rate, const float &time_diff);
92
93 float get_pitch_estimation() const { return pitch_estimation_; }
94
95 // float get_pitch_cur() const {
96 // return pitch_cur_;
97 // }
98
99 float get_vanishing_row() const { return vanishing_row_; }
100
101 // float get_accumulated_straight_driving_in_meter() const {
102 // return accumulated_straight_driving_in_meter_;
103 // }
104
105 private:
106 bool is_in_image(const Eigen::Vector2f &point) const {
107 int x = algorithm::IRound(point(0));
108 int y = algorithm::IRound(point(1));
109 bool is_in_image =
110 x >= 0 && x < image_width_ && y >= 0 && y < image_height_;
111 return (is_in_image);
112 }
113
114 bool IsTravelingStraight(const float &vehicle_yaw_changed) const {
115 float abs_yaw = static_cast<float>(fabs(vehicle_yaw_changed));
116 return abs_yaw < params_.max_allowed_yaw_angle_in_radian;
117 }
118
119 bool GetVanishingPoint(const EgoLane &lane, VanishingPoint *v_point);
120
121 int GetCenterIndex(const Eigen::Vector2f *points, int nr_pts) const;
122
123 bool SelectTwoPointsFromLineForVanishingPoint(const LaneLine &line,
124 float line_seg[4]);
125
126 bool GetIntersectionFromTwoLineSegments(const float line_seg_l[4],
127 const float line_seg_r[4],
128 VanishingPoint *v_point);
129
130 void PushVanishingPoint(const VanishingPoint &v_point);
131
132 bool PopVanishingPoint(VanishingPoint *v_point);
133
134 bool GetPitchFromVanishingPoint(const VanishingPoint &vp, float *pitch) const;
135
136 bool AddPitchToHistogram(float pitch);
137
138 private:
139 int image_width_ = 0;
140 int image_height_ = 0;
141 float k_mat_[9] = {0};
142 float pitch_cur_ = 0.0f;
143 float pitch_estimation_ = 0.0f;
144 float vanishing_row_ = 0.0f;
145 float accumulated_straight_driving_in_meter_ = 0.0f;
146
147 // EgoLane lane_;
148 HistogramEstimator pitch_histogram_;
149 std::deque<VanishingPoint> vp_buffer_;
150 CalibratorParams params_;
151};
152
153} // namespace camera
154} // namespace perception
155} // namespace apollo
bool Process(const EgoLane &lane, const float &velocity, const float &yaw_rate, const float &time_diff)
void Init(const LocalCalibratorInitOptions &options, const CalibratorParams *params=nullptr)
void GetYawVelocityInfo(const float &time_diff, const double cam_coord_cur[3], const double cam_coord_pre[3], const double cam_coord_pre_pre[3], float *yaw_rate, float *velocity)
class register implement
Definition arena_queue.h:37
void operator=(const CalibratorParams &params)