point_cloud.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "cartographer/sensor/point_cloud.h"
00018 
00019 #include "cartographer/sensor/proto/sensor.pb.h"
00020 #include "cartographer/transform/transform.h"
00021 
00022 namespace cartographer {
00023 namespace sensor {
00024 
00025 PointCloud TransformPointCloud(const PointCloud& point_cloud,
00026                                const transform::Rigid3f& transform) {
00027   PointCloud result;
00028   result.reserve(point_cloud.size());
00029   for (const RangefinderPoint& point : point_cloud) {
00030     result.emplace_back(transform * point);
00031   }
00032   return result;
00033 }
00034 
00035 TimedPointCloud TransformTimedPointCloud(const TimedPointCloud& point_cloud,
00036                                          const transform::Rigid3f& transform) {
00037   TimedPointCloud result;
00038   result.reserve(point_cloud.size());
00039   for (const TimedRangefinderPoint& point : point_cloud) {
00040     result.push_back(transform * point);
00041   }
00042   return result;
00043 }
00044 
00045 PointCloud CropPointCloud(const PointCloud& point_cloud, const float min_z,
00046                           const float max_z) {
00047   PointCloud cropped_point_cloud;
00048   for (const RangefinderPoint& point : point_cloud) {
00049     if (min_z <= point.position.z() && point.position.z() <= max_z) {
00050       cropped_point_cloud.push_back(point);
00051     }
00052   }
00053   return cropped_point_cloud;
00054 }
00055 
00056 TimedPointCloud CropTimedPointCloud(const TimedPointCloud& point_cloud,
00057                                     const float min_z, const float max_z) {
00058   TimedPointCloud cropped_point_cloud;
00059   for (const TimedRangefinderPoint& point : point_cloud) {
00060     if (min_z <= point.position.z() && point.position.z() <= max_z) {
00061       cropped_point_cloud.push_back(point);
00062     }
00063   }
00064   return cropped_point_cloud;
00065 }
00066 
00067 }  // namespace sensor
00068 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35