51 {
52 CHECK_NOTNULL(path_data);
53
54 init_point_ = init_point;
56 AERROR <<
"Fail to create init_sl_point from : "
57 << init_point.DebugString();
58 return false;
59 }
60 init_frenet_frame_point_ =
62
63 waypoint_sampler_->Init(&reference_line_info_, init_sl_point_,
64 init_frenet_frame_point_);
65 waypoint_sampler_->SetDebugLogger(planning_debug_);
66
67 std::vector<DpRoadGraphNode> min_cost_path;
68 if (!GenerateMinCostPath(obstacles, &min_cost_path)) {
69 AERROR <<
"Fail to generate graph!";
70 return false;
71 }
72 std::vector<common::FrenetFramePoint> frenet_path;
73 double accumulated_s = min_cost_path.front().sl_point.s();
74 const double path_resolution = config_.path_resolution();
75
76 for (size_t i = 1; i < min_cost_path.size(); ++i) {
77 const auto &prev_node = min_cost_path[i - 1];
78 const auto &cur_node = min_cost_path[i];
79
80 const double path_length = cur_node.sl_point.s() - prev_node.sl_point.s();
81 double current_s = 0.0;
82 const auto &curve = cur_node.min_cost_curve;
83 while (current_s + path_resolution / 2.0 < path_length) {
84 const double l = curve.Evaluate(0, current_s);
85 const double dl = curve.Evaluate(1, current_s);
86 const double ddl = curve.Evaluate(2, current_s);
87 common::FrenetFramePoint frenet_frame_point;
88 frenet_frame_point.set_s(accumulated_s + current_s);
89 frenet_frame_point.set_l(l);
90 frenet_frame_point.set_dl(dl);
91 frenet_frame_point.set_ddl(ddl);
92 frenet_path.push_back(std::move(frenet_frame_point));
93 current_s += path_resolution;
94 }
95 if (i == min_cost_path.size() - 1) {
96 accumulated_s += current_s;
97 } else {
98 accumulated_s += path_length;
99 }
100 }
101 path_data->SetReferenceLine(&reference_line_);
102 path_data->SetFrenetPath(FrenetFramePath(std::move(frenet_path)));
103 return true;
104}
bool XYToSL(const common::math::Vec2d &xy_point, common::SLPoint *const sl_point, double warm_start_s=-1.0) const
Transvert Cartesian coordinates to Frenet.
common::FrenetFramePoint GetFrenetPoint(const common::PathPoint &path_point) const
optional PathPoint path_point