trajectory_node_test.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2017 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <limits>
20 
21 #include "Eigen/Core"
23 #include "cartographer/mapping/proto/trajectory_node_data.pb.h"
25 #include "gtest/gtest.h"
26 
27 namespace cartographer {
28 namespace mapping {
29 namespace {
30 
31 TEST(TrajectoryNodeTest, ToAndFromProto) {
32  const TrajectoryNode::Data expected{
34  Eigen::Quaterniond(1., 2., -3., -4.),
35  sensor::CompressedPointCloud({{1.f, 2.f, 0.f}, {0.f, 0.f, 1.f}})
36  .Decompress(),
37  sensor::CompressedPointCloud({{2.f, 3.f, 4.f}}).Decompress(),
38  sensor::CompressedPointCloud({{-1.f, 2.f, 0.f}}).Decompress(),
39  Eigen::VectorXf::Unit(20, 4),
40  transform::Rigid3d({1., 2., 3.},
41  Eigen::Quaterniond(4., 5., -6., -7.).normalized())};
42  const proto::TrajectoryNodeData proto = ToProto(expected);
43  const TrajectoryNode::Data actual = FromProto(proto);
44  EXPECT_EQ(expected.time, actual.time);
45  EXPECT_TRUE(actual.gravity_alignment.isApprox(expected.gravity_alignment));
46  EXPECT_EQ(expected.filtered_gravity_aligned_point_cloud,
47  actual.filtered_gravity_aligned_point_cloud);
48  EXPECT_EQ(expected.high_resolution_point_cloud,
49  actual.high_resolution_point_cloud);
50  EXPECT_EQ(expected.low_resolution_point_cloud,
51  actual.low_resolution_point_cloud);
52  EXPECT_EQ(expected.rotational_scan_matcher_histogram,
53  actual.rotational_scan_matcher_histogram);
54  EXPECT_THAT(actual.local_pose,
55  transform::IsNearly(expected.local_pose, 1e-9));
56 }
57 
58 } // namespace
59 } // namespace mapping
60 } // namespace cartographer
PoseGraph::Constraint::Tag FromProto(const proto::PoseGraph::Constraint::Tag &proto)
Definition: pose_graph.cc:38
Rigid3< double > Rigid3d
Time FromUniversal(const int64 ticks)
Definition: time.cc:34
proto::MapLimits ToProto(const MapLimits &map_limits)
Definition: map_limits.h:92
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58