Apollo 10.0
自动驾驶开放平台
apollo::common::MeanFilter类 参考

The MeanFilter class is used to smoothen a series of noisy numbers, such as sensor data or the output of a function that we wish to be smoother. 更多...

#include <mean_filter.h>

apollo::common::MeanFilter 的协作图:

Public 成员函数

 MeanFilter (const std::uint_fast8_t window_size)
 Initializes a MeanFilter with a given window size.
 
 MeanFilter ()=default
 Default constructor; defers initialization.
 
 ~MeanFilter ()=default
 Default destructor.
 
double Update (const double measurement)
 Processes a new measurement in amortized constant time.
 

详细描述

The MeanFilter class is used to smoothen a series of noisy numbers, such as sensor data or the output of a function that we wish to be smoother.

This is achieved by keeping track of the last k measurements (where k is the window size), and returning the average of all but the minimum and maximum measurements, which are likely to be outliers.

在文件 mean_filter.h45 行定义.

构造及析构函数说明

◆ MeanFilter() [1/2]

apollo::common::MF::MeanFilter ( const std::uint_fast8_t  window_size)
explicit

Initializes a MeanFilter with a given window size.

参数
window_sizeThe window size of the MeanFilter. Older measurements are discarded.

在文件 mean_filter.cc32 行定义.

32 : window_size_(window_size) {
33 CHECK_GT(window_size_, 0);
34 CHECK_LE(window_size_, kMaxWindowSize);
35 initialized_ = true;
36}
const uint8 kMaxWindowSize

◆ MeanFilter() [2/2]

apollo::common::MeanFilter::MeanFilter ( )
default

Default constructor; defers initialization.

◆ ~MeanFilter()

apollo::common::MeanFilter::~MeanFilter ( )
default

Default destructor.

成员函数说明

◆ Update()

double apollo::common::MF::Update ( const double  measurement)

Processes a new measurement in amortized constant time.

参数
measurementThe measurement to be processed by the filter.

在文件 mean_filter.cc54 行定义.

54 {
55 ACHECK(initialized_);
56 CHECK_LE(values_.size(), window_size_);
57 CHECK_LE(min_candidates_.size(), window_size_);
58 CHECK_LE(max_candidates_.size(), window_size_);
59 ++time_;
60 time_ %= static_cast<std::uint_fast8_t>(2 * window_size_);
61 if (values_.size() == window_size_) {
62 RemoveEarliest();
63 }
64 Insert(measurement);
65 if (values_.size() > 2) {
66 return (sum_ - GetMin() - GetMax()) /
67 static_cast<double>(values_.size() - 2);
68 } else {
69 return sum_ / static_cast<double>(values_.size());
70 }
71}
#define ACHECK(cond)
Definition log.h:80

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