Debian Codegraph @

unit_test/sclam2d/odom_convert_sclam2d.cpp

raw symbols SCIP
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 "g2o/types/sclam2d/odometry_measurement.h"
28 #include "gtest/gtest.h"
29
30 using namespace std;
31 using namespace g2o;
32 using namespace Eigen;
33
34 TEST(Sclam2D, MotionMeasurementCtor) {
35 MotionMeasurement m1(0.1, 0.2, 0.3, 0.5);
36 ASSERT_DOUBLE_EQ(0.1, m1.x());
37 ASSERT_DOUBLE_EQ(0.2, m1.y());
38 ASSERT_DOUBLE_EQ(0.3, m1.theta());
39 ASSERT_DOUBLE_EQ(0.5, m1.dt());
40 MotionMeasurement m2(Eigen::Vector3d(0.1, 0.2, 0.3), 0.5);
41 ASSERT_DOUBLE_EQ(0.1, m2.x());
42 ASSERT_DOUBLE_EQ(0.2, m2.y());
43 ASSERT_DOUBLE_EQ(0.3, m2.theta());
44 ASSERT_DOUBLE_EQ(0.5, m2.dt());
45 }
46
47 TEST(Sclam2D, VelocityMeasurementCtor) {
48 VelocityMeasurement v1(0.1, 0.2, 0.7);
49 ASSERT_DOUBLE_EQ(0.1, v1.vl());
50 ASSERT_DOUBLE_EQ(0.2, v1.vr());
51 ASSERT_DOUBLE_EQ(0.7, v1.dt());
52 }
53
54 TEST(Sclam2D, OdomConvertStraightLine) {
55 MotionMeasurement m1(0.1, 0.0, 0.0, 0.5);
56 ASSERT_DOUBLE_EQ(0.1, m1.x());
57 ASSERT_DOUBLE_EQ(0.0, m1.y());
58 ASSERT_DOUBLE_EQ(0.0, m1.theta());
59 ASSERT_DOUBLE_EQ(0.5, m1.dt());
60 VelocityMeasurement v1 = OdomConvert::convertToVelocity(m1);
61 ASSERT_DOUBLE_EQ(m1.dt(), v1.dt());
62 MotionMeasurement m2 = OdomConvert::convertToMotion(v1);
63 ASSERT_DOUBLE_EQ(0.1, m2.x());
64 ASSERT_DOUBLE_EQ(0.0, m2.y());
65 ASSERT_DOUBLE_EQ(0.0, m2.theta());
66 ASSERT_DOUBLE_EQ(0.5, m2.dt());
67 }
68
69 TEST(Sclam2D, OdomConvert) {
70 VelocityMeasurement v1(0.1, 0.2, 0.7);
71 MotionMeasurement m1 = OdomConvert::convertToMotion(v1);
72 VelocityMeasurement v2 = OdomConvert::convertToVelocity(m1);
73 ASSERT_DOUBLE_EQ(0.1, v2.vl());
74 ASSERT_DOUBLE_EQ(0.2, v2.vr());
75 ASSERT_DOUBLE_EQ(0.7, v2.dt());
76 }