Skip to content

Commit 83e04ee

Browse files
committed
Make integration time in IntegratorEuler parameterizable.
1 parent a1d1a21 commit 83e04ee

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

include/sot/core/integrator-euler.hh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
/* SOT */
2929
#include <sot/core/integrator-abstract.hh>
30+
#include <dynamic-graph/command-setter.h>
31+
#include <dynamic-graph/command-getter.h>
3032

3133
/* --------------------------------------------------------------------- */
3234
/* --- CLASS ----------------------------------------------------------- */
@@ -64,7 +66,17 @@ class IntegratorEuler
6466
IntegratorEuler( const std::string& name )
6567
: IntegratorAbstract<sigT,coefT>( name )
6668
{
69+
setSamplingPeriod (0.005);
70+
6771
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."));
6880
}
6981

7082
virtual ~IntegratorEuler( void ) {}
@@ -73,14 +85,14 @@ protected:
7385
std::vector<sigT> inputMemory;
7486
std::vector<sigT> outputMemory;
7587

88+
double dt;
89+
double invdt;
90+
7691
public:
7792
sigT& integrate( sigT& res, int time )
7893
{
7994
sotDEBUG(15)<<"# In {"<<std::endl;
8095

81-
const double dt = 0.005;
82-
const double invdt = 200;
83-
8496
sigT sum;
8597
sigT tmp1, tmp2;
8698
const std::vector<coefT>& num = numerator;
@@ -127,6 +139,17 @@ public:
127139
sotDEBUG(15)<<"# Out }"<<std::endl;
128140
return res;
129141
}
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+
}
130153
};
131154

132155
} /* namespace sot */} /* namespace dynamicgraph */

0 commit comments

Comments
 (0)