10 #ifndef __SOT_INTEGRATOR_EULER_H__
11 #define __SOT_INTEGRATOR_EULER_H__
18 #include <dynamic-graph/command-getter.h>
19 #include <dynamic-graph/command-setter.h>
31 template <
class coefT>
50 template <
class sigT,
class coefT>
69 "sotIntegratorEuler(" + name +
70 ")::output(vector)::derivativesout") {
73 using namespace dynamicgraph::command;
77 this->addCommand(
"setSamplingPeriod",
78 new Setter<IntegratorEuler, double>(
80 "Set the time during two sampling."));
81 this->addCommand(
"getSamplingPeriod",
82 new Getter<IntegratorEuler, double>(
84 "Get the time during two sampling."));
91 "Initialize internal memory from current value of input")));
107 sotDEBUG(15) <<
"# In {" << std::endl;
111 const std::vector<coefT> &num =
numerator;
121 int numsize = (int)num.size();
122 for (
int i = 1; i < numsize; ++i) {
132 int denomsize = (int)denom.size() - 1;
133 for (
int i = 0; i < denomsize; ++i) {
141 for (
int i = denomsize - 1; i >= 0; --i) {
149 sotDEBUG(15) <<
"# Out }" << std::endl;
155 throw dynamicgraph::ExceptionSignal(
156 dynamicgraph::ExceptionSignal::GENERIC,
157 "Integrator does not compute the derivative.");
159 SOUT.recompute(time);
173 throw dynamicgraph::ExceptionSignal(
174 dynamicgraph::ExceptionSignal::GENERIC,
175 "The numerator or the denominator is empty.");
179 throw dynamicgraph::ExceptionSignal(
180 dynamicgraph::ExceptionSignal::GENERIC,
181 "The coefficient of the highest order derivative of denominator "
182 "should be 1 (the last pushDenomCoef should be the identity).");
188 for (std::size_t i = 1; i < numsize; ++i) {
194 for (std::size_t i = 0; i < denomsize; ++i) {
integrates an ODE. If Y is the output and X the input, the following equation is integrated: a_p * d(...
Definition: integrator-abstract.hh:46
dynamicgraph::SignalPtr< sigT, int > SIN
Definition: integrator-abstract.hh:101
std::vector< coefT > numerator
Definition: integrator-abstract.hh:120
dynamicgraph::SignalTimeDependent< sigT, int > SOUT
Definition: integrator-abstract.hh:103
std::vector< coefT > denominator
Definition: integrator-abstract.hh:121
integrates an ODE using a naive Euler integration. TODO: change the integration method....
Definition: integrator-euler.hh:51
double dt
Definition: integrator-euler.hh:102
double invdt
Definition: integrator-euler.hh:103
sigT & integrate(sigT &res, int time)
Definition: integrator-euler.hh:106
IntegratorEuler(const std::string &name)
Definition: integrator-euler.hh:64
static const std::string CLASS_NAME
Definition: integrator-euler.hh:55
std::vector< sigT > outputMemory
Definition: integrator-euler.hh:98
sigT & derivative(sigT &res, int time)
Definition: integrator-euler.hh:153
dynamicgraph::SignalTimeDependent< sigT, int > derivativeSOUT
Definition: integrator-euler.hh:100
virtual ~IntegratorEuler(void)
Definition: integrator-euler.hh:94
std::vector< sigT > inputMemory
Definition: integrator-euler.hh:97
static std::string getTypeName(void)
Definition: integrator-euler.hh:54
double getSamplingPeriod() const
Definition: integrator-euler.hh:169
void initialize()
Definition: integrator-euler.hh:171
void setSamplingPeriod(const double &period)
Definition: integrator-euler.hh:164
virtual const std::string & getClassName(void) const
#define sotDEBUG(level)
Definition: debug.hh:165
bool integratorEulerCoeffIsIdentity(const coefT c)
Definition: integrator-euler.hh:32
Definition: abstract-sot-external-interface.hh:17