test_sophus_matchers.cpp
Go to the documentation of this file.
1 // Copyright 2024 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <gmock/gmock.h>
16 #include <gtest/gtest.h>
17 
18 #include <Eigen/Core>
19 #include <sophus/se2.hpp>
20 #include <sophus/so2.hpp>
21 
23 
24 namespace {
25 
26 using Eigen::Vector2d;
27 using Eigen::Vector3d;
28 using Sophus::SE2d;
29 using Sophus::SO2d;
30 
35 
36 using testing::Not;
37 
38 TEST(SophusMatchers, Vector2Near) {
39  constexpr double kHighTolerance = 0.6;
40  constexpr double kLowTolerance = 0.4;
41  ASSERT_THAT(Vector2d(1.0, 2.0), Vector2Near({1.5, 1.5}, kHighTolerance));
42  ASSERT_THAT(Vector2d(1.0, 2.0), Not(Vector2Near({1.5, 1.5}, kLowTolerance)));
43 }
44 
45 TEST(SophusMatchers, Vector3Near) {
46  constexpr double kHighTolerance = 0.6;
47  constexpr double kLowTolerance = 0.4;
48  ASSERT_THAT(Vector3d(1.0, 2.0, 3.0), Vector3Near({1.0, 2.5, 3.0}, kHighTolerance));
49  ASSERT_THAT(Vector3d(1.0, 2.0, 3.0), Not(Vector3Near({1.0, 2.5, 3.0}, kLowTolerance)));
50 }
51 
52 TEST(SophusMatchers, SO2Near) {
53  constexpr double kTolerance = 0.1;
54  ASSERT_THAT(SO2d(1.0, 0.0), SO2Near({1.0, 0.0}, kTolerance));
55  ASSERT_THAT(SO2d(1.0, 0.0), Not(SO2Near({0.0, 1.0}, kTolerance)));
56 }
57 
58 TEST(SophusMatchers, SE2Near) {
59  constexpr double kHighTolerance = 0.6;
60  constexpr double kLowTolerance = 0.4;
61  ASSERT_THAT(SE2d(SO2d(1.0, 0.0), Vector2d(1.0, 2.0)), SE2Near({1.0, 0.0}, {1.5, 2.5}, kHighTolerance));
62  ASSERT_THAT(SE2d(SO2d(1.0, 0.0), Vector2d(1.0, 2.0)), Not(SE2Near({1.0, 0.0}, {1.5, 2.5}, kLowTolerance)));
63  ASSERT_THAT(SE2d(SO2d(1.0, 0.0), Vector2d(1.0, 2.0)), Not(SE2Near({0.0, 1.0}, {1.5, 2.5}, kHighTolerance)));
64 }
65 
66 } // namespace
kTolerance
double kTolerance
Definition: test_cluster_based_estimation.cpp:47
beluga::testing::SO2Near
auto SO2Near(const Sophus::SO2< Scalar > &t, Scalar e)
SO2 element matcher.
Definition: sophus_matchers.hpp:72
beluga::testing::SE2Near
auto SE2Near(const Sophus::SE2< Scalar > &t, Scalar e)
SE2 element matcher.
Definition: sophus_matchers.hpp:83
Vector3d
Vector3< double > Vector3d
beluga::testing::Vector3Near
auto Vector3Near(const Sophus::Vector3< Scalar > &t, Scalar e)
Vector3 element matcher.
Definition: sophus_matchers.hpp:58
se2.hpp
beluga::testing::Vector2Near
auto Vector2Near(const Sophus::Vector2< Scalar > &t, Scalar e)
Vector2 element matcher.
Definition: sophus_matchers.hpp:45
Sophus::SE2
Vector2d
Vector2< double > Vector2d
so2.hpp
sophus_matchers.hpp
Implements GTest matchers for Sophus/Eigen types.
Sophus::SE2d
SE2< double > SE2d
Sophus::SO2d
SO2< double > SO2d
beluga::TEST
TEST(Bresenham, MultiPassGuarantee)
Definition: test_bresenham.cpp:27


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53