test_tf2_sophus.cpp
Go to the documentation of this file.
1 // Copyright 2023 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 <gtest/gtest.h>
16 
17 #include <sophus/se2.hpp>
18 #include <sophus/se3.hpp>
19 
21 
22 namespace {
23 
24 using SophusTestCases = testing::Types<Sophus::SE2d, Sophus::SE2f, Sophus::SE3d, Sophus::SE3f>;
25 
26 template <typename T>
27 class TransformConvertTest : public testing::Test {
28  public:
29  using TypeParam = T;
30 };
31 
32 TYPED_TEST_SUITE(TransformConvertTest, SophusTestCases, );
33 
34 TYPED_TEST(TransformConvertTest, ThereAndBackAgain) {
35  auto message1 = beluga_ros::msg::Transform{};
36  auto message2 = beluga_ros::msg::Transform{};
37  message1.translation.x = 1;
38  message1.translation.y = 2;
39  message1.translation.z = 0;
40  message1.rotation.x = 0;
41  message1.rotation.y = 0;
42  message1.rotation.z = 0;
43  message1.rotation.w = 1;
44  auto instance = typename TestFixture::TypeParam{};
45  tf2::convert(message1, instance);
46  tf2::convert(instance, message2);
47  ASSERT_EQ(message1, message2);
48 }
49 
50 template <typename T>
51 class PoseConvertTest : public testing::Test {
52  public:
53  using TypeParam = T;
54 };
55 
56 TYPED_TEST_SUITE(PoseConvertTest, SophusTestCases, );
57 
58 TYPED_TEST(PoseConvertTest, ThereAndBackAgain) {
59  auto message1 = beluga_ros::msg::Pose{};
60  auto message2 = beluga_ros::msg::Pose{};
61  message1.position.x = 1;
62  message1.position.y = 2;
63  message1.position.z = 0;
64  message1.orientation.x = 0;
65  message1.orientation.y = 0;
66  message1.orientation.z = 0;
67  message1.orientation.w = 1;
68  auto instance = typename TestFixture::TypeParam{};
69  tf2::fromMsg(message1, instance);
70  tf2::toMsg(instance, message2);
71  ASSERT_EQ(message1, message2);
72 }
73 
74 } // namespace
tf2::convert
void convert(const A &a, B &b)
tf2::fromMsg
void fromMsg(const A &, B &b)
tf2_sophus.hpp
Message conversion API overloads for Sophus types.
TYPED_TEST_SUITE
TYPED_TEST_SUITE(BearingSensorModelTests, BearingSensorModelTestsTypes,)
se2.hpp
TYPED_TEST
TYPED_TEST(BearingSensorModelTests, BullsEyeDetection)
tf2::toMsg
B toMsg(const A &a)
se3.hpp


beluga_ros
Author(s):
autogenerated on Tue Jul 16 2024 03:00:02