feature-1d.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13 
14 /* --- SOT --- */
15 #include <sot/core/debug.hh>
17 #include <sot/core/feature-1d.hh>
18 using namespace std;
19 
20 #include <sot/core/factory.hh>
21 
22 using namespace dynamicgraph::sot;
23 using namespace dynamicgraph;
25 
26 /* --------------------------------------------------------------------- */
27 /* --- CLASS ----------------------------------------------------------- */
28 /* --------------------------------------------------------------------- */
29 
30 Feature1D::Feature1D(const string &pointName)
31  : FeatureAbstract(pointName),
32  errorSIN(NULL, "sotFeature1D(" + name + ")::input(vector)::errorIN"),
33  jacobianSIN(NULL,
34  "sotFeature1D(" + name + ")::input(matrix)::jacobianIN") {
37 
39 }
40 
41 /* --------------------------------------------------------------------- */
42 /* --------------------------------------------------------------------- */
43 /* --------------------------------------------------------------------- */
44 
47 
48 /* --------------------------------------------------------------------- */
49 /* --------------------------------------------------------------------- */
50 /* --------------------------------------------------------------------- */
51 
53  sotDEBUG(25) << "# In {" << endl;
54 
55  dim = 1;
56 
57  sotDEBUG(25) << "# Out }" << endl;
58  return dim;
59 }
60 
62  sigtime_t time) {
63  const dynamicgraph::Vector &err = errorSIN.access(time);
64  res.resize(1);
65  res(0) = err.dot(err) * .5;
66 
67  return res;
68 }
69 
71  sigtime_t time) {
72  sotDEBUGIN(15);
73 
74  const dynamicgraph::Matrix &Jac = jacobianSIN.access(time);
75  const dynamicgraph::Vector &err = errorSIN.access(time);
76 
77  res.resize(1, Jac.cols());
78  res.fill(0);
79  for (size_type j = 0; j < Jac.cols(); ++j)
80  for (size_type i = 0; i < Jac.rows(); ++i) res(0, j) += err(i) * Jac(i, j);
81 
82  sotDEBUGOUT(15);
83  return res;
84 }
85 
86 /* --------------------------------------------------------------------- */
87 /* --------------------------------------------------------------------- */
88 /* --------------------------------------------------------------------- */
89 
90 void Feature1D::display(std::ostream &os) const {
91  os << "1D <" << name << ">: " << std::endl;
92 
93  try {
94  os << " error= " << errorSIN.accessCopy() << endl
95  << " J = " << jacobianSIN.accessCopy() << endl;
96  } catch (const ExceptionAbstract &e) {
97  os << " All SIN not set.";
98  }
99 }
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Feature1D, "Feature1D")
dynamicgraph::sot::FeatureAbstract::addDependenciesFromReference
virtual void addDependenciesFromReference(void)=0
feature-1d.hh
factory.hh
dynamicgraph::SignalPtr::accessCopy
virtual const T & accessCopy() const
dynamicgraph::sot::Feature1D::errorSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > errorSIN
Input for the error.
Definition: feature-1d.hh:66
dynamicgraph::sot::FeatureAbstract::errorSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > errorSOUT
This signal returns the error between the desired value and the current value : .
Definition: feature-abstract.hh:185
dynamicgraph
i
int i
dynamicgraph::Entity::name
std::string name
dynamicgraph::Matrix
Eigen::MatrixXd Matrix
dynamicgraph::sot::Feature1D
Simple test: the task is defined to be e_2 = .5 . e'.e, with e the mother task. The jacobian is then ...
Definition: feature-1d.hh:48
dynamicgraph::sot::FeatureAbstract::jacobianSOUT
SignalTimeDependent< dynamicgraph::Matrix, sigtime_t > jacobianSOUT
Jacobian of the error wrt the robot state: .
Definition: feature-abstract.hh:193
dynamicgraph::sot::FeatureAbstract
This class gives the abstract definition of a feature.
Definition: feature-abstract.hh:76
debug.hh
res
res
dynamicgraph::SignalPtr::access
virtual const T & access(const Time &t)
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dim
int dim
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::ExceptionAbstract
dynamicgraph::SignalTimeDependent::addDependency
virtual void addDependency(const SignalBase< Time > &signal)
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
dynamicgraph::sot::Feature1D::jacobianSIN
dynamicgraph::SignalPtr< dynamicgraph::Matrix, sigtime_t > jacobianSIN
Input for the Jacobian.
Definition: feature-1d.hh:69
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::FeatureAbstract::removeDependenciesFromReference
virtual void removeDependenciesFromReference(void)=0
dynamicgraph::sot::Feature1D::computeJacobian
virtual dynamicgraph::Matrix & computeJacobian(dynamicgraph::Matrix &res, sigtime_t time)
Compute the Jacobian of the value according to the robot state..
Definition: feature-1d.cpp:70
exception-feature.hh
err
err
dynamicgraph::sot::Feature1D::display
virtual void display(std::ostream &os) const
Display the information related to this 1D implementation.
Definition: feature-1d.cpp:90
dynamicgraph::sot
dynamicgraph::sot::FeatureAbstract::getDimension
size_type getDimension(void) const
Shortest method.
Definition: feature-abstract.hh:121
dynamicgraph::sot::Feature1D::computeError
virtual dynamicgraph::Vector & computeError(dynamicgraph::Vector &res, sigtime_t time)
Compute the error between the desired value and the value itself.
Definition: feature-1d.cpp:61
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
compile.name
name
Definition: compile.py:23
sotDEBUG
#define sotDEBUG(level)
Definition: debug.hh:168


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31