g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
types
slam2d
se2.h
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
#ifndef G2O_SE2_H_
28
#define G2O_SE2_H_
29
30
#include <Eigen/Core>
31
#include <Eigen/Geometry>
32
#include <cassert>
33
34
#include "
g2o/core/eigen_types.h
"
35
#include "
g2o/stuff/misc.h
"
36
#include "
g2o_types_slam2d_api.h
"
37
38
namespace
g2o
{
39
43
class
G2O_TYPES_SLAM2D_API
SE2
{
44
public
:
45
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
;
46
SE2
() :
_R
(0),
_t
(0, 0) {}
47
48
SE2
(
const
Isometry2
& iso) :
_R
(0),
_t
(iso.
translation
()) {
49
_R
.fromRotationMatrix(iso.linear());
50
}
51
52
SE2
(
const
Vector3
& v) :
_R
(v[2]),
_t
(v[0], v[1]) {}
53
54
SE2
(
double
x,
double
y,
double
theta) :
_R
(theta),
_t
(x, y) {}
55
57
inline
const
Vector2
&
translation
()
const
{
return
_t
; }
58
void
setTranslation
(
const
Vector2
& t_) {
_t
= t_; }
59
61
inline
const
Rotation2D
&
rotation
()
const
{
return
_R
; }
62
void
setRotation
(
const
Rotation2D
& R_) {
_R
= R_; }
63
65
inline
SE2
operator*
(
const
SE2
& tr2)
const
{
66
SE2
result(*
this
);
67
result *= tr2;
68
return
result;
69
}
70
72
inline
SE2
&
operator*=
(
const
SE2
& tr2) {
73
_t
+=
_R
* tr2.
_t
;
74
_R
.angle() += tr2.
_R
.angle();
75
_R
.angle() =
normalize_theta
(
_R
.angle());
76
return
*
this
;
77
}
78
80
inline
Vector2
operator*
(
const
Vector2
& v)
const
{
return
_t
+
_R
* v; }
81
83
inline
SE2
inverse
()
const
{
84
SE2
ret;
85
ret.
_R
=
_R
.inverse();
86
ret.
_R
.angle() =
normalize_theta
(ret.
_R
.angle());
87
#ifdef _MSC_VER
88
ret.
_t
= ret.
_R
* (
Vector2
(
_t
* -1.));
89
#else
90
ret.
_t
= ret.
_R
* (
_t
* -1.);
91
#endif
92
return
ret;
93
}
94
95
inline
double
operator[]
(
int
i)
const
{
96
assert(i >= 0 && i < 3);
97
if
(i < 2)
return
_t
(i);
98
return
_R
.angle();
99
}
100
102
inline
void
fromVector
(
const
Vector3
& v) { *
this
=
SE2
(v[0], v[1], v[2]); }
103
105
inline
Vector3
toVector
()
const
{
106
return
Vector3
(
_t
.x(),
_t
.y(),
_R
.angle());
107
}
108
109
inline
Isometry2
toIsometry
()
const
{
110
Isometry2
iso = Isometry2::Identity();
111
iso.linear() =
_R
.toRotationMatrix();
112
iso.translation() =
_t
;
113
return
iso;
114
}
115
116
protected
:
117
Rotation2D
_R
;
118
Vector2
_t
;
119
};
120
121
}
// namespace g2o
122
123
#endif
g2o::SE2::translation
const Vector2 & translation() const
translational component
Definition
se2.h:57
g2o::SE2::_R
Rotation2D _R
Definition
se2.h:117
g2o::SE2::operator*
Vector2 operator*(const Vector2 &v) const
project a 2D vector
Definition
se2.h:80
g2o::SE2::SE2
SE2(const Vector3 &v)
Definition
se2.h:52
g2o::SE2::toVector
Vector3 toVector() const
convert to a 3D vector (x, y, theta)
Definition
se2.h:105
g2o::SE2::operator*
SE2 operator*(const SE2 &tr2) const
concatenate two SE2 elements (motion composition)
Definition
se2.h:65
g2o::SE2::setRotation
void setRotation(const Rotation2D &R_)
Definition
se2.h:62
g2o::SE2::inverse
SE2 inverse() const
invert :-)
Definition
se2.h:83
g2o::SE2::operator*=
SE2 & operator*=(const SE2 &tr2)
motion composition operator
Definition
se2.h:72
g2o::SE2::fromVector
void fromVector(const Vector3 &v)
assign from a 3D vector (x, y, theta)
Definition
se2.h:102
g2o::SE2::SE2
SE2(const Isometry2 &iso)
Definition
se2.h:48
g2o::SE2::setTranslation
void setTranslation(const Vector2 &t_)
Definition
se2.h:58
g2o::SE2::EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Definition
se2.h:45
g2o::SE2::_t
Vector2 _t
Definition
se2.h:118
g2o::SE2::SE2
SE2(double x, double y, double theta)
Definition
se2.h:54
g2o::SE2::SE2
SE2()
Definition
se2.h:46
g2o::SE2::operator[]
double operator[](int i) const
Definition
se2.h:95
g2o::SE2::rotation
const Rotation2D & rotation() const
rotational component
Definition
se2.h:61
g2o::SE2::toIsometry
Isometry2 toIsometry() const
Definition
se2.h:109
eigen_types.h
g2o_types_slam2d_api.h
G2O_TYPES_SLAM2D_API
#define G2O_TYPES_SLAM2D_API
Definition
g2o_types_slam2d_api.h:55
misc.h
some general case utility functions
g2o
Definition
dl_wrapper.cpp:55
g2o::Vector3
VectorN< 3 > Vector3
Definition
eigen_types.h:51
g2o::Isometry2
Eigen::Transform< double, 2, Eigen::Isometry, Eigen::ColMajor > Isometry2
Definition
eigen_types.h:76
g2o::normalize_theta
double normalize_theta(double theta)
Definition
misc.h:103
g2o::Vector2
VectorN< 2 > Vector2
Definition
eigen_types.h:50
g2o::Rotation2D
Eigen::Rotation2D< double > Rotation2D
Definition
eigen_types.h:80
Generated on
for g2o by
1.17.0