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) {
86 }
87 
89  if (isReferenceSet())
90  return getReferenceAbstract()->getName();
91  else
92  return "none";
93 }
94 
96  dynamicgraph::Vector &res, sigtime_t time) {
97  const Flags &fl = selectionSIN.access(time);
98  const size_type &dim = dimensionSOUT(time);
99 
100  std::size_t 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 (size_type i = 0; i < errdotDes.size(); ++i)
118  if (fl(i)) res(curr++) = -errdotDes(i);
119  } else
120  res.setZero();
121 
122  return res;
123 }
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::sot::FeatureAbstract::initCommands
void initCommands(void)
Definition: feature-abstract.cpp:52
dynamicgraph::sot::FeatureAbstract::featureRegistration
void featureRegistration(void)
Register the feature in the stack of tasks.
Definition: feature-abstract.cpp:66
i
int i
dynamicgraph::Entity
dynamicgraph::Entity::writeGraph
virtual std::ostream & writeGraph(std::ostream &os) const
dynamicgraph::sot::FeatureAbstract::setReference
virtual void setReference(FeatureAbstract *sdes)=0
boost
dynamicgraph::sot::FeatureAbstract::selectionSIN
SignalPtr< Flags, sigtime_t > selectionSIN
This vector specifies which dimension are used to perform the computation. For instance let us assume...
Definition: feature-abstract.hh:173
dynamicgraph::Entity::name
std::string name
dynamicgraph::sot::FeatureAbstract::jacobianSOUT
SignalTimeDependent< dynamicgraph::Matrix, sigtime_t > jacobianSOUT
Jacobian of the error wrt the robot state: .
Definition: feature-abstract.hh:193
feature-abstract.hh
dynamicgraph::sot::FeatureAbstract::FeatureAbstract
FeatureAbstract(const std::string &name)
Default constructor: the name of the class should be given.
Definition: feature-abstract.cpp:24
dynamicgraph::sot::FeatureAbstract
This class gives the abstract definition of a feature.
Definition: feature-abstract.hh:76
dynamicgraph::Entity::getName
const std::string & getName() const
debug.hh
res
res
dim
int dim
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::FeatureAbstract::CLASS_NAME
static const std::string CLASS_NAME
Store the name of the class.
Definition: feature-abstract.hh:79
dynamicgraph::sot::FeatureAbstract::writeGraph
virtual std::ostream & writeGraph(std::ostream &os) const
This method write a graph description on the file named FileName.
Definition: feature-abstract.cpp:70
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
exception-feature.hh
pool.hh
dynamicgraph::sot::ExceptionFeature
Definition: exception-feature.hh:29
dynamicgraph::sot::FeatureAbstract::getReferenceByName
std::string getReferenceByName(void) const
Definition: feature-abstract.cpp:88
dynamicgraph::PoolStorage::getInstance
static PoolStorage * getInstance()
Definition: pool.cpp:147
dynamicgraph::sot::FeatureAbstract::setReferenceByName
void setReferenceByName(const std::string &name)
Definition: feature-abstract.cpp:83
dynamicgraph::sot
dynamicgraph::sot::FeatureAbstract::computeErrorDot
virtual dynamicgraph::Vector & computeErrorDot(dynamicgraph::Vector &res, sigtime_t time)
Definition: feature-abstract.cpp:95
dynamicgraph::sot::FeatureAbstract::getReferenceAbstract
virtual const FeatureAbstract * getReferenceAbstract(void) const =0
dynamicgraph::SignalPtr::isPlugged
virtual bool isPlugged() const
dynamicgraph::Entity::addCommand
void addCommand(const std::string &name, command::Command *command)
dynamicgraph::sot::FeatureAbstract::dimensionSOUT
SignalTimeDependent< size_type, sigtime_t > dimensionSOUT
Returns the dimension of the feature as an output signal.
Definition: feature-abstract.hh:196
dynamicgraph::sot::FeatureAbstract::errordotSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > errordotSIN
Derivative of the reference value.
Definition: feature-abstract.hh:176
all-commands.h
dynamicgraph::sot::Flags
Definition: flags.hh:33
SOT_THROW
#define SOT_THROW
Definition: exception-abstract.hh:130
dynamicgraph::command::Setter
dynamicgraph::sot::FeatureAbstract::isReferenceSet
virtual bool isReferenceSet(void) const
Definition: feature-abstract.hh:217
dynamicgraph::command::Getter
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
compile.name
name
Definition: compile.py:23
dynamicgraph::sot::ExceptionFeature::UNCOMPATIBLE_SIZE
@ UNCOMPATIBLE_SIZE
Definition: exception-feature.hh:36
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