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/3d/submap_3d.h"
00018
00019 #include "cartographer/transform/transform.h"
00020 #include "gmock/gmock.h"
00021
00022 namespace cartographer {
00023 namespace mapping {
00024 namespace {
00025
00026 TEST(SubmapsTest, ToFromProto) {
00027 Eigen::VectorXf histogram(2);
00028 histogram << 1.0f, 2.0f;
00029 const Submap3D expected(
00030 0.05, 0.25,
00031 transform::Rigid3d(Eigen::Vector3d(1., 2., 0.),
00032 Eigen::Quaterniond(0., 0., 0., 1.)),
00033 histogram);
00034 const proto::Submap proto =
00035 expected.ToProto(true );
00036 EXPECT_FALSE(proto.has_submap_2d());
00037 EXPECT_TRUE(proto.has_submap_3d());
00038 const auto actual = Submap3D(proto.submap_3d());
00039 EXPECT_TRUE(expected.local_pose().translation().isApprox(
00040 actual.local_pose().translation(), 1e-6));
00041 EXPECT_TRUE(expected.local_pose().rotation().isApprox(
00042 actual.local_pose().rotation(), 1e-6));
00043 EXPECT_EQ(expected.num_range_data(), actual.num_range_data());
00044 EXPECT_EQ(expected.insertion_finished(), actual.insertion_finished());
00045 EXPECT_NEAR(expected.high_resolution_hybrid_grid().resolution(), 0.05, 1e-6);
00046 EXPECT_NEAR(expected.low_resolution_hybrid_grid().resolution(), 0.25, 1e-6);
00047 EXPECT_TRUE(expected.rotational_scan_matcher_histogram().isApprox(
00048 actual.rotational_scan_matcher_histogram(), 1e-6));
00049 }
00050
00051 }
00052 }
00053 }