rigid_transform_test_helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 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 
17 #ifndef CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_
18 #define CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_
19 
20 #include <string>
21 
22 #include "Eigen/Core"
23 #include "Eigen/Geometry"
26 #include "gmock/gmock.h"
27 #include "gtest/gtest.h"
28 
29 namespace cartographer {
30 namespace transform {
31 
32 template <typename T>
33 Eigen::Transform<T, 2, Eigen::Affine> ToEigen(const Rigid2<T>& rigid2) {
34  return Eigen::Translation<T, 2>(rigid2.translation()) * rigid2.rotation();
35 }
36 
37 template <typename T>
38 Eigen::Transform<T, 3, Eigen::Affine> ToEigen(const Rigid3<T>& rigid3) {
39  return Eigen::Translation<T, 3>(rigid3.translation()) * rigid3.rotation();
40 }
41 
42 MATCHER_P2(IsNearly, rigid, epsilon,
43  string(string(negation ? "isn't" : "is", " nearly ") +
44  rigid.DebugString())) {
45  return ToEigen(arg).isApprox(ToEigen(rigid), epsilon);
46 }
47 
48 } // namespace transform
49 } // namespace cartographer
50 
51 #endif // CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_TEST_HELPERS_H_
const Vector & translation() const
const Quaternion & rotation() const
MATCHER_P2(IsNearly, rigid, epsilon, string(string(negation?"isn't":"is"," nearly ")+rigid.DebugString()))
const Vector & translation() const
Eigen::Transform< T, 2, Eigen::Affine > ToEigen(const Rigid2< T > &rigid2)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58