transform.cc
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 
18 
19 namespace cartographer {
20 namespace transform {
21 
23  return Rigid2d({pose.translation().x(), pose.translation().y()},
24  pose.rotation());
25 }
26 
27 Eigen::Vector2d ToEigen(const proto::Vector2d& vector) {
28  return Eigen::Vector2d(vector.x(), vector.y());
29 }
30 
31 Eigen::Vector3f ToEigen(const proto::Vector3f& vector) {
32  return Eigen::Vector3f(vector.x(), vector.y(), vector.z());
33 }
34 
35 Eigen::Vector3d ToEigen(const proto::Vector3d& vector) {
36  return Eigen::Vector3d(vector.x(), vector.y(), vector.z());
37 }
38 
39 Eigen::Quaterniond ToEigen(const proto::Quaterniond& quaternion) {
40  return Eigen::Quaterniond(quaternion.w(), quaternion.x(), quaternion.y(),
41  quaternion.z());
42 }
43 
45  proto::Rigid2d proto;
46  proto.mutable_translation()->set_x(transform.translation().x());
47  proto.mutable_translation()->set_y(transform.translation().y());
48  proto.set_rotation(transform.rotation().angle());
49  return proto;
50 }
51 
53  proto::Rigid2f proto;
54  proto.mutable_translation()->set_x(transform.translation().x());
55  proto.mutable_translation()->set_y(transform.translation().y());
56  proto.set_rotation(transform.rotation().angle());
57  return proto;
58 }
59 
61  proto::Rigid3d proto;
62  *proto.mutable_translation() = ToProto(rigid.translation());
63  *proto.mutable_rotation() = ToProto(rigid.rotation());
64  return proto;
65 }
66 
68  return transform::Rigid3d(ToEigen(rigid.translation()),
69  ToEigen(rigid.rotation()));
70 }
71 
73  proto::Rigid3f proto;
74  *proto.mutable_translation() = ToProto(rigid.translation());
75  *proto.mutable_rotation() = ToProto(rigid.rotation());
76  return proto;
77 }
78 
79 proto::Vector2d ToProto(const Eigen::Vector2d& vector) {
80  proto::Vector2d proto;
81  proto.set_x(vector.x());
82  proto.set_y(vector.y());
83  return proto;
84 }
85 
86 proto::Vector3f ToProto(const Eigen::Vector3f& vector) {
87  proto::Vector3f proto;
88  proto.set_x(vector.x());
89  proto.set_y(vector.y());
90  proto.set_z(vector.z());
91  return proto;
92 }
93 
94 proto::Vector3d ToProto(const Eigen::Vector3d& vector) {
95  proto::Vector3d proto;
96  proto.set_x(vector.x());
97  proto.set_y(vector.y());
98  proto.set_z(vector.z());
99  return proto;
100 }
101 
102 proto::Quaternionf ToProto(const Eigen::Quaternionf& quaternion) {
103  proto::Quaternionf proto;
104  proto.set_w(quaternion.w());
105  proto.set_x(quaternion.x());
106  proto.set_y(quaternion.y());
107  proto.set_z(quaternion.z());
108  return proto;
109 }
110 
111 proto::Quaterniond ToProto(const Eigen::Quaterniond& quaternion) {
112  proto::Quaterniond proto;
113  proto.set_w(quaternion.w());
114  proto.set_x(quaternion.x());
115  proto.set_y(quaternion.y());
116  proto.set_z(quaternion.z());
117  return proto;
118 }
119 
120 } // namespace transform
121 } // namespace cartographer
Rigid2d ToRigid2(const proto::Rigid2d &pose)
Definition: transform.cc:22
const Vector & translation() const
const Quaternion & rotation() const
Rigid3< double > Rigid3d
transform::Rigid3d ToRigid3(const proto::Rigid3d &rigid)
Definition: transform.cc:67
transform::Rigid3d pose
Rigid2< double > Rigid2d
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:44
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:59