27
27
28
28
/* SOT */
29
29
#include < sot/core/integrator-abstract.hh>
30
+ #include < dynamic-graph/command-setter.h>
31
+ #include < dynamic-graph/command-getter.h>
30
32
31
33
/* --------------------------------------------------------------------- */
32
34
/* --- CLASS ----------------------------------------------------------- */
@@ -64,7 +66,17 @@ class IntegratorEuler
64
66
IntegratorEuler ( const std::string& name )
65
67
: IntegratorAbstract<sigT,coefT>( name )
66
68
{
69
+ setSamplingPeriod (0.005 );
70
+
67
71
SOUT.addDependency (SIN);
72
+ this ->addCommand (" setSamplingPeriod" ,
73
+ new dg::command::Setter<IntegratorEuler,double > (*this ,
74
+ &IntegratorEuler::setSamplingPeriod,
75
+ " Set the time during two sampling." ));
76
+ this ->addCommand (" getSamplingPeriod" ,
77
+ new dg::command::Getter<IntegratorEuler,double > (*this ,
78
+ &IntegratorEuler::getSamplingPeriod,
79
+ " Get the time during two sampling." ));
68
80
}
69
81
70
82
virtual ~IntegratorEuler ( void ) {}
@@ -73,14 +85,14 @@ protected:
73
85
std::vector<sigT> inputMemory;
74
86
std::vector<sigT> outputMemory;
75
87
88
+ double dt;
89
+ double invdt;
90
+
76
91
public:
77
92
sigT& integrate ( sigT& res, int time )
78
93
{
79
94
sotDEBUG (15 )<<" # In {" <<std::endl;
80
95
81
- const double dt = 0.005 ;
82
- const double invdt = 200 ;
83
-
84
96
sigT sum;
85
97
sigT tmp1, tmp2;
86
98
const std::vector<coefT>& num = numerator;
@@ -127,6 +139,17 @@ public:
127
139
sotDEBUG (15 )<<" # Out }" <<std::endl;
128
140
return res;
129
141
}
142
+
143
+ void setSamplingPeriod (const double & period)
144
+ {
145
+ dt = period;
146
+ invdt = 1 /period;
147
+ }
148
+
149
+ double getSamplingPeriod () const
150
+ {
151
+ return dt;
152
+ }
130
153
};
131
154
132
155
} /* namespace sot */ } /* namespace dynamicgraph */
0 commit comments