point_cloud.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 #include "cartographer/sensor/proto/sensor.pb.h"
21 
22 namespace cartographer {
23 namespace sensor {
24 
26  const transform::Rigid3f& transform) {
27  PointCloud result;
28  result.reserve(point_cloud.size());
29  for (const Eigen::Vector3f& point : point_cloud) {
30  result.emplace_back(transform * point);
31  }
32  return result;
33 }
34 
35 PointCloud Crop(const PointCloud& point_cloud, const float min_z,
36  const float max_z) {
37  PointCloud cropped_point_cloud;
38  for (const auto& point : point_cloud) {
39  if (min_z <= point.z() && point.z() <= max_z) {
40  cropped_point_cloud.push_back(point);
41  }
42  }
43  return cropped_point_cloud;
44 }
45 
46 proto::PointCloud ToProto(const PointCloud& point_cloud) {
47  proto::PointCloud proto;
48  for (const auto& point : point_cloud) {
49  proto.add_x(point.x());
50  proto.add_y(point.y());
51  proto.add_z(point.z());
52  }
53  return proto;
54 }
55 
57  PointCloud point_cloud;
58  const int size = std::min({proto.x_size(), proto.y_size(), proto.z_size()});
59  point_cloud.reserve(size);
60  for (int i = 0; i != size; ++i) {
61  point_cloud.emplace_back(proto.x(i), proto.y(i), proto.z(i));
62  }
63  return point_cloud;
64 }
65 
66 } // namespace sensor
67 } // namespace cartographer
PointCloud TransformPointCloud(const PointCloud &point_cloud, const transform::Rigid3f &transform)
Definition: point_cloud.cc:25
PointCloud Crop(const PointCloud &point_cloud, const float min_z, const float max_z)
Definition: point_cloud.cc:35
int max_z
Definition: 3d/submaps.cc:41
int min_z
Definition: 3d/submaps.cc:40
proto::PointCloud ToProto(const PointCloud &point_cloud)
Definition: point_cloud.cc:46
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:30
PointCloud ToPointCloud(const proto::PointCloud &proto)
Definition: point_cloud.cc:56


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:39