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) without time information.
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  explicit CompressedPointCloud(const proto::CompressedPointCloud& proto);
43 
44  // Returns decompressed point cloud.
45  PointCloud Decompress() const;
46 
47  bool empty() const;
48  size_t size() const;
49  ConstIterator begin() const;
50  ConstIterator end() const;
51 
52  bool operator==(const CompressedPointCloud& right_hand_container) const;
53  proto::CompressedPointCloud ToProto() const;
54 
55  private:
56  std::vector<int32> point_data_;
57  size_t num_points_;
58 };
59 
60 // Forward iterator for compressed point clouds.
62  public:
63  using iterator_category = std::forward_iterator_tag;
64  using value_type = Eigen::Vector3f;
66  using pointer = const Eigen::Vector3f*;
67  using reference = const Eigen::Vector3f&;
68 
69  // Creates begin iterator.
70  explicit ConstIterator(const CompressedPointCloud* compressed_point_cloud);
71 
72  // Creates end iterator.
73  static ConstIterator EndIterator(
74  const CompressedPointCloud* compressed_point_cloud);
75 
76  Eigen::Vector3f operator*() const;
77  ConstIterator& operator++();
78  bool operator!=(const ConstIterator& it) const;
79 
80  private:
81  // Reads next point from buffer. Also handles reading the meta data of the
82  // next block, if the current block is depleted.
83  void ReadNextPoint();
84 
88  Eigen::Vector3f current_point_;
89  Eigen::Vector3i current_block_coordinates_;
90  std::vector<int32>::const_iterator input_;
91 };
92 
93 } // namespace sensor
94 } // namespace cartographer
95 
96 #endif // CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
proto::CompressedPointCloud ToProto() const
bool operator==(const CompressedPointCloud &right_hand_container) const
int64_t int64
Definition: port.h:33
Rigid2< FloatType > operator*(const Rigid2< FloatType > &lhs, const Rigid2< FloatType > &rhs)
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:32
int32_t int32
Definition: port.h:32


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