Apollo 11.0
自动驾驶开放平台
apollo::planning::IterativeAnchoringSmoother类 参考

#include <iterative_anchoring_smoother.h>

apollo::planning::IterativeAnchoringSmoother 的协作图:

Public 成员函数

 IterativeAnchoringSmoother (const PlannerOpenSpaceConfig &planner_open_space_config)
 
 ~IterativeAnchoringSmoother ()=default
 
bool Smooth (const Eigen::MatrixXd &xWS, const double init_a, const double init_v, const std::vector< std::vector< common::math::Vec2d > > &obstacles_vertices_vec, DiscretizedTrajectory *discretized_trajectory)
 
 IterativeAnchoringSmoother (const IterativeAnchoringConfig &iterative_anchoring_config)
 

Public 属性

std::vector< std::vector< common::math::Vec2d > > box_vec_
 
std::vector< std::vector< std::vector< common::math::Vec2d > > > box_vec_vec_
 

详细描述

在文件 iterative_anchoring_smoother.h 第 43 行定义.

构造及析构函数说明

◆ IterativeAnchoringSmoother() [1/2]

apollo::planning::IterativeAnchoringSmoother::IterativeAnchoringSmoother ( const PlannerOpenSpaceConfig &  planner_open_space_config)

在文件 iterative_anchoring_smoother.cc 第 47 行定义.

47 {
48 // TODO(Jinyun, Yu): refactor after stabilized.
49 const auto& vehicle_param = common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param();
50 ego_length_ = vehicle_param.length();
51 ego_width_ = vehicle_param.width();
52 center_shift_distance_ = ego_length_ / 2.0 - vehicle_param.back_edge_to_center();
53 planner_open_space_config_ = planner_open_space_config;
54 iterative_anchoring_config_ = planner_open_space_config_.iterative_anchoring_smoother_config();
55 AINFO << "config:" << planner_open_space_config_.DebugString();
56}
#define AINFO
Definition log.h:42
optional IterativeAnchoringConfig iterative_anchoring_smoother_config

◆ ~IterativeAnchoringSmoother()

apollo::planning::IterativeAnchoringSmoother::~IterativeAnchoringSmoother ( )
default

◆ IterativeAnchoringSmoother() [2/2]

apollo::planning::IterativeAnchoringSmoother::IterativeAnchoringSmoother ( const IterativeAnchoringConfig &  iterative_anchoring_config)
explicit

在文件 iterative_anchoring_smoother.cc 第 58 行定义.

58 {
59 // TODO(Jinyun, Yu): refactor after stabilized.
60 const auto& vehicle_param = common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param();
61 ego_length_ = vehicle_param.length();
62 ego_width_ = vehicle_param.width();
63 center_shift_distance_ = ego_length_ / 2.0 - vehicle_param.back_edge_to_center();
64 iterative_anchoring_config_ = iterative_anchoring_config;
65 AINFO << "config:" << iterative_anchoring_config_.DebugString();
66}

成员函数说明

◆ Smooth()

bool apollo::planning::IterativeAnchoringSmoother::Smooth ( const Eigen::MatrixXd &  xWS,
const double  init_a,
const double  init_v,
const std::vector< std::vector< common::math::Vec2d > > &  obstacles_vertices_vec,
DiscretizedTrajectory *  discretized_trajectory 
)

在文件 iterative_anchoring_smoother.cc 第 68 行定义.

73 {
74 if (xWS.cols() < 2) {
75 AERROR << "reference points size smaller than two, smoother early "
76 "returned";
77 return false;
78 }
79 const auto start_timestamp = std::chrono::system_clock::now();
80
81 // Set gear of the trajectory
82 gear_ = CheckGear(xWS);
83
84 // Set obstacle in form of linesegments
85 std::vector<std::vector<LineSegment2d>> obstacles_linesegments_vec;
86 for (const auto& obstacle_vertices : obstacles_vertices_vec) {
87 size_t vertices_num = obstacle_vertices.size();
88 std::vector<LineSegment2d> obstacle_linesegments;
89 for (size_t i = 0; i + 1 < vertices_num; ++i) {
90 LineSegment2d line_segment = LineSegment2d(obstacle_vertices[i], obstacle_vertices[i + 1]);
91 obstacle_linesegments.emplace_back(line_segment);
92 }
93 obstacles_linesegments_vec.emplace_back(obstacle_linesegments);
94 }
95 obstacles_linesegments_vec_ = std::move(obstacles_linesegments_vec);
96
97 // Interpolate the traj
98 DiscretizedPath warm_start_path;
99 size_t xWS_size = xWS.cols();
100 double accumulated_s = 0.0;
101 Vec2d last_path_point(xWS(0, 0), xWS(1, 0));
102 for (size_t i = 0; i < xWS_size; ++i) {
103 Vec2d cur_path_point(xWS(0, i), xWS(1, i));
104 accumulated_s += cur_path_point.DistanceTo(last_path_point);
105 PathPoint path_point;
106 path_point.set_x(xWS(0, i));
107 path_point.set_y(xWS(1, i));
108 path_point.set_theta(xWS(2, i));
109 path_point.set_s(accumulated_s);
110 warm_start_path.push_back(std::move(path_point));
111 last_path_point = cur_path_point;
112 }
113 if (std::fabs(accumulated_s) < 0.1) {
114 AERROR << "warm_start_path smaller than 0.1 m, can't enforce "
115 "heading continuity";
116 return false;
117 }
118
119 const double interpolated_delta_s = iterative_anchoring_config_.interpolated_delta_s();
120 std::vector<std::pair<double, double>> interpolated_warm_start_point2ds;
121 double path_length = warm_start_path.Length();
122 int count = std::ceil(path_length / interpolated_delta_s);
123 double delta_s = path_length / (count < 4 ? 4 : count);
124 path_length += delta_s * 1.0e-6;
125 for (double s = 0; s < path_length; s += delta_s) {
126 const auto point2d = warm_start_path.Evaluate(s);
127 interpolated_warm_start_point2ds.emplace_back(point2d.x(), point2d.y());
128 }
129
130 const size_t interpolated_size = interpolated_warm_start_point2ds.size();
131 if (interpolated_size < 6) {
132 ADEBUG << "interpolated_warm_start_path smaller than 4, can't enforce "
133 "initial zero kappa";
134 enforce_initial_kappa_ = false;
135 } else {
136 enforce_initial_kappa_ = true;
137 }
138
139 // Adjust heading to ensure heading continuity
140 AdjustStartEndHeading(xWS, &interpolated_warm_start_point2ds);
141
142 // Reset path profile by discrete point heading and curvature estimation
143 DiscretizedPath interpolated_warm_start_path;
144 if (!SetPathProfile(interpolated_warm_start_point2ds, &interpolated_warm_start_path)) {
145 AERROR << "Set path profile fails";
146 return false;
147 }
148
149 // Generate feasible bounds for each path point
150 std::vector<double> bounds;
151 if (!GenerateInitialBounds(interpolated_warm_start_path, &bounds)) {
152 AERROR << "Generate initial bounds failed, path point to close to obstacle";
153 return false;
154 }
155
156 // Check initial path collision avoidance, if it fails, smoother assumption
157 // fails. Try reanchoring
158 input_colliding_point_index_.clear();
159 if (!CheckCollisionAvoidance(interpolated_warm_start_path, &input_colliding_point_index_)) {
160 AERROR << "Interpolated input path points colliding with obstacle";
161 // if (!ReAnchoring(colliding_point_index, &interpolated_warm_start_path)) {
162 // AERROR << "Fail to reanchor colliding input path points";
163 // return false;
164 // }
165 }
166
167 const auto path_smooth_start_timestamp = std::chrono::system_clock::now();
168
169 // Smooth path to have smoothed x, y, phi, kappa and s
170 DiscretizedPath smoothed_path_points;
171 if (!SmoothPath(interpolated_warm_start_path, bounds, &smoothed_path_points)) {
172 return false;
173 }
174 // PrintCurves print_curve;
175 // for (size_t i = 0; i < smoothed_path_points.size(); i++) {
176 // print_curve.AddPoint("iter_smoothed_xy", smoothed_path_points[i].x(),
177 // smoothed_path_points[i].y());
178 // print_curve.AddPoint("iter_smoothed_s-kappa",
179 // smoothed_path_points[i].s(),
180 // smoothed_path_points[i].kappa());
181 // print_curve.AddPoint("iter_smoothed_s-theta",
182 // smoothed_path_points[i].s(),
183 // smoothed_path_points[i].theta());
184 // }
185 // for (size_t i = 0; i < interpolated_warm_start_path.size(); i++) {
186 // print_curve.AddPoint("iter_warm_xy", interpolated_warm_start_path[i].x(),
187 // interpolated_warm_start_path[i].y());
188 // print_curve.AddPoint("iter_warm_s-kappa",
189 // interpolated_warm_start_path[i].s(),
190 // interpolated_warm_start_path[i].kappa());
191 // print_curve.AddPoint("iter_warm_s-theta",
192 // interpolated_warm_start_path[i].s(),
193 // interpolated_warm_start_path[i].theta());
194 // }
195 // print_curve.PrintToLog();
196 const auto path_smooth_end_timestamp = std::chrono::system_clock::now();
197 std::chrono::duration<double> path_smooth_diff = path_smooth_end_timestamp - path_smooth_start_timestamp;
198 ADEBUG << "iterative anchoring path smoother time: " << path_smooth_diff.count() * 1000.0 << " ms.";
199
200 const auto speed_smooth_start_timestamp = std::chrono::system_clock::now();
201
202 // Smooth speed to have smoothed v and a
203 SpeedData smoothed_speeds;
204 if (!SmoothSpeed(init_a, init_v, smoothed_path_points.Length(), &smoothed_speeds)) {
205 return false;
206 }
207
208 // TODO(Jinyun): Evaluate performance
209 // SpeedData smoothed_speeds;
210 // if (!GenerateStopProfileFromPolynomial(
211 // init_a, init_v, smoothed_path_points.Length(), &smoothed_speeds)) {
212 // return false;
213 // }
214
215 const auto speed_smooth_end_timestamp = std::chrono::system_clock::now();
216 std::chrono::duration<double> speed_smooth_diff = speed_smooth_end_timestamp - speed_smooth_start_timestamp;
217 ADEBUG << "iterative anchoring speed smoother time: " << speed_smooth_diff.count() * 1000.0 << " ms.";
218
219 // Combine path and speed
220 if (!CombinePathAndSpeed(smoothed_path_points, smoothed_speeds, discretized_trajectory)) {
221 return false;
222 }
223
224 AdjustPathAndSpeedByGear(discretized_trajectory);
225
226 const auto end_timestamp = std::chrono::system_clock::now();
227 std::chrono::duration<double> diff = end_timestamp - start_timestamp;
228 ADEBUG << "iterative anchoring smoother total time: " << diff.count() * 1000.0 << " ms.";
229
230 ADEBUG << "discretized_trajectory size " << discretized_trajectory->size();
231 return true;
232}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
float diff(Image< float > *I, int x1, int y1, int x2, int y2)
Dissimilarity measure between pixels

类成员变量说明

◆ box_vec_

std::vector<std::vector<common::math::Vec2d> > apollo::planning::IterativeAnchoringSmoother::box_vec_

在文件 iterative_anchoring_smoother.h 第 112 行定义.

◆ box_vec_vec_

std::vector<std::vector<std::vector<common::math::Vec2d> > > apollo::planning::IterativeAnchoringSmoother::box_vec_vec_

在文件 iterative_anchoring_smoother.h 第 113 行定义.


该类的文档由以下文件生成: