00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _searchenergy_h_
00027 #define _searchenergy_h_
00028
00029 #include <ostream>
00030 #include <list>
00031 #include <QObject>
00032
00033 #include "search.h"
00034 #include "matvec3D.h"
00035
00036 class Hand;
00037 class Body;
00038 class QualityMeasure;
00039 class GraspPlanningState;
00040
00042
00053 class SearchEnergy : public QObject
00054 {
00055 Q_OBJECT
00056 protected:
00057 Hand *mHand; Body *mObject;
00058 QualityMeasure *mVolQual, *mEpsQual;
00059 SearchEnergyType mType;
00060 SearchContactType mContactType;
00063 bool mDisableRendering;
00064
00066 mutable std::ostream *mOut;
00067
00068 void createQualityMeasures();
00069 void setHandAndObject(Hand *h, Body *o);
00070 double contactEnergy() const;
00071 double potentialQualityEnergy(bool verbose = false) const;
00072 double guidedPotentialQualityEnergy() const;
00073 double autograspQualityEnergy() const;
00074 double approachAutograspQualityEnergy() const;
00075 double guidedAutograspEnergy() const;
00076 double strictAutograspEnergy() const;
00077
00079 double dynamicAutograspEnergy() const;
00081 bool contactSlip() const;
00083 bool dynamicAutograspComplete() const;
00085 double compliantEnergy() const;
00086
00087 double distanceFunction(double d) const;
00088 double potentialQualityScalingFunction(double dist, double cosTheta) const;
00089
00091 double energy() const;
00093 bool legal() const;
00094
00096 mutable bool mCompUnbalanced;
00097 mutable vec3 mMaxUnbalancedForce;
00099 mutable bool mDynamicsError;
00100 private slots:
00102 void autoGraspStep(int numCols, bool &stopRequest) const;
00104 void dynamicsError(const char*) const;
00105 public:
00106 SearchEnergy();
00107 ~SearchEnergy();
00108
00109 void setType(SearchEnergyType t){mType = t;}
00110 void setContactType(SearchContactType t){mContactType = t;}
00111 double getEpsQual();
00112 double getVolQual();
00113 SearchContactType getContactType() const {return mContactType;}
00114 void disableRendering(bool dr){mDisableRendering = dr;}
00115
00121 virtual void analyzeState(bool &isLegal, double &stateEnergy, const GraspPlanningState *state, bool noChange = true);
00123 virtual void analyzeCurrentPosture(Hand *h, Body *o, bool &isLegal, double &stateEnergy, bool noChange = true);
00124
00126 void setStatStream(std::ostream *out) const {mOut = out;}
00127 };
00128
00132 class ClosureSearchEnergy : public SearchEnergy
00133 {
00134 protected:
00135 const std::list<GraspPlanningState*> *mAvoidList;
00136 double mThreshold;
00137 public:
00138 ClosureSearchEnergy() : SearchEnergy(), mAvoidList(NULL), mThreshold(0.3) {}
00139
00140 void setThreshold(double t){mThreshold=t;}
00141 void setAvoidList(const std::list<GraspPlanningState*> *l){mAvoidList = l;}
00142 void analyzeState(bool &isLegal, double &stateEnergy, const GraspPlanningState *state, bool noChange = true);
00143 };
00144
00145 #endif