7 #ifndef NUKLEI_DESCRIPTOR_H
8 #define NUKLEI_DESCRIPTOR_H
11 #include <boost/utility.hpp>
23 typedef NUKLEI_UNIQUE_PTR< Descriptor > ptr;
27 virtual void assertConsistency()
const = 0;
29 virtual NUKLEI_UNIQUE_PTR<Descriptor> clone()
const = 0;
30 virtual NUKLEI_UNIQUE_PTR<Descriptor> create()
const = 0;
32 virtual double distanceTo(
const Descriptor &d)
const
40 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
41 template<
class Archive>
42 void serialize(Archive &ar,
const unsigned int version)
50 return d.clone().release();
56 typedef NUKLEI_UNIQUE_PTR< VisualDescriptor > ptr;
58 virtual void setColor(
const Color& c) = 0;
61 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
62 template<
class Archive>
63 void serialize(Archive &ar,
const unsigned int version)
72 typedef NUKLEI_UNIQUE_PTR< ColorDescriptor > ptr;
76 virtual void assertConsistency()
const
78 color_->assertConsistency();
81 NUKLEI_UNIQUE_PTR<Descriptor> clone()
const
84 c->color_ = color_->clone();
85 return NUKLEI_UNIQUE_PTR<Descriptor>(NUKLEI_MOVE(c));
88 NUKLEI_UNIQUE_PTR<Descriptor> create()
const
93 Color& getColor() {
return *color_; }
94 const Color& getColor()
const {
return *color_; }
95 void setColor(
const Color& c) { color_ = c.clone(); }
100 NUKLEI_UNIQUE_PTR<Color> color_;
102 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
103 template<
class Archive>
104 void serialize(Archive &ar,
const unsigned int version)
106 ar & NUKLEI_SERIALIZATION_MAKE_NVP
109 ar & NUKLEI_SERIALIZATION_NVP(color_);
119 typedef NUKLEI_UNIQUE_PTR< ColorPairDescriptor > ptr;
123 virtual void assertConsistency()
const
125 leftColor_->assertConsistency();
126 rightColor_->assertConsistency();
129 NUKLEI_UNIQUE_PTR<Descriptor> clone()
const
132 pair->leftColor_ = leftColor_->clone();
133 pair->rightColor_ = rightColor_->clone();
134 return NUKLEI_UNIQUE_PTR<Descriptor>(NUKLEI_MOVE(pair));
137 NUKLEI_UNIQUE_PTR<Descriptor> create()
const
142 Color& getLeftColor() {
return *leftColor_; }
143 const Color& getLeftColor()
const {
return *leftColor_; }
144 void setLeftColor(
const Color& c) { leftColor_ = c.clone(); }
146 Color& getRightColor() {
return *rightColor_; }
147 const Color& getRightColor()
const {
return *rightColor_; }
148 void setRightColor(
const Color& c) { rightColor_ = c.clone(); }
150 void setColor(
const Color& c) { rightColor_ = c.clone(); leftColor_ = c.clone(); }
155 NUKLEI_UNIQUE_PTR<Color> leftColor_;
156 NUKLEI_UNIQUE_PTR<Color> rightColor_;
158 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
159 template<
class Archive>
160 void serialize(Archive &ar,
const unsigned int version)
162 ar & NUKLEI_SERIALIZATION_MAKE_NVP
165 ar & NUKLEI_SERIALIZATION_NVP(leftColor_);
166 ar & NUKLEI_SERIALIZATION_NVP(rightColor_);
175 typedef NUKLEI_UNIQUE_PTR< GraspDescriptor > ptr;
176 typedef enum { PHYSICAL_SUCCESS = 0,
185 typedef TrialOutcome Type;
186 static const Type defaultType = UNKNOWN;
187 static const std::string TypeNames[];
191 TrialOutcome getTrialOutcome()
const {
return trialOutcome_; }
192 void setTrialOutcome(
const TrialOutcome trialOutcome) { trialOutcome_ = trialOutcome; }
194 std::vector<weight_t> getQuality()
const {
return graspQuality_; }
195 void setQuality(
const std::vector<weight_t> q) { graspQuality_ = q; }
199 TrialOutcome trialOutcome_;
200 std::vector<weight_t> graspQuality_;
201 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
202 template<
class Archive>
203 void serialize(Archive &ar,
const unsigned int version)
207 ar & NUKLEI_SERIALIZATION_MAKE_NVP
215 else if (version >= 2)
217 std::string trialOutcome = nameFromType<GraspDescriptor>(trialOutcome_);
218 ar & NUKLEI_SERIALIZATION_MAKE_NVP(
"trialOutcome",
220 trialOutcome_ = typeFromName<GraspDescriptor>(trialOutcome);
224 ar & NUKLEI_SERIALIZATION_NVP(graspQuality_);
233 typedef NUKLEI_UNIQUE_PTR< TwoFingerDescriptor > ptr;
237 virtual void assertConsistency()
const
239 NUKLEI_TRACE_BEGIN();
244 NUKLEI_UNIQUE_PTR<Descriptor> clone()
const
248 g->closeToGrasp_ = closeToGrasp_;
249 g->setTrialOutcome(getTrialOutcome());
250 g->setQuality(getQuality());
251 return NUKLEI_UNIQUE_PTR<Descriptor>(NUKLEI_MOVE(g));
254 NUKLEI_UNIQUE_PTR<Descriptor> create()
const
259 coord_t getGap()
const {
return gap_; }
260 void setGap(
const coord_t gap) { gap_ = gap; }
262 bool getCloseToGrasp()
const {
return closeToGrasp_; }
263 void setCloseToGrasp(
const bool closeToGrasp) { closeToGrasp_ = closeToGrasp; }
266 Vector3 getCoViSEuler()
const {
return covisEuler_; }
267 void setCoViSEuler(
const Vector3& covisEuler) { covisEuler_ = covisEuler; }
274 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
275 template<
class Archive>
276 void serialize(Archive &ar,
const unsigned int version)
279 ar & NUKLEI_SERIALIZATION_MAKE_NVP
283 ar & NUKLEI_SERIALIZATION_MAKE_NVP
286 ar & NUKLEI_SERIALIZATION_NVP(gap_);
287 ar & NUKLEI_SERIALIZATION_NVP(closeToGrasp_);
288 ar & NUKLEI_SERIALIZATION_NVP(covisEuler_);
297 typedef NUKLEI_UNIQUE_PTR< GeometricDescriptor > ptr;
300 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
301 template<
class Archive>
302 void serialize(Archive &ar,
const unsigned int version)
310 typedef NUKLEI_UNIQUE_PTR< PlaneDescriptor > ptr;
314 virtual void assertConsistency()
const
316 NUKLEI_TRACE_BEGIN();
320 NUKLEI_UNIQUE_PTR<Descriptor> clone()
const
323 return NUKLEI_UNIQUE_PTR<Descriptor>(NUKLEI_MOVE(g));
326 NUKLEI_UNIQUE_PTR<Descriptor> create()
const
328 return NUKLEI_UNIQUE_PTR<Descriptor>(NUKLEI_MOVE(
new PlaneDescriptor));
331 friend class NUKLEI_SERIALIZATION_FRIEND_CLASSNAME;
332 template<
class Archive>
333 void serialize(Archive &ar,
const unsigned int version)
335 ar & NUKLEI_SERIALIZATION_MAKE_NVP
348 #if BOOST_VERSION < 104100
353 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::ColorDescriptor, "mdfh_Descriptor_Color")
354 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::GraspDescriptor, "mdfh_Descriptor_Grasp")
355 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::TwoFingerDescriptor, "mdfh_Descriptor_TwoFinger")
356 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::PlaneDescriptor, "mdfh_Descriptor_Plane")
357 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::RGBColor, "mdfh_Color_RGB")
358 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::HSVColor, "mdfh_Color_HSV")
359 NUKLEI_SERIALIZATION_DECLARE_TYPE_WITH_NAME(
nuklei::HSVConeColor, "mdfh_Color_HSVCone")
361 #endif // BOOST_VERSION