GCC Code Coverage Report


Directory: ./
File: include/sot/core/feature-generic.hh
Date: 2024-11-13 12:35:17
Exec Total Coverage
Lines: 2 3 66.7%
Branches: 2 6 33.3%

Line Branch Exec Source
1 /*
2 * Copyright 2010,
3 * François Bleibel,
4 * Olivier Stasse,
5 *
6 * CNRS/AIST
7 *
8 */
9
10 #ifndef __SOT_FEATURE_GENERIC_HH__
11 #define __SOT_FEATURE_GENERIC_HH__
12
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16
17 /* SOT */
18 #include <sot/core/exception-task.hh>
19 #include <sot/core/feature-abstract.hh>
20
21 /* --------------------------------------------------------------------- */
22 /* --- API ------------------------------------------------------------- */
23 /* --------------------------------------------------------------------- */
24
25 #if defined(WIN32)
26 #if defined(feature_generic_EXPORTS)
27 #define SOTFEATUREGENERIC_EXPORT __declspec(dllexport)
28 #else
29 #define SOTFEATUREGENERIC_EXPORT __declspec(dllimport)
30 #endif
31 #else
32 #define SOTFEATUREGENERIC_EXPORT
33 #endif
34
35 /* --------------------------------------------------------------------- */
36 /* --- CLASS ----------------------------------------------------------- */
37 /* --------------------------------------------------------------------- */
38
39 namespace dynamicgraph {
40 namespace sot {
41
42 /*!
43 \class FeatureGeneric
44 \brief Class that defines a generic implementation of the abstract interface
45 for features.
46
47 This class is very useful if the feature can be easily computed using
48 the basic operator provided. For instance a free space controller on a
49 end-effector is basically directly computed from the Jacobian provided
50 by dyn and some appropriate addition and soustraction.
51 Instead of building a specific feature for this, it is possible to use the
52 signals and plug the computed error, Jacobian and activation to the input
53 of this generic feature implementation.
54
55 */
56 class SOTFEATUREGENERIC_EXPORT FeatureGeneric
57 : public FeatureAbstract,
58 FeatureReferenceHelper<FeatureGeneric> {
59 public:
60 /*! Field storing the class name. */
61 static const std::string CLASS_NAME;
62 /*! Returns the name of the class. */
63 virtual const std::string &getClassName(void) const { return CLASS_NAME; }
64
65 protected:
66 dynamicgraph::Vector::Index dimensionDefault;
67
68 /* --- SIGNALS ------------------------------------------------------------ */
69 public:
70 /*! \name dynamicgraph::Signals
71 @{
72 */
73 /*! \name Input signals
74 @{
75 */
76 /*! \brief Input for the error. */
77 dynamicgraph::SignalPtr<dynamicgraph::Vector, int> errorSIN;
78
79 /*! \brief Input for the Jacobian. */
80 dynamicgraph::SignalPtr<dynamicgraph::Matrix, int> jacobianSIN;
81
82 /*! @} */
83
84 /*! \name Output signals
85 @{
86 */
87 /*! \brief Publish the jacobian of the feature according to the robot state.
88 */
89 using FeatureAbstract::jacobianSOUT;
90
91 /*! \brief Publish the error between the desired and the current value of the
92 feature. */
93 using FeatureAbstract::errorSOUT;
94
95 public:
96 /*! \brief Default constructor */
97 FeatureGeneric(const std::string &name);
98
99 /*! \brief Default destructor */
100 4 virtual ~FeatureGeneric(void) {}
101
102 /*! \brief Get the dimension of the feature. */
103 virtual unsigned int &getDimension(unsigned int &dim, int time);
104
105 /*! \name Methods to trigger computation related to this feature.
106 @{
107 */
108
109 /*! \brief Compute the error between the desired value and the value itself.
110 */
111 virtual dynamicgraph::Vector &computeError(dynamicgraph::Vector &res,
112 int time);
113
114 /*! \brief Compute the Jacobian of the value according to the robot state.. */
115 virtual dynamicgraph::Matrix &computeJacobian(dynamicgraph::Matrix &res,
116 int time);
117
118 /*! @} */
119
120 /*! \brief Display the information related to this generic implementation. */
121 virtual void display(std::ostream &os) const;
122
123 /*! \name Dealing with the reference value to be reach with this feature.
124 @{
125 */
126
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
81 DECLARE_REFERENCE_FUNCTIONS(FeatureGeneric);
127 /*! @} */
128 };
129
130 } /* namespace sot */
131 } /* namespace dynamicgraph */
132
133 #endif // #ifndef __SOT_FEATURE_GENERIC_HH__
134
135 /*
136 * Local variables:
137 * c-basic-offset: 2
138 * End:
139 */
140