Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
inlanecruising_plugin::smoothing Namespace Reference

Classes

class  BSpline
 Realization of SplineI that uses the Eigen::Splines library for interpolation. More...
 
class  SplineI
 Interface to a spline interpolator that can be used to smoothly interpolate between points. More...
 

Typedefs

typedef Eigen::Spline< double, 2 > Spline2d
 

Functions

std::vector< double > moving_average_filter (const std::vector< double > input, int window_size, bool ignore_first_point=true)
 Extremely simplie moving average filter. More...
 

Typedef Documentation

◆ Spline2d

typedef Eigen::Spline<double, 2> inlanecruising_plugin::smoothing::Spline2d

Definition at line 29 of file BSpline.hpp.

Function Documentation

◆ moving_average_filter()

std::vector< double > inlanecruising_plugin::smoothing::moving_average_filter ( const std::vector< double >  input,
int  window_size,
bool  ignore_first_point = true 
)

Extremely simplie moving average filter.

Parameters
inputThe points to be filtered
window_sizeThe number of points to use in the moving window for averaging
Returns
The filterted points

Definition at line 37 of file filters.hpp.

38{
39 if (window_size % 2 == 0) {
40 throw std::invalid_argument("moving_average_filter window size must be odd");
41 }
42
43 std::vector<double> output;
44 output.reserve(input.size());
45
46 if (input.size() == 0) {
47 return output;
48 }
49
50 int start_index = 0;
51 if (ignore_first_point) {
52 start_index = 1;
53 output.push_back(input[0]);
54 }
55
56 for (int i = start_index; i<input.size(); i++) {
57
58
59 double total = 0;
60 int sample_min = std::max(0, i - window_size / 2);
61 int sample_max = std::min((int) input.size() - 1 , i + window_size / 2);
62
63 int count = sample_max - sample_min + 1;
64 std::vector<double> sample;
65 sample.reserve(count);
66 for (int j = sample_min; j <= sample_max; j++) {
67 total += input[j];
68 }
69 output.push_back(total / (double) count);
70
71 }
72
73 return output;
74}

References process_bag::i, and process_traj_logs::start_index.