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

#include <qp_spline_reference_line_smoother.h>

类 apollo::planning::QpSplineReferenceLineSmoother 继承关系图:
apollo::planning::QpSplineReferenceLineSmoother 的协作图:

Public 成员函数

 QpSplineReferenceLineSmoother (const ReferenceLineSmootherConfig &config)
 
virtual ~QpSplineReferenceLineSmoother ()=default
 
bool Smooth (const ReferenceLine &raw_reference_line, ReferenceLine *const smoothed_reference_line) override
 Smooth a given reference line
 
void SetAnchorPoints (const std::vector< AnchorPoint > &anchor_points) override
 Smoothing constraints
 
- Public 成员函数 继承自 apollo::planning::ReferenceLineSmoother
 ReferenceLineSmoother (const ReferenceLineSmootherConfig &config)
 
virtual ~ReferenceLineSmoother ()=default
 

额外继承的成员函数

- Protected 属性 继承自 apollo::planning::ReferenceLineSmoother
ReferenceLineSmootherConfig config_
 

详细描述

在文件 qp_spline_reference_line_smoother.h 第 37 行定义.

构造及析构函数说明

◆ QpSplineReferenceLineSmoother()

apollo::planning::QpSplineReferenceLineSmoother::QpSplineReferenceLineSmoother ( const ReferenceLineSmootherConfig &  config)
explicit

在文件 qp_spline_reference_line_smoother.cc 第 37 行定义.

39 : ReferenceLineSmoother(config) {
40 spline_solver_.reset(
41 new OsqpSpline2dSolver(t_knots_, config.qp_spline().spline_order()));
42}
ReferenceLineSmoother(const ReferenceLineSmootherConfig &config)

◆ ~QpSplineReferenceLineSmoother()

virtual apollo::planning::QpSplineReferenceLineSmoother::~QpSplineReferenceLineSmoother ( )
virtualdefault

成员函数说明

◆ SetAnchorPoints()

void apollo::planning::QpSplineReferenceLineSmoother::SetAnchorPoints ( const std::vector< AnchorPoint > &  achor_points)
overridevirtual

Smoothing constraints

实现了 apollo::planning::ReferenceLineSmoother.

在文件 qp_spline_reference_line_smoother.cc 第 207 行定义.

208 {
209 CHECK_GE(anchor_points.size(), 2U);
210 anchor_points_ = anchor_points;
211}

◆ Smooth()

bool apollo::planning::QpSplineReferenceLineSmoother::Smooth ( const ReferenceLine &  ,
ReferenceLine *const   
)
overridevirtual

Smooth a given reference line

实现了 apollo::planning::ReferenceLineSmoother.

在文件 qp_spline_reference_line_smoother.cc 第 46 行定义.

48 {
49 Clear();
50 const double kEpsilon = 1e-6;
51 if (!Sampling()) {
52 AERROR << "Fail to sample reference line smoother points!";
53 return false;
54 }
55
56 spline_solver_->Reset(t_knots_, config_.qp_spline().spline_order());
57
58 if (!AddConstraint()) {
59 AERROR << "Add constraint for spline smoother failed";
60 return false;
61 }
62
63 if (!AddKernel()) {
64 AERROR << "Add kernel for spline smoother failed.";
65 return false;
66 }
67
68 if (!Solve()) {
69 AERROR << "Solve spline smoother problem failed";
70 }
71
72 // mapping spline to reference line point
73 const double start_t = t_knots_.front();
74 const double end_t = t_knots_.back();
75
76 const double resolution =
77 (end_t - start_t) / (config_.num_of_total_points() - 1);
78 double t = start_t;
79 std::vector<ReferencePoint> ref_points;
80 const auto& spline = spline_solver_->spline();
81 for (std::uint32_t i = 0; i < config_.num_of_total_points() && t < end_t;
82 ++i, t += resolution) {
83 const double heading =
84 std::atan2(spline.DerivativeY(t), spline.DerivativeX(t));
85 const double kappa = CurveMath::ComputeCurvature(
86 spline.DerivativeX(t), spline.SecondDerivativeX(t),
87 spline.DerivativeY(t), spline.SecondDerivativeY(t));
88 const double dkappa = CurveMath::ComputeCurvatureDerivative(
89 spline.DerivativeX(t), spline.SecondDerivativeX(t),
90 spline.ThirdDerivativeX(t), spline.DerivativeY(t),
91 spline.SecondDerivativeY(t), spline.ThirdDerivativeY(t));
92
93 std::pair<double, double> xy = spline(t);
94 xy.first += ref_x_;
95 xy.second += ref_y_;
96 common::SLPoint ref_sl_point;
97 if (!raw_reference_line.XYToSL({xy.first, xy.second}, &ref_sl_point)) {
98 return false;
99 }
100 if (ref_sl_point.s() < -kEpsilon ||
101 ref_sl_point.s() > raw_reference_line.Length()) {
102 continue;
103 }
104 ref_sl_point.set_s(std::max(ref_sl_point.s(), 0.0));
105 ReferencePoint rlp = raw_reference_line.GetReferencePoint(ref_sl_point.s());
106 auto new_lane_waypoints = rlp.lane_waypoints();
107 for (auto& lane_waypoint : new_lane_waypoints) {
108 lane_waypoint.l = ref_sl_point.l();
109 }
110 ref_points.emplace_back(ReferencePoint(
111 hdmap::MapPathPoint(common::math::Vec2d(xy.first, xy.second), heading,
112 new_lane_waypoints),
113 kappa, dkappa));
114 }
115
117 if (ref_points.size() < 2) {
118 AERROR << "Fail to generate smoothed reference line.";
119 return false;
120 }
121 *smoothed_reference_line = ReferenceLine(ref_points);
122 return true;
123}
static double ComputeCurvatureDerivative(const double dx, const double d2x, const double d3x, const double dy, const double d2y, const double d3y)
Compute the curvature change rate w.r.t.
Definition curve_math.cc:38
static double ComputeCurvature(const double dx, const double d2x, const double dy, const double d2y)
Compute the curvature (kappa) given curve X = (x(t), y(t)) which t is an arbitrary parameter.
Definition curve_math.cc:29
static void RemoveDuplicates(std::vector< ReferencePoint > *points)
#define AERROR
Definition log.h:44

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