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 
36  const transform::Rigid3f& transform) {
37  TimedPointCloud result;
38  result.reserve(point_cloud.size());
39  for (const Eigen::Vector4f& point : point_cloud) {
40  Eigen::Vector4f result_point;
41  result_point.head<3>() = transform * point.head<3>();
42  result_point[3] = point[3];
43  result.emplace_back(result_point);
44  }
45  return result;
46 }
47 
48 PointCloud CropPointCloud(const PointCloud& point_cloud, const float min_z,
49  const float max_z) {
50  PointCloud cropped_point_cloud;
51  for (const Eigen::Vector3f& point : point_cloud) {
52  if (min_z <= point.z() && point.z() <= max_z) {
53  cropped_point_cloud.push_back(point);
54  }
55  }
56  return cropped_point_cloud;
57 }
58 
60  const float min_z, const float max_z) {
61  TimedPointCloud cropped_point_cloud;
62  for (const Eigen::Vector4f& point : point_cloud) {
63  if (min_z <= point.z() && point.z() <= max_z) {
64  cropped_point_cloud.push_back(point);
65  }
66  }
67  return cropped_point_cloud;
68 }
69 
70 } // namespace sensor
71 } // namespace cartographer
PointCloud TransformPointCloud(const PointCloud &point_cloud, const transform::Rigid3f &transform)
Definition: point_cloud.cc:25
TimedPointCloud TransformTimedPointCloud(const TimedPointCloud &point_cloud, const transform::Rigid3f &transform)
Definition: point_cloud.cc:35
PointCloud CropPointCloud(const PointCloud &point_cloud, const float min_z, const float max_z)
Definition: point_cloud.cc:48
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:32
std::vector< Eigen::Vector4f > TimedPointCloud
Definition: point_cloud.h:39
int min_z
Definition: submap_3d.cc:31
int max_z
Definition: submap_3d.cc:32
TimedPointCloud CropTimedPointCloud(const TimedPointCloud &point_cloud, const float min_z, const float max_z)
Definition: point_cloud.cc:59


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