g2o
Loading...
Searching...
No Matches
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
33using namespace Eigen;
34
35namespace g2o {
36
38static void jac_quat3_euler3(Eigen::Matrix<double, 6, 6, Eigen::ColMajor>& J,
39 const Isometry3& 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;
53 J.col(i) = (eb - ea) * idelta;
54 }
55}
56
57bool EdgeSE3Euler::read(std::istream& is) {
58 Vector6 meas;
59 for (int i = 0; i < 6; i++) is >> meas[i];
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
76bool EdgeSE3Euler::write(std::ostream& os) const {
78 for (int i = 0; i < 6; i++) os << meas[i] << " ";
79
80 Matrix<double, 6, 6, Eigen::ColMajor> J;
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
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition base_edge.h:119
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition base_edge.h:107
void setInformation(const InformationType &information)
Definition base_edge.h:111
Measurement _measurement
the measurement of the edge
Definition base_edge.h:146
virtual bool write(std::ostream &os) const
write the vertex to a stream
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
virtual void setMeasurement(const Isometry3 &m)
Definition edge_se3.h:53
Definition jet.h:938
Isometry3 fromVectorQT(const Vector7 &v)
Vector6 toVectorET(const Isometry3 &t)
Vector7 toVectorQT(const Isometry3 &t)
Isometry3 fromVectorET(const Vector6 &v)
VectorN< 7 > Vector7
Definition eigen_types.h:54
constexpr double cst(long double v)
Definition misc.h:60
Eigen::Transform< double, 3, Eigen::Isometry, Eigen::ColMajor > Isometry3
Definition eigen_types.h:77
VectorN< 6 > Vector6
Definition eigen_types.h:53
static void jac_quat3_euler3(Eigen::Matrix< double, 6, 6, Eigen::ColMajor > &J, const Isometry3 &t)