Skip to content

Commit 0827cca

Browse files
committed
Add access to derivative of output in IntegratorEuler
1 parent 83df0f2 commit 0827cca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

include/sot/core/integrator-euler.hh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ class IntegratorEuler
6565
public:
6666
IntegratorEuler( const std::string& name )
6767
: IntegratorAbstract<sigT,coefT>( name )
68+
, derivativeSOUT(boost::bind(&IntegratorEuler<sigT,coefT>::derivative,this,_1,_2),
69+
SOUT,
70+
"sotIntegratorAbstract("+name+")::output(vector)::derivativesout")
6871
{
72+
this->signalRegistration( derivativeSOUT );
73+
6974
using namespace dg::command;
7075

7176
setSamplingPeriod (0.005);
7277

73-
SOUT.addDependency(SIN);
7478
this->addCommand ("setSamplingPeriod",
7579
new Setter<IntegratorEuler,double> (*this,
7680
&IntegratorEuler::setSamplingPeriod,
@@ -92,6 +96,8 @@ protected:
9296
std::vector<sigT> inputMemory;
9397
std::vector<sigT> outputMemory;
9498

99+
dg::SignalTimeDependent<sigT, int> derivativeSOUT;
100+
95101
double dt;
96102
double invdt;
97103

@@ -147,6 +153,16 @@ public:
147153
return res;
148154
}
149155

156+
sigT& derivative ( sigT& res, int time )
157+
{
158+
if (outputMemory.size() < 2)
159+
throw dg::ExceptionSignal (dg::ExceptionSignal::GENERIC,
160+
"Integrator does not compute the derivative.");
161+
162+
SOUT.recompute(time);
163+
res = outputMemory[1];
164+
}
165+
150166
void setSamplingPeriod (const double& period)
151167
{
152168
dt = period;

0 commit comments

Comments
 (0)