dynamicgraph::agimus::SafeGainAdaptive Class Reference

Exponentially decreasing gain that is safer than dynamicgraph::sot::core::GainAdaptive. More...

#include <gain-adaptive.hh>

Inheritance diagram for dynamicgraph::agimus::SafeGainAdaptive:
[legend]
Collaboration diagram for dynamicgraph::agimus::SafeGainAdaptive:
[legend]

Public Member Functions

virtual void display (std::ostream &os) const
 
virtual const std::string & getClassName (void) const
 
 SafeGainAdaptive (const std::string &name)
 
void setParameters (const double &a, const double &b, const double &c, const double &d)
 Set the gain parameters. More...
 
void computeParameters (const double &valueAt0, const double &valueAtInfty, const double &errNormOfMaxExp, const double &errNormOfHalfHyp)
 Compute the parameters from specific values. More...
 

Public Attributes

SignalPtr< Vector, int > errorSIN
 
SignalTimeDependent< double, int > gainSOUT
 

Static Public Attributes

static const std::string CLASS_NAME
 

Protected Member Functions

double & computeGain (double &res, int t)
 

Protected Attributes

double a
 
double b
 
double c
 
double d
 
Vector cs
 

Detailed Description

Exponentially decreasing gain that is safer than dynamicgraph::sot::core::GainAdaptive.

It follows the law

\[ g(e) = a \exp (-b ||e||) + c \frac{\tanh(d ||e||)}{||e||} \]

.

Use the following code to see the curves:

import numpy, matplotlib.pyplot as plt
gain = SafeGainAdaptive('g')
#g.computeParameters(0.1, 1., 0.1, 2.)
errors = numpy.linspace(0, 5., 1000)
def compute(e):
t = gain.error.time + 1
gain.error.value = (e,)
gain.error.time = t
gain.gain.recompute(t)
return gain.gain.value
gains = [ compute(e) for e in errors ]
lg = plt.plot(errors, gains, 'r', label="Gain")
ld = plt.twinx().plot(errors, [ g*e for e,g in zip(errors,gains) ], 'b', label="Derivative")
lines = lg + ld
plt.legend(lines, [l.get_label() for l in lines])
plt.show()

Constructor & Destructor Documentation

◆ SafeGainAdaptive()

SafeGainAdaptive::SafeGainAdaptive ( const std::string &  name)

Member Function Documentation

◆ computeGain()

double & SafeGainAdaptive::computeGain ( double &  res,
int  t 
)
protected

References a, b, c, cs, d, and errorSIN.

◆ computeParameters()

void SafeGainAdaptive::computeParameters ( const double &  valueAt0,
const double &  valueAtInfty,
const double &  errNormOfMaxExp,
const double &  errNormOfHalfHyp 
)

Compute the parameters from specific values.

Parameters
valueAt0value of the gain at zero,
valueAtInftyvalue of $ gain(||e||) ||e|| $ when $ ||e||\to\infty $
errNormOfMaxExpnorm of the error for which the exponential part is maximum
errNormOfSwitchnorm of the error for which the hyperbolic part is half of its final value

References a, b, c, d, and setParameters().

Referenced by SafeGainAdaptive().

◆ display()

void SafeGainAdaptive::display ( std::ostream &  os) const
virtual

References cs, and gainSOUT.

◆ getClassName()

virtual const std::string& dynamicgraph::agimus::SafeGainAdaptive::getClassName ( void  ) const
inlinevirtual

◆ setParameters()

void SafeGainAdaptive::setParameters ( const double &  a,
const double &  b,
const double &  c,
const double &  d 
)

Set the gain parameters.

Parameters
a,b,c,dthe gain parameters.

References a, b, c, cs, and d.

Referenced by computeParameters().

Member Data Documentation

◆ a

double dynamicgraph::agimus::SafeGainAdaptive::a
protected

◆ b

double dynamicgraph::agimus::SafeGainAdaptive::b
protected

◆ c

double dynamicgraph::agimus::SafeGainAdaptive::c
protected

◆ CLASS_NAME

const std::string dynamicgraph::agimus::SafeGainAdaptive::CLASS_NAME
static

◆ cs

Vector dynamicgraph::agimus::SafeGainAdaptive::cs
protected

Referenced by computeGain(), display(), and setParameters().

◆ d

double dynamicgraph::agimus::SafeGainAdaptive::d
protected

◆ errorSIN

SignalPtr<Vector, int> dynamicgraph::agimus::SafeGainAdaptive::errorSIN

Referenced by computeGain(), and SafeGainAdaptive().

◆ gainSOUT

SignalTimeDependent<double, int> dynamicgraph::agimus::SafeGainAdaptive::gainSOUT

Referenced by display(), and SafeGainAdaptive().