compressed_point_cloud.h
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 
17 #ifndef CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
18 #define CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
19 
20 #include <iterator>
21 #include <vector>
22 
23 #include "Eigen/Core"
26 #include "cartographer/sensor/proto/sensor.pb.h"
27 
28 namespace cartographer {
29 namespace sensor {
30 
31 // A compressed representation of a point cloud consisting of a collection of
32 // points (Vector3f).
33 // Internally, points are grouped by blocks. Each block encodes a bit of meta
34 // data (number of points in block, coordinates of the block) and encodes each
35 // point with a fixed bit rate in relation to the block.
37  public:
38  class ConstIterator;
39 
41  explicit CompressedPointCloud(const PointCloud& point_cloud);
42 
43  // Returns decompressed point cloud.
44  PointCloud Decompress() const;
45 
46  bool empty() const;
47  size_t size() const;
48  ConstIterator begin() const;
49  ConstIterator end() const;
50 
51  proto::CompressedPointCloud ToProto() const;
52 
53  private:
54  CompressedPointCloud(const std::vector<int32>& point_data, size_t num_points);
55 
56  std::vector<int32> point_data_;
57  size_t num_points_;
58 };
59 
60 // Forward iterator for compressed point clouds.
62  : public std::iterator<std::forward_iterator_tag, Eigen::Vector3f> {
63  public:
64  // Creates begin iterator.
65  explicit ConstIterator(const CompressedPointCloud* compressed_point_cloud);
66 
67  // Creates end iterator.
68  static ConstIterator EndIterator(
69  const CompressedPointCloud* compressed_point_cloud);
70 
71  Eigen::Vector3f operator*() const;
72  ConstIterator& operator++();
73  bool operator!=(const ConstIterator& it) const;
74 
75  private:
76  // Reads next point from buffer. Also handles reading the meta data of the
77  // next block, if the current block is depleted.
78  void ReadNextPoint();
79 
83  Eigen::Vector3f current_point_;
84  Eigen::Vector3i current_block_coordinates_;
85  std::vector<int32>::const_iterator input_;
86 };
87 
88 } // namespace sensor
89 } // namespace cartographer
90 
91 #endif // CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
int32_t int32
Definition: port.h:30
proto::CompressedPointCloud ToProto() const
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:30
GaussianDistribution< T, N > operator*(const Eigen::Matrix< T, N, M > &lhs, const GaussianDistribution< T, M > &rhs)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58