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 
25 proto::RangeData ToProto(const RangeData& range_data) {
26  proto::RangeData proto;
27  *proto.mutable_origin() = transform::ToProto(range_data.origin);
28  *proto.mutable_point_cloud() = ToProto(range_data.returns);
29  *proto.mutable_missing_echo_point_cloud() = ToProto(range_data.misses);
30  return proto;
31 }
32 
33 RangeData FromProto(const proto::RangeData& proto) {
34  auto range_data = RangeData{
35  transform::ToEigen(proto.origin()), ToPointCloud(proto.point_cloud()),
36  ToPointCloud(proto.missing_echo_point_cloud()),
37  };
38  return range_data;
39 }
40 
42  const transform::Rigid3f& transform) {
43  return RangeData{
44  transform * range_data.origin,
45  TransformPointCloud(range_data.returns, transform),
46  TransformPointCloud(range_data.misses, transform),
47  };
48 }
49 
50 RangeData CropRangeData(const RangeData& range_data, const float min_z,
51  const float max_z) {
52  return RangeData{range_data.origin, Crop(range_data.returns, min_z, max_z),
53  Crop(range_data.misses, min_z, max_z)};
54 }
55 
57  return CompressedRangeData{
58  range_data.origin, CompressedPointCloud(range_data.returns),
59  CompressedPointCloud(range_data.misses),
60  };
61 }
62 
63 RangeData Decompress(const CompressedRangeData& compressed_range_data) {
64  return RangeData{compressed_range_data.origin,
65  compressed_range_data.returns.Decompress(),
66  compressed_range_data.misses.Decompress()};
67 }
68 
69 } // namespace sensor
70 } // 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
RangeData TransformRangeData(const RangeData &range_data, const transform::Rigid3f &transform)
Definition: range_data.cc:41
RangeData Decompress(const CompressedRangeData &compressed_range_data)
Definition: range_data.cc:63
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:44
proto::PointCloud ToProto(const PointCloud &point_cloud)
Definition: point_cloud.cc:46
CompressedRangeData Compress(const RangeData &range_data)
Definition: range_data.cc:56
RangeData FromProto(const proto::RangeData &proto)
Definition: range_data.cc:33
PointCloud ToPointCloud(const proto::PointCloud &proto)
Definition: point_cloud.cc:56
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:50


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