sophus_matchers.hpp
Go to the documentation of this file.
1 // Copyright 2023-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 #ifndef BELUGA_TESTING_SOPHUS_MATCHERS_HPP
16 #define BELUGA_TESTING_SOPHUS_MATCHERS_HPP
17 
26 #include <gmock/gmock.h>
27 
28 #include <sophus/se2.hpp>
29 #include <sophus/so2.hpp>
30 #include <sophus/types.hpp>
31 
32 namespace beluga::testing {
33 
34 using ::testing::AllOf;
35 using ::testing::DoubleNear;
36 using ::testing::Property;
37 
39 
44 template <class Scalar>
45 inline auto Vector2Near(const Sophus::Vector2<Scalar>& t, Scalar e) {
46  return AllOf(
47  Property("x", &Sophus::Vector2<Scalar>::x, DoubleNear(t.x(), e)),
48  Property("y", &Sophus::Vector2<Scalar>::y, DoubleNear(t.y(), e)));
49 }
50 
52 
57 template <class Scalar>
58 inline auto Vector3Near(const Sophus::Vector3<Scalar>& t, Scalar e) {
59  return AllOf(
60  Property("x", &Sophus::Vector3<Scalar>::x, DoubleNear(t.x(), e)),
61  Property("y", &Sophus::Vector3<Scalar>::y, DoubleNear(t.y(), e)),
62  Property("z", &Sophus::Vector3<Scalar>::z, DoubleNear(t.z(), e)));
63 }
64 
66 
71 template <class Scalar>
72 inline auto SO2Near(const Sophus::SO2<Scalar>& t, Scalar e) {
73  return Property("unit_complex", &Sophus::SO2<Scalar>::unit_complex, Vector2Near(t.unit_complex(), e));
74 }
75 
77 
82 template <class Scalar>
83 inline auto SE2Near(const Sophus::SE2<Scalar>& t, Scalar e) {
84  return AllOf(
85  Property("translation", &Sophus::SE2<Scalar>::translation, Vector2Near(t.translation(), e)),
86  Property("so2", &Sophus::SE2<Scalar>::so2, SO2Near(t.so2(), e)));
87 }
88 
90 template <class Scalar>
91 inline auto SE2Near(const Sophus::SO2<Scalar>& r, const Sophus::Vector2<Scalar>& t, Scalar e) {
92  return SE2Near<Scalar>(Sophus::SE2<Scalar>{r, t}, e);
93 }
94 
95 } // namespace beluga::testing
96 
97 #endif
Sophus::SO2
beluga::testing::SO2Near
auto SO2Near(const Sophus::SO2< Scalar > &t, Scalar e)
SO2 element matcher.
Definition: sophus_matchers.hpp:72
Sophus::Vector3
Vector< Scalar, 3, Options > Vector3
beluga::testing::SE2Near
auto SE2Near(const Sophus::SE2< Scalar > &t, Scalar e)
SE2 element matcher.
Definition: sophus_matchers.hpp:83
Sophus::Vector2
Vector< Scalar, 2, Options > Vector2
Sophus::SE2::so2
SOPHUS_FUNC SO2Member & so2()
beluga::testing::Vector3Near
auto Vector3Near(const Sophus::Vector3< Scalar > &t, Scalar e)
Vector3 element matcher.
Definition: sophus_matchers.hpp:58
se2.hpp
types.hpp
beluga::testing::Vector2Near
auto Vector2Near(const Sophus::Vector2< Scalar > &t, Scalar e)
Vector2 element matcher.
Definition: sophus_matchers.hpp:45
Sophus::SE2
so2.hpp
beluga::testing
Definition: sophus_matchers.hpp:32
Sophus::SE2::translation
SOPHUS_FUNC TranslationMember & translation()
Sophus::SO2::unit_complex
SOPHUS_FUNC ComplexMember const & unit_complex() const


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