Apollo 10.0
自动驾驶开放平台
apollo::control::Interpolation1D类 参考

#include <interpolation_1d.h>

apollo::control::Interpolation1D 的协作图:

Public 类型

typedef std::vector< std::pair< double, double > > DataType
 

Public 成员函数

 Interpolation1D ()=default
 
bool Init (const DataType &xy)
 
double Interpolate (double x) const
 

详细描述

在文件 interpolation_1d.h28 行定义.

成员类型定义说明

◆ DataType

typedef std::vector<std::pair<double, double> > apollo::control::Interpolation1D::DataType

在文件 interpolation_1d.h30 行定义.

构造及析构函数说明

◆ Interpolation1D()

apollo::control::Interpolation1D::Interpolation1D ( )
default

成员函数说明

◆ Init()

bool apollo::control::Interpolation1D::Init ( const DataType xy)

在文件 interpolation_1d.cc27 行定义.

27 {
28 if (xy.empty()) {
29 AERROR << "empty input.";
30 return false;
31 }
32 auto data(xy);
33 std::sort(data.begin(), data.end());
34 Eigen::VectorXd x(data.size());
35 Eigen::VectorXd y(data.size());
36 for (unsigned i = 0; i < data.size(); ++i) {
37 x(i) = data[i].first;
38 y(i) = data[i].second;
39 }
40 x_min_ = data.front().first;
41 x_max_ = data.back().first;
42 y_start_ = data.front().second;
43 y_end_ = data.back().second;
44
45 // Spline fitting here. X values are scaled down to [0, 1] for this.
46 spline_.reset(new Eigen::Spline<double, 1>(
47 Eigen::SplineFitting<Eigen::Spline<double, 1>>::Interpolate(
48 y.transpose(),
49 // No more than cubic spline, but accept short vectors.
50 static_cast<Eigen::DenseIndex>(std::min<size_t>(x.size() - 1, 3)),
51 ScaledValues(x))));
52 return true;
53}
double Interpolate(double x) const
#define AERROR
Definition log.h:44

◆ Interpolate()

double apollo::control::Interpolation1D::Interpolate ( double  x) const

在文件 interpolation_1d.cc55 行定义.

55 {
56 if (x < x_min_) {
57 return y_start_;
58 }
59 if (x > x_max_) {
60 return y_end_;
61 }
62 // x values need to be scaled down in extraction as well.
63 return (*spline_)(ScaledValue(x))(0);
64}

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