10 #ifndef __SOT_FIRFILTER_HH__ 11 #define __SOT_FIRFILTER_HH__ 16 #include <dynamic-graph/entity.h> 58 assert((i <
numel) &&
"Youre accessing an empty buffer");
71 template <
class sigT,
class coefT>
75 using ::dynamicgraph::command::Command;
76 using ::dynamicgraph::command::Value;
78 template <
class sigT,
class coefT>
85 template <
class sigT,
class coefT>
93 using ::dynamicgraph::command::Getter;
94 using ::dynamicgraph::command::Setter;
96 template <
class sigT,
class coefT>
106 return "Finite impulse response filter\n" 108 " Provide the following sum in output signal:\n" 111 " y (n) = \\ c s (n-i) \n" 116 " - c_i are coefficients stored in an array\n" 117 " - N is the size of the array\n" 118 " - s is the input signal.\n";
124 SIN(NULL,
"sotFIRFilter(" + name +
")::input(T)::sin"),
126 "sotFIRFilter(" + name +
")::output(T)::sout") {
127 signalRegistration(SIN << SOUT);
128 std::string docstring =
129 " Set element at rank in array of coefficients\n" 132 " - positive int: rank\n" 134 addCommand(
"setElement",
137 " Get element at rank in array of coefficients\n" 140 " - positive int: rank\n" 143 addCommand(
"getElement",
146 " Set number of coefficients\n" 149 " - positive int: size\n";
154 " Get Number of coefficients\n" 157 " - positive int: size\n";
165 const sigT &in = SIN.access(time);
166 reset_signal(res, in);
169 size_t SIZE = std::min(
data.size(), coefs.size());
170 for (
size_t i = 0;
i < SIZE; ++
i) {
171 res += coefs[
i] *
data[
i];
178 size_t s =
static_cast<size_t>(
size);
179 data.reset_capacity(s);
184 return static_cast<unsigned int>(coefs.size());
187 void setElement(
const unsigned int &rank,
const coefT &coef) {
191 coefT
getElement(
const unsigned int &rank)
const {
return coefs[rank]; }
205 using ::dynamicgraph::command::Command;
206 using ::dynamicgraph::command::Value;
207 using ::dynamicgraph::command::ValueHelper;
209 template <
class sigT,
class coefT>
211 const std::string &docstring)
217 template <
class sigT,
class coefT>
222 unsigned int rank = values[0].value();
223 coefT coef = values[1].value();
228 template <
class sigT,
class coefT>
230 const std::string &docstring)
233 template <
class sigT,
class coefT>
238 unsigned int rank = values[0].value();
std::vector< coefT > coefs
coefT getElement(const unsigned int &rank) const
virtual sigT & compute(sigT &res, int time)
unsigned int getBufferSize() const
virtual const std::string & getClassName() const
FIRFilter(const std::string &name)
SignalPtr< sigT, int > SIN
void resizeBuffer(const unsigned int &size)
static void reset_signal(sigT &, const sigT &)
void push_front(const T &data)
virtual const std::string & getClassName() const
void reset_capacity(size_t n)
static std::string getTypeName(void)
detail::circular_buffer< sigT > data
void reset_capacity(size_t n, const T &el)
SignalTimeDependent< sigT, int > SOUT
const std::vector< Value > & getParameterValues() const
static const std::string CLASS_NAME
void setElement(const unsigned int &rank, const coefT &coef)
GetElement(FIRFilter< sigT, coefT > &entity, const std::string &docstring)
std::string getDocString() const