6 #include <dynamic-graph/factory.h> 
    9 #include <sot/core/debug.hh> 
   18 #define ALL_INPUT_SIGNALS m_xSIN 
   20 #define ALL_OUTPUT_SIGNALS m_x_filteredSOUT << m_dxSOUT << m_ddxSOUT 
   24 using namespace dynamicgraph::command;
 
   25 using namespace Eigen;
 
   40       CONSTRUCT_SIGNAL_OUT(x_filtered, 
dynamicgraph::Vector, m_x_dx_ddxSINNER),
 
   41       CONSTRUCT_SIGNAL_OUT(dx, 
dynamicgraph::Vector, m_x_dx_ddxSINNER),
 
   42       CONSTRUCT_SIGNAL_OUT(ddx, 
dynamicgraph::Vector, m_x_dx_ddxSINNER),
 
   43       CONSTRUCT_SIGNAL_INNER(x_dx_ddx, 
dynamicgraph::Vector, m_xSIN) {
 
   49       makeDirectGetter(*
this, &
m_dt,
 
   50                        docDirectGetter(
"Control timestep [s ]", 
"double")));
 
   55           docDirectGetter(
"Delay in the estimation of signal x", 
"double")));
 
   57              makeDirectGetter(*
this, &
x_size,
 
   58                               docDirectGetter(
"Size of the x signal", 
"int")));
 
   61                               docCommandVoid4(
"Initialize the estimator.",
 
   62                                               "Control timestep [s].",
 
   63                                               "Size of the input signal x",
 
   64                                               "Estimation delay for signal x",
 
   65                                               "Polynomial order")));
 
   72                                const double& delay, 
const int& polyOrder) {
 
   73   assert(timestep > 0.0 && 
"Timestep should be > 0");
 
   74   assert(delay >= 1.5 * timestep &&
 
   75          "Estimation delay should be >= 1.5*timestep");
 
   79   int winSizeEnc = (int)(2 * delay / 
m_dt);
 
   80   assert(winSizeEnc >= 3 && 
"Estimation-window's length should be >= 3");
 
   84   else if (polyOrder == 2)
 
   87     SEND_MSG(
"Only polynomial orders 1 and 2 allowed. Reinitialize the filter",
 
  101   sotDEBUG(15) << 
"Compute x_dx_ddx inner signal " << iter << std::endl;
 
  104   const dynamicgraph::Vector& base_x = m_xSIN(iter);
 
  108   m_filter->estimate(m_x_filter_std, m_x_std);
 
  109   m_filter->getEstimateDerivative(m_dx_filter_std, 1);
 
  110   m_filter->getEstimateDerivative(m_ddx_filter_std, 2);
 
  113   if (s.size() != 3 * x_size) s.resize(3 * x_size);
 
  114   for (
int i = 0; i < x_size; i++) s(i) = m_x_filter_std[i];
 
  115   for (
int i = 0; i < x_size; i++) s(i + x_size) = m_dx_filter_std[i];
 
  116   for (
int i = 0; i < x_size; i++) s(i + 2 * x_size) = m_ddx_filter_std[i];
 
  128   sotDEBUG(15) << 
"Compute x_filtered output signal " << iter << std::endl;
 
  130   const dynamicgraph::Vector& x_dx_ddx = m_x_dx_ddxSINNER(iter);
 
  131   if (s.size() != x_size) s.resize(x_size);
 
  132   s = x_dx_ddx.head(x_size);
 
  137   sotDEBUG(15) << 
"Compute dx output signal " << iter << std::endl;
 
  139   const dynamicgraph::Vector& x_dx_ddx = m_x_dx_ddxSINNER(iter);
 
  140   if (s.size() != x_size) s.resize(x_size);
 
  141   s = x_dx_ddx.segment(x_size, x_size);
 
  146   sotDEBUG(15) << 
"Compute ddx output signal " << iter << std::endl;
 
  148   const dynamicgraph::Vector& x_dx_ddx = m_x_dx_ddxSINNER(iter);
 
  149   if (s.size() != x_size) s.resize(x_size);
 
  150   s = x_dx_ddx.segment(2 * x_size, x_size);
 
  155   os << 
"NumericalDifference " << getName() << 
":\n";
 
  157     getProfiler().report_all(3, os);
 
  158   } 
catch (ExceptionSignal e) {
 
EIGEN_MAKE_ALIGNED_OPERATOR_NEW NumericalDifference(const std::string &name)
 
PolyEstimator * m_filter
x signal
 
std::vector< double > m_ddx_filter_std
 
virtual void display(std::ostream &os) const
 
void init(const double ×tep, const int &sigSize, const double &delay, const int &polyOrder)
 
int x_size
delay introduced by the estimation
 
std::vector< double > m_x_filter_std
1st derivative
 
double m_delay
sampling timestep of the input signal
 
std::vector< double > m_dx_filter_std
2nd derivative
 
std::vector< double > m_x_std
filtered output
 
DEFINE_SIGNAL_OUT_FUNCTION(u, dynamicgraph::Vector)
 
AdmittanceController EntityClassName
 
DEFINE_SIGNAL_INNER_FUNCTION(kinematics_computations, dynamicgraph::Vector)
 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(AdmittanceController, "AdmittanceController")
 
#define ALL_OUTPUT_SIGNALS
 
#define ALL_INPUT_SIGNALS
 
#define COPY_VECTOR_TO_ARRAY(src, dest)