trajectory_node_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace
00062 }  // namespace mapping
00063 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:36