44 {
45 double euc_noise = 0.01;
46
47
50
51
54 std::make_unique<
56
58
59 vector<Vector3d> true_points;
60 for (size_t i = 0; i < 1000; ++i) {
61 true_points.push_back(
65 }
66
67
68 int vertex_id = 0;
69 for (size_t i = 0; i < 2; ++i) {
70
71 Vector3d t(0, 0, i);
72 Quaterniond q;
73 q.setIdentity();
74
75 Eigen::Isometry3d cam;
76 cam = q;
77 cam.translation() = t;
78
79
82
84
85 cerr << t.transpose() << " | " << q.coeffs().transpose() << endl;
86
87
89
90
92
93 vertex_id++;
94 }
95
96
97 for (size_t i = 0; i < true_points.size(); ++i) {
98
103
104
105 Vector3d pt0, pt1;
106 pt0 = vp0->
estimate().inverse() * true_points[i];
107 pt1 = vp1->
estimate().inverse() * true_points[i];
108
109
113
117
118
119 Vector3d nm0, nm1;
120 nm0 << 0, i, 1;
121 nm1 << 0, i, 1;
122 nm0.normalize();
123 nm1.normalize();
124
127
130
136
138
139
141
143
144
145
146
147
148
149
151 }
152
153
156 Eigen::Isometry3d cam = vc->
estimate();
157 cam.translation() = Vector3d(0, 0, 0.2);
159
162 cout <<
"Initial chi2 = " << FIXED(optimizer.
chi2()) << endl;
163
165
167
168 cout << endl << "Second vertex should be near 0,0,1" << endl;
169 cout << dynamic_cast<VertexSE3*>(optimizer.
vertices().find(0)->second)
170 ->estimate()
171 .translation()
172 .transpose()
173 << endl;
174 cout << dynamic_cast<VertexSE3*>(optimizer.
vertices().find(1)->second)
175 ->estimate()
176 .translation()
177 .transpose()
178 << endl;
179}
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
virtual void setMeasurement(const Measurement &m)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
const EstimateType & estimate() const
return the current estimate of the vertex
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
void setVertex(size_t i, Vertex *v)
const VertexIDMap & vertices() const
linear solver using dense cholesky decomposition
virtual void setId(int id)
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
Implementation of the Levenberg Algorithm.
static double gaussRand(double mean, double sigma)
static double uniformRand(double lowerBndr, double upperBndr)
void computeActiveErrors()
int optimize(int iterations, bool online=false)
void setVerbose(bool verbose)
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
void setAlgorithm(OptimizationAlgorithm *algorithm)
3D pose Vertex, represented as an Isometry3
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
double chi2() const
returns the chi2 of the current configuration