g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam3d_addons
edge_se3_euler.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#include "
edge_se3_euler.h
"
28
29
#include <iostream>
30
31
#include "
g2o/core/factory.h
"
32
33
using namespace
Eigen
;
34
35
namespace
g2o
{
36
38
static
void
jac_quat3_euler3
(Eigen::Matrix<double, 6, 6, Eigen::ColMajor>& J,
39
const
Isometry3
& t) {
40
Vector7
t0 =
g2o::internal::toVectorQT
(t);
41
42
double
delta =
cst
(1e-6);
43
double
idelta = 1 / (2 * delta);
44
45
Vector7
ta;
46
Vector7
tb;
47
for
(
int
i = 0; i < 6; i++) {
48
ta = tb = t0;
49
ta[i] -= delta;
50
tb[i] += delta;
51
Vector6
ea =
g2o::internal::toVectorET
(
g2o::internal::fromVectorQT
(ta));
52
Vector6
eb =
g2o::internal::toVectorET
(
g2o::internal::fromVectorQT
(tb));
53
J.col(i) = (eb - ea) * idelta;
54
}
55
}
56
57
bool
EdgeSE3Euler::read
(std::istream& is) {
58
Vector6
meas;
59
for
(
int
i = 0; i < 6; i++) is >> meas[i];
60
Isometry3
transf =
g2o::internal::fromVectorET
(meas);
61
Matrix<double, 6, 6, Eigen::ColMajor> infMatEuler;
62
for
(
int
i = 0; i < 6; i++)
63
for
(
int
j = i; j < 6; j++) {
64
is >> infMatEuler(i, j);
65
if
(i != j) infMatEuler(j, i) = infMatEuler(i, j);
66
}
67
Matrix<double, 6, 6, Eigen::ColMajor> J;
68
jac_quat3_euler3
(J, transf);
69
Matrix<double, 6, 6, Eigen::ColMajor> infMat =
70
J.transpose() * infMatEuler * J;
71
setMeasurement
(transf);
72
setInformation
(infMat);
73
return
true
;
74
}
75
76
bool
EdgeSE3Euler::write
(std::ostream& os)
const
{
77
Vector6
meas =
g2o::internal::toVectorET
(
_measurement
);
78
for
(
int
i = 0; i < 6; i++) os << meas[i] <<
" "
;
79
80
Matrix<double, 6, 6, Eigen::ColMajor> J;
81
jac_quat3_euler3
(J,
measurement
());
82
// HACK: invert the jacobian to simulate the inverse derivative
83
J = J.inverse();
84
Matrix<double, 6, 6, Eigen::ColMajor> infMatEuler =
85
J.transpose() *
information
() * J;
86
for
(
int
i = 0; i < 6; i++)
87
for
(
int
j = i; j < 6; j++) {
88
os <<
" "
<< infMatEuler(i, j);
89
}
90
return
os.good();
91
}
92
93
}
// namespace g2o
g2o::BaseEdge< D, Isometry3 >::measurement
EIGEN_STRONG_INLINE const Measurement & measurement() const
Definition
base_edge.h:119
g2o::BaseEdge< D, Isometry3 >::information
EIGEN_STRONG_INLINE const InformationType & information() const
Definition
base_edge.h:107
g2o::BaseEdge< D, Isometry3 >::setInformation
void setInformation(const InformationType &information)
Definition
base_edge.h:111
g2o::BaseEdge< D, Isometry3 >::_measurement
Measurement _measurement
Definition
base_edge.h:146
g2o::EdgeSE3Euler::write
virtual bool write(std::ostream &os) const
write the vertex to a stream
Definition
edge_se3_euler.cpp:76
g2o::EdgeSE3Euler::read
virtual EIGEN_MAKE_ALIGNED_OPERATOR_NEW bool read(std::istream &is)
read the vertex from a stream, i.e., the internal state of the vertex
Definition
edge_se3_euler.cpp:57
g2o::EdgeSE3::setMeasurement
virtual void setMeasurement(const Isometry3 &m)
Definition
edge_se3.h:53
edge_se3_euler.h
factory.h
Eigen
Definition
jet.h:938
g2o::internal::toVectorQT
Vector7 toVectorQT(const Isometry3 &t)
Definition
isometry3d_mappings.cpp:111
g2o::internal::fromVectorQT
Isometry3 fromVectorQT(const Vector7 &v)
Definition
isometry3d_mappings.cpp:137
g2o::internal::fromVectorET
Isometry3 fromVectorET(const Vector6 &v)
Definition
isometry3d_mappings.cpp:130
g2o::internal::toVectorET
Vector6 toVectorET(const Isometry3 &t)
Definition
isometry3d_mappings.cpp:104
g2o
Definition
dl_wrapper.cpp:55
g2o::cst
constexpr double cst(long double v)
Definition
misc.h:60
g2o::jac_quat3_euler3
static void jac_quat3_euler3(Eigen::Matrix< double, 6, 6, Eigen::ColMajor > &J, const Isometry3 &t)
Definition
edge_se3_euler.cpp:38
g2o::Vector6
VectorN< 6 > Vector6
Definition
eigen_types.h:53
g2o::Vector7
VectorN< 7 > Vector7
Definition
eigen_types.h:54
g2o::Isometry3
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3
Definition
eigen_types.h:77
Generated on
for g2o by
1.17.0