Debian Codegraph @

unit_test/slam2d/mappings_se2.cpp

raw symbols SCIP
1 // g2o - General Graph Optimization
2 // Copyright (C) 2014 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 "g2o/types/slam2d/se2.h"
28 #include "gtest/gtest.h"
29
30 using namespace std;
31 using namespace g2o;
32
33 TEST(MappingsSlam2D, SE2) {
34 // constructor from 3 values
35 SE2 s1(cst(0.), cst(1.), cst(2.));
36 EXPECT_DOUBLE_EQ(0., s1[0]);
37 EXPECT_DOUBLE_EQ(1., s1[1]);
38 EXPECT_DOUBLE_EQ(2., s1[2]);
39
40 // constructor from vector
41 Vector3 vec2 = Vector3(cst(0.1), cst(0.2), cst(0.3));
42 SE2 s2(vec2);
43 EXPECT_DOUBLE_EQ(0.1, s2[0]);
44 EXPECT_DOUBLE_EQ(0.2, s2[1]);
45 EXPECT_DOUBLE_EQ(0.3, s2[2]);
46 EXPECT_DOUBLE_EQ(0., (vec2.head<2>() - s2.translation()).norm());
47
48 // constructor from Isometry
49 Rotation2D rot3 = Rotation2D(cst(1.));
50 SE2 s3 = SE2(Isometry2(rot3));
51 EXPECT_DOUBLE_EQ(0., s3.translation()(0));
52 EXPECT_DOUBLE_EQ(0., s3.translation()(1));
53 EXPECT_DOUBLE_EQ(1., s3.rotation().angle());
54 }