orientation_test.cpp
Go to the documentation of this file.
00001 #include "transform_graph/orientation.h"
00002 
00003 #include <gtest/gtest.h>
00004 
00005 namespace transform_graph {
00006 TEST(TestOrientation, Identity) {
00007   Orientation o;
00008   Eigen::Matrix3d expected;
00009   // clang-format off
00010   expected << 1, 0, 0,
00011               0, 1, 0,
00012               0, 0, 1;
00013   // clang-format on
00014   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00015 }
00016 
00017 TEST(TestOrientation, TestWxyz) {
00018   Orientation o(0.92387959, 0, 0, 0.38268353);
00019   Eigen::Matrix3d expected;
00020   // clang-format off
00021   expected << 0.707107, -0.707107, 0,
00022               0.707107,  0.707107, 0,
00023               0       ,  0       , 1;
00024   // clang-format on
00025   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00026 }
00027 
00028 TEST(TestOrientation, TestEigenMatrix) {
00029   Eigen::Matrix3d input;
00030   // clang-format off
00031   input << 0.707107, -0.707107, 0,
00032            0.707107,  0.707107, 0,
00033            0       ,  0       , 1;
00034   // clang-format on
00035 
00036   Orientation o(input);
00037   Eigen::Matrix3d expected;
00038   // clang-format off
00039   expected << 0.707107, -0.707107, 0,
00040               0.707107,  0.707107, 0,
00041               0       ,  0       , 1;
00042   // clang-format on
00043   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00044 }
00045 
00046 TEST(TestOrientation, TestEigenQuaternion) {
00047   Eigen::Quaterniond q(0.92387959, 0, 0, 0.38268353);
00048   Orientation o(q);
00049   Eigen::Matrix3d expected;
00050   // clang-format off
00051   expected << 0.707107, -0.707107, 0,
00052               0.707107,  0.707107, 0,
00053               0       ,  0       , 1;
00054   // clang-format on
00055   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00056 }
00057 
00058 TEST(TestOrientation, TestGeometryMsgsQuaternion) {
00059   geometry_msgs::Quaternion q;
00060   q.w = 0.92387959;
00061   q.x = 0;
00062   q.y = 0;
00063   q.z = 0.38268353;
00064   Orientation o(q);
00065   Eigen::Matrix3d expected;
00066   // clang-format off
00067   expected << 0.707107, -0.707107, 0,
00068               0.707107,  0.707107, 0,
00069               0       ,  0       , 1;
00070   // clang-format on
00071   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00072 }
00073 
00074 TEST(TestOrientation, TestTfQuaternion) {
00075   tf::Quaternion q(0, 0, 0.38268353, 0.92387959);
00076   Orientation o(q);
00077   Eigen::Matrix3d expected;
00078   // clang-format off
00079   expected << 0.707107, -0.707107, 0,
00080               0.707107,  0.707107, 0,
00081               0       ,  0       , 1;
00082   // clang-format on
00083   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.00001));
00084 }
00085 
00086 TEST(TestOrientation, TestTfMatrix) {
00087   // clang-format off
00088   tf::Matrix3x3 input(0.707107, -0.707107, 0,
00089                       0.707107,  0.707107, 0,
00090                       0       ,  0       , 1);
00091   // clang-format on
00092 
00093   Orientation o(input);
00094   Eigen::Matrix3d expected;
00095   // clang-format off
00096   expected << 0.707107, -0.707107, 0,
00097               0.707107,  0.707107, 0,
00098               0       ,  0       , 1;
00099   // clang-format on
00100   EXPECT_TRUE(expected.isApprox(o.matrix(), 0.000001));
00101 }
00102 }  // namespace transform_graph
00103 
00104 int main(int argc, char **argv) {
00105   testing::InitGoogleTest(&argc, argv);
00106   return RUN_ALL_TESTS();
00107 }


transform_graph
Author(s):
autogenerated on Sat Jun 8 2019 19:23:43