trajectory_node.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 "Eigen/Core"
23 
24 namespace cartographer {
25 namespace mapping {
26 
27 proto::TrajectoryNodeData ToProto(const TrajectoryNode::Data& constant_data) {
28  proto::TrajectoryNodeData proto;
29  proto.set_timestamp(common::ToUniversal(constant_data.time));
30  *proto.mutable_gravity_alignment() =
32  *proto.mutable_filtered_gravity_aligned_point_cloud() =
35  .ToProto();
36  *proto.mutable_high_resolution_point_cloud() =
38  .ToProto();
39  *proto.mutable_low_resolution_point_cloud() =
41  .ToProto();
42  for (Eigen::VectorXf::Index i = 0;
43  i != constant_data.rotational_scan_matcher_histogram.size(); ++i) {
44  proto.add_rotational_scan_matcher_histogram(
45  constant_data.rotational_scan_matcher_histogram(i));
46  }
47  *proto.mutable_local_pose() = transform::ToProto(constant_data.local_pose);
48  return proto;
49 }
50 
51 TrajectoryNode::Data FromProto(const proto::TrajectoryNodeData& proto) {
52  Eigen::VectorXf rotational_scan_matcher_histogram(
53  proto.rotational_scan_matcher_histogram_size());
54  for (int i = 0; i != proto.rotational_scan_matcher_histogram_size(); ++i) {
55  rotational_scan_matcher_histogram(i) =
56  proto.rotational_scan_matcher_histogram(i);
57  }
58  return TrajectoryNode::Data{
59  common::FromUniversal(proto.timestamp()),
60  transform::ToEigen(proto.gravity_alignment()),
61  sensor::CompressedPointCloud(proto.filtered_gravity_aligned_point_cloud())
62  .Decompress(),
63  sensor::CompressedPointCloud(proto.high_resolution_point_cloud())
64  .Decompress(),
65  sensor::CompressedPointCloud(proto.low_resolution_point_cloud())
66  .Decompress(),
67  rotational_scan_matcher_histogram,
68  transform::ToRigid3(proto.local_pose())};
69 }
70 
71 } // namespace mapping
72 } // namespace cartographer
PoseGraph::Constraint::Tag FromProto(const proto::PoseGraph::Constraint::Tag &proto)
Definition: pose_graph.cc:38
proto::CompressedPointCloud ToProto() const
transform::Rigid3d ToRigid3(const proto::Rigid3d &rigid)
Definition: transform.cc:71
Time FromUniversal(const int64 ticks)
Definition: time.cc:34
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:48
int64 ToUniversal(const Time time)
Definition: time.cc:36
proto::MapLimits ToProto(const MapLimits &map_limits)
Definition: map_limits.h:92
Eigen::Transform< T, 2, Eigen::Affine > ToEigen(const Rigid2< T > &rigid2)


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