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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00044 #ifndef _TREEOPTIMIZER3_HH_
00045 #define _TREEOPTIMIZER3_HH_
00046
00047 #include "posegraph3.hh"
00048
00050 struct TreeOptimizer3: public TreePoseGraph3{
00051 typedef std::vector<Pose> PoseVector;
00052
00054 TreeOptimizer3();
00055
00057 virtual ~TreeOptimizer3();
00058
00060 void initializeTreeParameters();
00061
00063 void initializeOptimization(EdgeCompareMode mode=EVComparator<Edge*>::CompareLevel);
00064
00065 void initializeOnlineOptimization(EdgeCompareMode mode=EVComparator<Edge*>::CompareLevel);
00066
00067 void initializeOnlineIterations();
00068
00070 void iterate(TreePoseGraph3::EdgeSet* eset=0, bool noPreconditioner=false);
00071
00073 double error(double* mre=0, double* mte=0, double* are=0, double* ate=0, TreePoseGraph3::EdgeSet* eset=0) const;
00074
00076 double angularError() const;
00077
00079 double translationalError() const;
00080
00081 bool restartOnDivergence;
00082
00083 inline double getRotGain() const {return rotGain;}
00084
00086 int iteration;
00087
00088 void recomputeAllTransformations();
00089
00090 protected:
00091
00094 Transformation getPose(Vertex*v, Vertex* top);
00095
00098 Rotation getRotation(Vertex*v, Vertex* top);
00099
00100 void recomputeTransformations(Vertex*v, Vertex* top);
00101
00102 void recomputeParameters(Vertex*v, Vertex* top);
00103
00104 void computePreconditioner();
00105
00106 void propagateErrorsPreconditioner();
00107
00108 void propagateErrors();
00109
00111 double error(const Edge* e) const;
00112
00113
00115 double translationalError(const Edge* e) const;
00116
00118 double rotationalError(const Edge* e) const;
00119
00120 double traslationalError(const Edge* e) const;
00121
00122
00124 double gamma[2];
00125
00127 struct PM_t{
00128 double v [2];
00129 inline double& operator[](int i){return v[i];}
00130 };
00131 typedef std::vector< PM_t > PMVector;
00132 PMVector M;
00133
00134 int mpl;
00135 std::vector<double> maxRotationalErrors;
00136 std::vector<double> maxTranslationalErrors;
00137 double rotGain, trasGain;
00138
00139 virtual void onStepStart(Edge* e);
00140 virtual void onStepFinished(Edge* e);
00141 virtual void onIterationStart(int iteration);
00142 virtual void onIterationFinished(int iteration);
00143 virtual bool isDone();
00144
00145 };
00146
00147 #endif