range_data.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  return RangeData{
28  transform * range_data.origin,
29  TransformPointCloud(range_data.returns, transform),
30  TransformPointCloud(range_data.misses, transform),
31  };
32 }
33 
35  const transform::Rigid3f& transform) {
36  return TimedRangeData{
37  transform * range_data.origin,
38  TransformTimedPointCloud(range_data.returns, transform),
39  TransformTimedPointCloud(range_data.misses, transform),
40  };
41 }
42 
43 RangeData CropRangeData(const RangeData& range_data, const float min_z,
44  const float max_z) {
45  return RangeData{range_data.origin,
46  CropPointCloud(range_data.returns, min_z, max_z),
47  CropPointCloud(range_data.misses, min_z, max_z)};
48 }
49 
51  const float min_z, const float max_z) {
52  return TimedRangeData{range_data.origin,
53  CropTimedPointCloud(range_data.returns, min_z, max_z),
54  CropTimedPointCloud(range_data.misses, min_z, max_z)};
55 }
56 
57 proto::RangeData ToProto(const RangeData& range_data) {
58  proto::RangeData proto;
59  *proto.mutable_origin() = transform::ToProto(range_data.origin);
60  proto.mutable_returns()->Reserve(range_data.returns.size());
61  for (const Eigen::Vector3f& point : range_data.returns) {
62  *proto.add_returns() = transform::ToProto(point);
63  }
64  proto.mutable_misses()->Reserve(range_data.misses.size());
65  for (const Eigen::Vector3f& point : range_data.misses) {
66  *proto.add_misses() = transform::ToProto(point);
67  }
68  return proto;
69 }
70 
71 RangeData FromProto(const proto::RangeData& proto) {
72  PointCloud returns;
73  returns.reserve(proto.returns().size());
74  std::transform(
75  proto.returns().begin(), proto.returns().end(),
76  std::back_inserter(returns),
77  static_cast<Eigen::Vector3f (*)(const transform::proto::Vector3f&)>(
79  PointCloud misses;
80  misses.reserve(proto.misses().size());
81  std::transform(
82  proto.misses().begin(), proto.misses().end(), std::back_inserter(misses),
83  static_cast<Eigen::Vector3f (*)(const transform::proto::Vector3f&)>(
85  return RangeData{transform::ToEigen(proto.origin()), returns, misses};
86 }
87 
88 } // namespace sensor
89 } // 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
proto::FixedFramePoseData ToProto(const FixedFramePoseData &pose_data)
FixedFramePoseData FromProto(const proto::FixedFramePoseData &proto)
RangeData TransformRangeData(const RangeData &range_data, const transform::Rigid3f &transform)
Definition: range_data.cc:25
PointCloud CropPointCloud(const PointCloud &point_cloud, const float min_z, const float max_z)
Definition: point_cloud.cc:48
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:48
TimedRangeData TransformTimedRangeData(const TimedRangeData &range_data, const transform::Rigid3f &transform)
Definition: range_data.cc:34
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:32
TimedRangeData CropTimedRangeData(const TimedRangeData &range_data, const float min_z, const float max_z)
Definition: range_data.cc:50
Eigen::Transform< T, 2, Eigen::Affine > ToEigen(const Rigid2< T > &rigid2)
RangeData CropRangeData(const RangeData &range_data, const float min_z, const float max_z)
Definition: range_data.cc:43
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