feature-abstract.hh
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 #ifndef __SOT_FEATURE_ABSTRACT_H__
11 #define __SOT_FEATURE_ABSTRACT_H__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
19 
20 /* SOT */
22 #include <dynamic-graph/entity.h>
23 
24 #include <sot/core/flags.hh>
25 #include <sot/core/pool.hh>
26 
27 #include "sot/core/api.hh"
28 
29 /* STD */
30 #include <string>
31 
32 namespace dynamicgraph {
33 namespace sot {
34 
35 /* --------------------------------------------------------------------- */
36 /* --- CLASS ----------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38 
77  public:
79  static const std::string CLASS_NAME;
80 
82  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
83 
85  void featureRegistration(void);
86 
87  void initCommands(void);
88 
89  public:
91  FeatureAbstract(const std::string &name);
93  virtual ~FeatureAbstract(void){};
94 
104  virtual size_type &getDimension(size_type &res, sigtime_t time) = 0;
105 
112  size_type res;
113  getDimension(res, time);
114  return res;
115  }
116 
121  inline size_type getDimension(void) const {
122  return dimensionSOUT.accessCopy();
123  }
140  virtual dynamicgraph::Vector &computeError(dynamicgraph::Vector &res,
141  sigtime_t time) = 0;
142 
148  virtual dynamicgraph::Matrix &computeJacobian(dynamicgraph::Matrix &res,
149  sigtime_t time) = 0;
150 
155  virtual dynamicgraph::Vector &computeErrorDot(dynamicgraph::Vector &res,
156  sigtime_t time);
157 
160  /* --- SIGNALS ------------------------------------------------------------ */
161  public:
174 
177 
186 
190 
194 
197 
200  virtual std::ostream &writeGraph(std::ostream &os) const;
201 
203  return errordotSOUT;
204  }
205 
208  /* --- REFERENCE VALUE S* ------------------------------------------------- */
209  public:
213  virtual void setReference(FeatureAbstract *sdes) = 0;
214  virtual void unsetReference(void) { setReference(NULL); }
215  virtual const FeatureAbstract *getReferenceAbstract(void) const = 0;
216  virtual FeatureAbstract *getReferenceAbstract(void) = 0;
217  virtual bool isReferenceSet(void) const { return false; }
218 
219  virtual void addDependenciesFromReference(void) = 0;
220  virtual void removeDependenciesFromReference(void) = 0;
221 
222  /* Commands for bindings. */
223  void setReferenceByName(const std::string &name);
224  std::string getReferenceByName(void) const;
226 };
227 
228 template <class FeatureSpecialized>
230  FeatureSpecialized *ptr;
232 
233  public:
234  FeatureReferenceHelper(void) : ptr(NULL) {}
235 
236  void setReference(FeatureAbstract *sdes);
237  // void setReferenceByName( const std::string & name );
238  void unsetReference(void) { setReference(NULL); }
239  bool isReferenceSet(void) const { return ptr != NULL; }
240  FeatureSpecialized *getReference(void) { return ptr; }
241  const FeatureSpecialized *getReference(void) const { return ptr; }
242 };
243 
244 template <class FeatureSpecialized>
246  FeatureAbstract *sdes) {
247  ptr = dynamic_cast<FeatureSpecialized *>(sdes);
248  ptrA = ptr;
249 }
250 
251 #define DECLARE_REFERENCE_FUNCTIONS(FeatureSpecialized) \
252  typedef FeatureReferenceHelper<FeatureSpecialized> SP; \
253  virtual void setReference(FeatureAbstract *sdes) { \
254  if (sdes == NULL) { \
255  /* UNSET */ \
256  if (SP::isReferenceSet()) removeDependenciesFromReference(); \
257  SP::unsetReference(); \
258  } else { \
259  /* SET */ \
260  SP::setReference(sdes); \
261  if (SP::isReferenceSet()) addDependenciesFromReference(); \
262  } \
263  } \
264  virtual const FeatureAbstract *getReferenceAbstract(void) const { \
265  return SP::getReference(); \
266  } \
267  virtual FeatureAbstract *getReferenceAbstract(void) { \
268  return (FeatureAbstract *)SP::getReference(); \
269  } \
270  bool isReferenceSet(void) const { return SP::isReferenceSet(); } \
271  virtual void addDependenciesFromReference(void); \
272  virtual void removeDependenciesFromReference(void)
273 /* END OF define DECLARE_REFERENCE_FUNCTIONS */
274 
275 #define DECLARE_NO_REFERENCE \
276  virtual void setReference(FeatureAbstract *) {} \
277  virtual const FeatureAbstract *getReferenceAbstract(void) const { \
278  return NULL; \
279  } \
280  virtual FeatureAbstract *getReferenceAbstract(void) { return NULL; } \
281  virtual void addDependenciesFromReference(void) {} \
282  virtual void removeDependenciesFromReference(void) {} \
283  /* To force a ; */ bool NO_REFERENCE
284 /* END OF define DECLARE_REFERENCE_FUNCTIONS */
285 
286 } // namespace sot
287 } // namespace dynamicgraph
288 
289 #endif // #ifndef __SOT_FEATURE_ABSTRACT_H__
dynamicgraph::sot::FeatureReferenceHelper::ptrA
FeatureAbstract * ptrA
Definition: feature-abstract.hh:231
SOT_CORE_EXPORT
#define SOT_CORE_EXPORT
Definition: api.hh:20
dynamicgraph::sot::FeatureAbstract::~FeatureAbstract
virtual ~FeatureAbstract(void)
Default destructor.
Definition: feature-abstract.hh:93
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::FeatureReferenceHelper
Definition: feature-abstract.hh:229
dynamicgraph::SignalPtr
dynamicgraph
dynamicgraph::sot::FeatureReferenceHelper::getReference
FeatureSpecialized * getReference(void)
Definition: feature-abstract.hh:240
dynamicgraph::Entity
dynamicgraph::sot::FeatureAbstract::getClassName
virtual const std::string & getClassName(void) const
Returns the name class.
Definition: feature-abstract.hh:82
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::Matrix
Eigen::MatrixXd Matrix
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::unsetReference
virtual void unsetReference(void)
Definition: feature-abstract.hh:214
dynamicgraph::sot::FeatureAbstract
This class gives the abstract definition of a feature.
Definition: feature-abstract.hh:76
res
res
dynamicgraph::sot::FeatureReferenceHelper::setReference
void setReference(FeatureAbstract *sdes)
Definition: feature-abstract.hh:245
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::FeatureReferenceHelper::FeatureReferenceHelper
FeatureReferenceHelper(void)
Definition: feature-abstract.hh:234
dynamicgraph::sot::FeatureAbstract::errordotSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > errordotSOUT
Derivative of the error with respect to time: .
Definition: feature-abstract.hh:189
dynamicgraph::sot::FeatureAbstract::CLASS_NAME
static const std::string CLASS_NAME
Store the name of the class.
Definition: feature-abstract.hh:79
api.hh
dynamicgraph::sot::FeatureReferenceHelper::unsetReference
void unsetReference(void)
Definition: feature-abstract.hh:238
dynamicgraph::sot::FeatureReferenceHelper::getReference
const FeatureSpecialized * getReference(void) const
Definition: feature-abstract.hh:241
all-signals.h
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
flags.hh
linear-algebra.h
pool.hh
dynamicgraph::sot::FeatureAbstract::getDimension
size_type getDimension(sigtime_t time)
Short method.
Definition: feature-abstract.hh:111
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t >
dynamicgraph::sot::FeatureAbstract::getDimension
size_type getDimension(void) const
Shortest method.
Definition: feature-abstract.hh:121
dynamicgraph::sot::FeatureAbstract::getErrorDot
virtual SignalTimeDependent< dynamicgraph::Vector, sigtime_t > & getErrorDot()
Definition: feature-abstract.hh:202
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
dynamicgraph::sot::FeatureAbstract::isReferenceSet
virtual bool isReferenceSet(void) const
Definition: feature-abstract.hh:217
writeGraph
void writeGraph(const char *filename)
dynamicgraph::sot::FeatureReferenceHelper::ptr
FeatureSpecialized * ptr
Definition: feature-abstract.hh:230
dynamicgraph::sot::FeatureReferenceHelper::isReferenceSet
bool isReferenceSet(void) const
Definition: feature-abstract.hh:239
compile.name
name
Definition: compile.py:23


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