timed_point_cloud_data.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 "cartographer/transform/proto/transform.pb.h"
21 
22 namespace cartographer {
23 namespace sensor {
24 
25 proto::TimedPointCloudData ToProto(
26  const TimedPointCloudData& timed_point_cloud_data) {
27  proto::TimedPointCloudData proto;
28  proto.set_timestamp(common::ToUniversal(timed_point_cloud_data.time));
29  *proto.mutable_origin() = transform::ToProto(timed_point_cloud_data.origin);
30  proto.mutable_point_data()->Reserve(timed_point_cloud_data.ranges.size());
31  for (const Eigen::Vector4f& range : timed_point_cloud_data.ranges) {
32  *proto.add_point_data() = transform::ToProto(range);
33  }
34  return proto;
35 }
36 
37 TimedPointCloudData FromProto(const proto::TimedPointCloudData& proto) {
38  TimedPointCloud timed_point_cloud;
39  timed_point_cloud.reserve(proto.point_data().size());
40  std::transform(
41  proto.point_data().begin(), proto.point_data().end(),
42  std::back_inserter(timed_point_cloud),
43  static_cast<Eigen::Vector4f (*)(const transform::proto::Vector4f&)>(
45  return TimedPointCloudData{common::FromUniversal(proto.timestamp()),
46  transform::ToEigen(proto.origin()),
47  timed_point_cloud};
48 }
49 
50 } // namespace sensor
51 } // namespace cartographer
proto::FixedFramePoseData ToProto(const FixedFramePoseData &pose_data)
FixedFramePoseData FromProto(const proto::FixedFramePoseData &proto)
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
std::vector< Eigen::Vector4f > TimedPointCloud
Definition: point_cloud.h:39
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