rigid_transform_test_helpers.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 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 #ifndef CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_
00018 #define CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_
00019 
00020 #include <string>
00021 
00022 #include "Eigen/Core"
00023 #include "Eigen/Geometry"
00024 #include "cartographer/common/port.h"
00025 #include "cartographer/transform/rigid_transform.h"
00026 #include "gmock/gmock.h"
00027 #include "gtest/gtest.h"
00028 
00029 namespace cartographer {
00030 namespace transform {
00031 
00032 template <typename T>
00033 Eigen::Transform<T, 2, Eigen::Affine> ToEigen(const Rigid2<T>& rigid2) {
00034   return Eigen::Translation<T, 2>(rigid2.translation()) * rigid2.rotation();
00035 }
00036 
00037 template <typename T>
00038 Eigen::Transform<T, 3, Eigen::Affine> ToEigen(const Rigid3<T>& rigid3) {
00039   return Eigen::Translation<T, 3>(rigid3.translation()) * rigid3.rotation();
00040 }
00041 
00042 MATCHER_P2(IsNearly, rigid, epsilon,
00043            std::string(std::string(negation ? "isn't nearly " : "is nearly ") +
00044                        rigid.DebugString())) {
00045   return ToEigen(arg).isApprox(ToEigen(rigid), epsilon);
00046 }
00047 
00048 }  // namespace transform
00049 }  // namespace cartographer
00050 
00051 #endif  // CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_


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