32 #ifndef FILTERS_TRANSFER_FUNCTION_HPP_
33 #define FILTERS_TRANSFER_FUNCTION_HPP_
95 virtual bool update(
const T & data_in, T& data_out) ;
106 std::vector<double>
a_;
107 std::vector<double>
b_;
111 template <
typename T>
116 template <
typename T>
121 template <
typename T>
153 for(uint32_t i = 0; i < b_.size(); i++)
155 b_[i] = (b_[i] / a_[0]);
157 for(uint32_t i = 1; i < a_.size(); i++)
159 a_[i] = (a_[i] / a_[0]);
161 a_[0] = (a_[0] / a_[0]);
168 template <
typename T>
177 data_out=b_[0] * temp_;
179 for (uint32_t row = 1; row <= input_buffer_->size(); row++)
181 data_out += b_[row] * (*input_buffer_)[row-1];
183 for (uint32_t row = 1; row <= output_buffer_->size(); row++)
185 data_out -= a_[row] * (*output_buffer_)[row-1];
188 input_buffer_->push_front(temp_);
189 output_buffer_->push_front(data_out);
223 template <
typename T>
246 virtual bool update(
const std::vector<T> & data_in, std::vector<T>& data_out) ;
257 std::vector<double>
a_;
258 std::vector<double>
b_;
262 template <
typename T>
267 template <
typename T>
272 template <
typename T>
290 temp_.resize(this->number_of_channels_);
304 for(uint32_t i = 0; i < b_.size(); i++)
306 b_[i] = (b_[i] / a_[0]);
308 for(uint32_t i = 1; i < a_.size(); i++)
310 a_[i] = (a_[i] / a_[0]);
312 a_[0] = (a_[0] / a_[0]);
319 template <
typename T>
324 if (data_in.size() != this->number_of_channels_ || data_out.size() != this->number_of_channels_ )
326 ROS_ERROR(
"Number of channels is %d, but data_in.size() = %d and data_out.size() = %d. They must match", this->number_of_channels_, (
int)data_in.size(), (
int)data_out.size());
332 for (uint32_t i = 0; i < temp_.size(); i++)
334 data_out[i]=b_[0] * temp_[i];
336 for (uint32_t row = 1; row <= input_buffer_->size(); row++)
338 (data_out)[i] += b_[row] * (*input_buffer_)[row-1][i];
340 for (uint32_t row = 1; row <= output_buffer_->size(); row++)
342 (data_out)[i] -= a_[row] * (*output_buffer_)[row-1][i];
345 input_buffer_->push_front(temp_);
346 output_buffer_->push_front(data_out);
352 #endif //#ifndef FILTERS_TRANSFER_FUNCTION_HPP_