Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/mapping/trajectory_node.h"
00018
00019 #include <limits>
00020
00021 #include "Eigen/Core"
00022 #include "cartographer/common/time.h"
00023 #include "cartographer/mapping/proto/trajectory_node_data.pb.h"
00024 #include "cartographer/transform/rigid_transform_test_helpers.h"
00025 #include "gtest/gtest.h"
00026
00027 namespace cartographer {
00028 namespace mapping {
00029 namespace {
00030
00031 TEST(TrajectoryNodeTest, ToAndFromProto) {
00032 const TrajectoryNode::Data expected{
00033 common::FromUniversal(42),
00034 Eigen::Quaterniond(1., 2., -3., -4.),
00035 sensor::CompressedPointCloud(
00036 {{Eigen::Vector3f{1.f, 2.f, 0.f}}, {Eigen::Vector3f{0.f, 0.f, 1.f}}})
00037 .Decompress(),
00038 sensor::CompressedPointCloud({{Eigen::Vector3f{2.f, 3.f, 4.f}}})
00039 .Decompress(),
00040 sensor::CompressedPointCloud({{Eigen::Vector3f{-1.f, 2.f, 0.f}}})
00041 .Decompress(),
00042 Eigen::VectorXf::Unit(20, 4),
00043 transform::Rigid3d({1., 2., 3.},
00044 Eigen::Quaterniond(4., 5., -6., -7.).normalized())};
00045 const proto::TrajectoryNodeData proto = ToProto(expected);
00046 const TrajectoryNode::Data actual = FromProto(proto);
00047 EXPECT_EQ(expected.time, actual.time);
00048 EXPECT_TRUE(actual.gravity_alignment.isApprox(expected.gravity_alignment));
00049 EXPECT_EQ(expected.filtered_gravity_aligned_point_cloud,
00050 actual.filtered_gravity_aligned_point_cloud);
00051 EXPECT_EQ(expected.high_resolution_point_cloud,
00052 actual.high_resolution_point_cloud);
00053 EXPECT_EQ(expected.low_resolution_point_cloud,
00054 actual.low_resolution_point_cloud);
00055 EXPECT_EQ(expected.rotational_scan_matcher_histogram,
00056 actual.rotational_scan_matcher_histogram);
00057 EXPECT_THAT(actual.local_pose,
00058 transform::IsNearly(expected.local_pose, 1e-9));
00059 }
00060
00061 }
00062 }
00063 }