g2o
Loading...
Searching...
No Matches
sba_utils.h
Go to the documentation of this file.
1// g2o - General Graph Optimization
2// Copyright (C) 2011 H. Strasdat
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#ifndef G2O_SBA_UTILS_H
28#define G2O_SBA_UTILS_H
29
31#include "g2o_types_sba_api.h"
32
33namespace g2o {
34
35namespace internal {
36
37inline Vector3 invert_depth(const Vector3& x) {
38 Vector2 aux = x.head<2>();
39 return unproject(aux) / x[2];
40}
41
42inline Eigen::Matrix<double, 2, 3, Eigen::ColMajor> d_proj_d_y(
43 const double& f, const Vector3& xyz) {
44 double z_sq = xyz[2] * xyz[2];
45 Eigen::Matrix<double, 2, 3, Eigen::ColMajor> J;
46 J << f / xyz[2], 0, -(f * xyz[0]) / z_sq, 0, f / xyz[2], -(f * xyz[1]) / z_sq;
47 return J;
48}
49
50inline Eigen::Matrix<double, 3, 6, Eigen::ColMajor> d_expy_d_y(
51 const Vector3& y) {
52 Eigen::Matrix<double, 3, 6, Eigen::ColMajor> J;
53 J.topLeftCorner<3, 3>() = -skew(y);
54 J.bottomRightCorner<3, 3>().setIdentity();
55
56 return J;
57}
58
59inline Matrix3 d_Tinvpsi_d_psi(const SE3Quat& T, const Vector3& psi) {
60 Matrix3 R = T.rotation().toRotationMatrix();
61 Vector3 x = invert_depth(psi);
62 Vector3 r1 = R.col(0);
63 Vector3 r2 = R.col(1);
64 Matrix3 J;
65 J.col(0) = r1;
66 J.col(1) = r2;
67 J.col(2) = -R * x;
68 J *= 1. / psi.z();
69 return J;
70}
71
72} // namespace internal
73} // namespace g2o
74
75#endif
const Quaternion & rotation() const
Definition se3quat.h:93
Eigen::Matrix< double, 2, 3, Eigen::ColMajor > d_proj_d_y(const double &f, const Vector3 &xyz)
Definition sba_utils.h:42
Vector3 invert_depth(const Vector3 &x)
Definition sba_utils.h:37
Matrix3 d_Tinvpsi_d_psi(const SE3Quat &T, const Vector3 &psi)
Definition sba_utils.h:59
Eigen::Matrix< double, 3, 6, Eigen::ColMajor > d_expy_d_y(const Vector3 &y)
Definition sba_utils.h:50
void skew(Eigen::MatrixBase< Derived > &s, const Eigen::MatrixBase< DerivedOther > &v)
VectorN< 3 > Vector3
Definition eigen_types.h:51
MatrixN< 3 > Matrix3
Definition eigen_types.h:72
VectorN< 2 > Vector2
Definition eigen_types.h:50
G2O_TYPES_SLAM3D_API Vector3 unproject(const Vector2 &)