Apollo 11.0
自动驾驶开放平台
apollo::control::InterpolationPlus1D类 参考

#include <interpolation_plus_1d.h>

类 apollo::control::InterpolationPlus1D 继承关系图:
apollo::control::InterpolationPlus1D 的协作图:

静态 Public 成员函数

static double interpolation_1d (const double &value, const google::protobuf::RepeatedField< double > &input_vector, const google::protobuf::RepeatedField< double > &output_vector)
 

额外继承的成员函数

- Public 类型 继承自 apollo::control::Interpolation1D
typedef std::vector< std::pair< double, double > > DataType
 
- Public 成员函数 继承自 apollo::control::Interpolation1D
 Interpolation1D ()=default
 
bool Init (const DataType &xy)
 
double Interpolate (double x) const
 

详细描述

在文件 interpolation_plus_1d.h 第 33 行定义.

成员函数说明

◆ interpolation_1d()

double apollo::control::InterpolationPlus1D::interpolation_1d ( const double &  value,
const google::protobuf::RepeatedField< double > &  input_vector,
const google::protobuf::RepeatedField< double > &  output_vector 
)
static

在文件 interpolation_plus_1d.cc 第 25 行定义.

28 {
29 int input_size = input_vector.size();
30 int output_size = output_vector.size();
31
32 ADEBUG << "input_size is " << input_size << ", output_size is " << output_size;
33 if (input_size < 1 || output_size < 1) {
34 AERROR << "1d interpolation: vector size is 0";
35 return 1.0;
36 } else if (input_size != output_size) {
37 AERROR << "1d interpolation: vector size is wrong"
38 << ", input_size: " << input_size << ", output_size: " << output_size;
39 return 1.0;
40 }
41
42 if (value <= input_vector.Get(0)) {
43 ADEBUG << "return the output_vector.Get(0)";
44 return output_vector.Get(0);
45 } else if (value >= input_vector.Get(input_size - 1)) {
46 ADEBUG << "return the output_vector.Get(input_size - 1)";
47 return output_vector.Get(input_size - 1);
48 }
49
50 for (int i = 1; i < input_size; ++i) {
51 if (value >= input_vector.Get(i - 1) && value < input_vector.Get(i)) {
52 ADEBUG << "return the interpolation_1d";
53 return output_vector.Get(i - 1)
54 + (output_vector.Get(i) - output_vector.Get(i - 1)) * (value - input_vector.Get(i - 1))
55 / (input_vector.Get(i) - input_vector.Get(i - 1));
56 }
57 }
58
59 AERROR << "1d interpolation: something is wrong";
60 return 1.0;
61}
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

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