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 
52 unsigned int &Feature1D::getDimension(unsigned int &dim, int /*time*/) {
53  sotDEBUG(25) << "# In {" << endl;
54 
55  dim = 1;
56 
57  sotDEBUG(25) << "# Out }" << endl;
58  return dim;
59 }
60 
62  int 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  int 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 (int j = 0; j < Jac.cols(); ++j)
80  for (int 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 (ExceptionAbstract e) {
97  os << " All SIN not set.";
98  }
99 }
virtual void removeDependenciesFromReference(void)=0
Eigen::VectorXd Vector
int i
void signalRegistration(const SignalArray< int > &signals)
#define sotDEBUGOUT(level)
Definition: debug.hh:212
virtual dynamicgraph::Vector & computeError(dynamicgraph::Vector &res, int time)
Compute the error between the desired value and the value itself.
Definition: feature-1d.cpp:61
#define sotDEBUGIN(level)
Definition: debug.hh:211
SignalTimeDependent< dynamicgraph::Matrix, int > jacobianSOUT
Jacobian of the error wrt the robot state: .
unsigned int getDimension(void) const
Shortest method.
dynamicgraph::SignalPtr< dynamicgraph::Matrix, int > jacobianSIN
Input for the Jacobian.
Definition: feature-1d.hh:69
Simple test: the task is defined to be e_2 = .5 . e&#39;.e, with e the mother task. The jacobian is then ...
Definition: feature-1d.hh:48
virtual void display(std::ostream &os) const
Display the information related to this 1D implementation.
Definition: feature-1d.cpp:90
virtual const T & access(const Time &t)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Feature1D, "Feature1D")
virtual void addDependency(const SignalBase< Time > &signal)
virtual dynamicgraph::Matrix & computeJacobian(dynamicgraph::Matrix &res, int time)
Compute the Jacobian of the value according to the robot state..
Definition: feature-1d.cpp:70
virtual const T & accessCopy() const
#define sotDEBUG(level)
Definition: debug.hh:165
This class gives the abstract definition of a feature.
Eigen::MatrixXd Matrix
virtual void addDependenciesFromReference(void)=0
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > errorSIN
Input for the error.
Definition: feature-1d.hh:66
SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
This signal returns the error between the desired value and the current value : . ...
err


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26