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.
basic_autonomy::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> basic_autonomy::smoothing::Spline2d

Definition at line 29 of file BSpline.hpp.

Function Documentation

◆ moving_average_filter()

std::vector< double > basic_autonomy::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 24 of file filters.cpp.

25{
26 if (window_size % 2 == 0) {
27 throw std::invalid_argument("moving_average_filter window size must be odd");
28 }
29
30 std::vector<double> output;
31 output.reserve(input.size());
32
33 if (input.size() == 0) {
34 return output;
35 }
36
37 int start_index = 0;
38 if (ignore_first_point) {
39 start_index = 1;
40 output.push_back(input[0]);
41 }
42
43 for (int i = start_index; i < static_cast<int>(input.size()); i++) {
44
45
46 double total = 0;
47 int sample_min = std::max(0, i - window_size / 2);
48 int sample_max = std::min((int) input.size() - 1 , i + window_size / 2);
49
50 int count = sample_max - sample_min + 1;
51 std::vector<double> sample;
52 sample.reserve(count);
53 for (int j = sample_min; j <= sample_max; j++) {
54 total += input[j];
55 }
56 output.push_back(total / (double) count);
57
58 }
59
60 return output;
61}

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

Referenced by basic_autonomy::waypoint_generation::compose_lanechange_trajectory_from_path(), basic_autonomy::waypoint_generation::compose_lanefollow_trajectory_from_path(), stop_controlled_intersection_tactical_plugin::StopControlledIntersectionTacticalPlugin::compose_trajectory_from_centerline(), stop_and_wait_plugin::StopandWait::compose_trajectory_from_centerline(), and yield_plugin::YieldPlugin::generate_JMT_trajectory().

Here is the caller graph for this function: