00001 /* 00002 * Copyright 2018 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/pose_graph.h" 00018 00019 #include "cartographer/mapping/internal/testing/test_helpers.h" 00020 #include "cartographer/mapping/trajectory_builder_interface.h" 00021 #include "cartographer/transform/transform.h" 00022 #include "google/protobuf/util/message_differencer.h" 00023 #include "gtest/gtest.h" 00024 00025 namespace cartographer { 00026 namespace mapping { 00027 namespace { 00028 00029 TEST(PoseGraph, SerializeConstraint) { 00030 proto::PoseGraph::Constraint expected_constraint = 00031 testing::CreateFakeConstraint(testing::CreateFakeNode(1, 2), 00032 testing::CreateFakeSubmap3D(2, 3)); 00033 ::google::protobuf::RepeatedPtrField<proto::PoseGraph::Constraint> 00034 constraint_protos; 00035 *constraint_protos.Add() = expected_constraint; 00036 PoseGraph::Constraint constraint = FromProto(constraint_protos).front(); 00037 EXPECT_TRUE(google::protobuf::util::MessageDifferencer::Equals( 00038 expected_constraint, ToProto(constraint))); 00039 } 00040 00041 } // namespace 00042 } // namespace mapping 00043 } // namespace cartographer