Apollo 10.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 行定义.

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

◆ ~IterativeAnchoringSmoother()

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

◆ IterativeAnchoringSmoother() [2/2]

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

成员函数说明

◆ 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 第 60 行定义.

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

类成员变量说明

◆ box_vec_

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

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

◆ box_vec_vec_

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

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


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