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

linear interpolation from key (double, double) to one double value. 更多...

#include <interpolation_2d.h>

apollo::control::Interpolation2D 的协作图:

Public 类型

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

Public 成员函数

 Interpolation2D ()=default
 
bool Init (const DataType &xyz)
 initialize Interpolation2D internal table
 
double Interpolate (const KeyType &xy) const
 linear interpolate from 2D key (double, double) to one double value.
 
bool CheckMap () const
 

详细描述

linear interpolation from key (double, double) to one double value.

在文件 interpolation_2d.h40 行定义.

成员类型定义说明

◆ DataType

typedef std::vector<std::tuple<double, double, double> > apollo::control::Interpolation2D::DataType

在文件 interpolation_2d.h42 行定义.

◆ KeyType

typedef std::pair<double, double> apollo::control::Interpolation2D::KeyType

在文件 interpolation_2d.h43 行定义.

构造及析构函数说明

◆ Interpolation2D()

apollo::control::Interpolation2D::Interpolation2D ( )
default

成员函数说明

◆ CheckMap()

bool apollo::control::Interpolation2D::CheckMap ( ) const

在文件 interpolation_2d.cc50 行定义.

50 {
51 double keysize = xyz_.begin()->second.size();
52 auto itr_ = xyz_.begin();
53 for (; itr_ != xyz_.end(); itr_++) {
54 if (FLAGS_use_calibration_dimension_equal_check) {
55 if (keysize != itr_->second.size()) {
56 AERROR << "calibration map dimension is not equal.";
57 AERROR << "first value: " << keysize
58 << ", second value: " << itr_->second.size();
59 return false;
60 }
61 }
62
63 int pos_count = 0;
64 int nag_count = 0;
65 auto inner_itr_ = itr_->second.begin();
66 for (; inner_itr_ != itr_->second.end(); inner_itr_++) {
67 if (inner_itr_->first > 0) {
68 pos_count++;
69 } else if (inner_itr_->first < 0) {
70 nag_count++;
71 }
72 }
73 if (nag_count == 0) {
74 AERROR << "calibration has all pos map";
75 return false;
76 }
77 if (pos_count == 0) {
78 AERROR << "calibration has all nag map";
79 return false;
80 }
81 }
82 return true;
83}
#define AERROR
Definition log.h:44

◆ Init()

bool apollo::control::Interpolation2D::Init ( const DataType xyz)

initialize Interpolation2D internal table

参数
xyzpassing interpolation initialization table data
返回
true if init is ok.

在文件 interpolation_2d.cc33 行定义.

33 {
34 if (xyz.empty()) {
35 AERROR << "empty input.";
36 return false;
37 }
38 for (const auto &t : xyz) {
39 xyz_[std::get<0>(t)][std::get<1>(t)] = std::get<2>(t);
40 }
41
42 if (!CheckMap()) {
43 AERROR << "calibration map is not correct.";
44 return false;
45 }
46
47 return true;
48}

◆ Interpolate()

double apollo::control::Interpolation2D::Interpolate ( const KeyType xy) const

linear interpolate from 2D key (double, double) to one double value.

参数
xyzpassing interpolation initialization table data
返回
true if init is ok.

在文件 interpolation_2d.cc85 行定义.

85 {
86 double max_x = xyz_.rbegin()->first;
87 double min_x = xyz_.begin()->first;
88 if (xy.first >= max_x - kDoubleEpsilon) {
89 return InterpolateYz(xyz_.rbegin()->second, xy.second);
90 }
91 if (xy.first <= min_x + kDoubleEpsilon) {
92 return InterpolateYz(xyz_.begin()->second, xy.second);
93 }
94
95 auto itr_after = xyz_.lower_bound(xy.first);
96 auto itr_before = itr_after;
97 if (itr_before != xyz_.begin()) {
98 --itr_before;
99 }
100
101 double x_before = itr_before->first;
102 double z_before = InterpolateYz(itr_before->second, xy.second);
103 double x_after = itr_after->first;
104 double z_after = InterpolateYz(itr_after->second, xy.second);
105
106 double x_diff_before = std::fabs(xy.first - x_before);
107 double x_diff_after = std::fabs(xy.first - x_after);
108
109 return InterpolateValue(z_before, x_diff_before, z_after, x_diff_after);
110}
const double kDoubleEpsilon

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