Skip to content

Commit

Permalink
Inline function #136
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Nov 20, 2023
1 parent f3b2554 commit ac78385
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 5 additions & 3 deletions lbr_fri_ros2/include/lbr_fri_ros2/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class ExponentialFilter {
* @param[in] previous The previous smoothed value.
* @return double The returned smoothed value.
*/
inline double compute(const double &current, const double &previous);
inline double compute(const double &current, const double &previous) {
return filters::exponentialSmoothing(current, previous, alpha_);
};

/**
* @brief Set the cutoff frequency object. Internally computes the new #alpha_.
Expand All @@ -61,14 +63,14 @@ class ExponentialFilter {
*
* @return const double&
*/
inline const double &get_sample_time() const;
inline const double &get_sample_time() const { return sample_time_; };

/**
* @brief Get #alpha_.
*
* @return const double&
*/
inline const double &get_alpha() const;
inline const double &get_alpha() const { return alpha_; };

protected:
/**
Expand Down
8 changes: 0 additions & 8 deletions lbr_fri_ros2/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ ExponentialFilter::ExponentialFilter(const double &cutoff_frequency, const doubl
set_cutoff_frequency(cutoff_frequency, sample_time);
}

inline double ExponentialFilter::compute(const double &current, const double &previous) {
return filters::exponentialSmoothing(current, previous, alpha_);
}

void ExponentialFilter::set_cutoff_frequency(const double &cutoff_frequency,
const double &sample_time) {
cutoff_frequency_ = cutoff_frequency;
Expand All @@ -24,10 +20,6 @@ void ExponentialFilter::set_cutoff_frequency(const double &cutoff_frequency,
}
}

inline const double &ExponentialFilter::get_sample_time() const { return sample_time_; }

inline const double &ExponentialFilter::get_alpha() const { return alpha_; }

double ExponentialFilter::compute_alpha_(const double &cutoff_frequency,
const double &sample_time) {
double omega_3db = 2.0 * M_PI * sample_time * cutoff_frequency;
Expand Down

0 comments on commit ac78385

Please sign in to comment.