feature-abstract.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 
11 
12 #include <iostream>
14 #include <sot/core/pool.hh>
15 
16 #include "sot/core/debug.hh"
18 
19 using namespace dynamicgraph::sot;
21 
22 const std::string FeatureAbstract::CLASS_NAME = "FeatureAbstract";
23 
25  : Entity(name),
26  selectionSIN(NULL,
27  "sotFeatureAbstract(" + name + ")::input(flag)::selec"),
28  errordotSIN(
29  NULL, "sotFeatureAbstract(" + name + ")::input(vector)::errordotIN"),
30  errorSOUT(boost::bind(&FeatureAbstract::computeError, this, _1, _2),
31  selectionSIN,
32  "sotFeatureAbstract(" + name + ")::output(vector)::error"),
33  errordotSOUT(boost::bind(&FeatureAbstract::computeErrorDot, this, _1, _2),
34  selectionSIN << errordotSIN,
35  "sotFeatureAbstract(" + name + ")::output(vector)::errordot")
36 
37  ,
38  jacobianSOUT(
39  boost::bind(&FeatureAbstract::computeJacobian, this, _1, _2),
40  selectionSIN,
41  "sotFeatureAbstract(" + name + ")::output(matrix)::jacobian"),
42  dimensionSOUT(boost::bind(&FeatureAbstract::getDimension, this, _1, _2),
43  selectionSIN,
44  "sotFeatureAbstract(" + name + ")::output(uint)::dim") {
45  selectionSIN = true;
47  << dimensionSOUT);
49  initCommands();
50 }
51 
53  using namespace command;
54  addCommand("setReference",
57  "Give the name of the reference feature.\nInput: a string "
58  "(feature name)."));
59  addCommand("getReference",
62  "Get the name of the reference feature.\nOutput: a string "
63  "(feature name)."));
64 }
65 
67  PoolStorage::getInstance()->registerFeature(name, this);
68 }
69 
70 std::ostream &FeatureAbstract::writeGraph(std::ostream &os) const {
72 
73  if (isReferenceSet()) {
74  const FeatureAbstract *asotFA = getReferenceAbstract();
75  os << "\t\"" << asotFA->getName() << "\" -> \"" << getName() << "\""
76  << "[ color=darkseagreen4 ]" << std::endl;
77  } else
78  std::cout << "asotFAT : 0" << std::endl;
79 
80  return os;
81 }
82 
83 void FeatureAbstract::setReferenceByName(const std::string &name) {
85  &dynamicgraph::sot::PoolStorage::getInstance()->getFeature(name));
86 }
87 
89  if (isReferenceSet())
90  return getReferenceAbstract()->getName();
91  else
92  return "none";
93 }
94 
96  dynamicgraph::Vector &res, int time) {
97  const Flags &fl = selectionSIN.access(time);
98  const int &dim = dimensionSOUT(time);
99 
100  unsigned int curr = 0;
101  res.resize(dim);
102 
103  sotDEBUG(25) << "Dim = " << dim << std::endl;
104 
106  const dynamicgraph::Vector &errdotDes =
108  sotDEBUG(15) << "Err* = " << errdotDes;
109  if (errdotDes.size() < dim) {
112  "Error: dimension uncompatible with des->errorIN size."
113  " (while considering feature <%s>).",
114  getName().c_str());
115  }
116 
117  for (int i = 0; i < errdotDes.size(); ++i)
118  if (fl(i)) res(curr++) = -errdotDes(i);
119  } else
120  res.setZero();
121 
122  return res;
123 }
#define SOT_THROW
Eigen::VectorXd Vector
std::string getReferenceByName(void) const
SignalPtr< Flags, int > selectionSIN
This vector specifies which dimension are used to perform the computation. For instance let us assume...
void setReferenceByName(const std::string &name)
int i
virtual const FeatureAbstract * getReferenceAbstract(void) const =0
SignalTimeDependent< unsigned int, int > dimensionSOUT
Returns the dimension of the feature as an output signal.
void signalRegistration(const SignalArray< int > &signals)
virtual std::ostream & writeGraph(std::ostream &os) const
virtual bool isReferenceSet(void) const
static const std::string CLASS_NAME
Store the name of the class.
int dim
SignalTimeDependent< dynamicgraph::Matrix, int > jacobianSOUT
Jacobian of the error wrt the robot state: .
SignalPtr< dynamicgraph::Vector, int > errordotSIN
Derivative of the reference value.
virtual const T & access(const Time &t)
static PoolStorage * getInstance()
Definition: pool.cpp:147
virtual void setReference(FeatureAbstract *sdes)=0
FeatureAbstract(const std::string &name)
Default constructor: the name of the class should be given.
#define sotDEBUG(level)
Definition: debug.hh:165
virtual bool isPlugged() const
This class gives the abstract definition of a feature.
const std::string & getName() const
virtual dynamicgraph::Vector & computeErrorDot(dynamicgraph::Vector &res, int time)
virtual std::ostream & writeGraph(std::ostream &os) const
This method write a graph description on the file named FileName.
void featureRegistration(void)
Register the feature in the stack of tasks.
void addCommand(const std::string &name, command::Command *command)
SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
This signal returns the error between the desired value and the current value : . ...


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