compressed_point_cloud.h
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 #ifndef CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
00018 #define CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_
00019 
00020 #include <iterator>
00021 #include <vector>
00022 
00023 #include "Eigen/Core"
00024 #include "cartographer/common/port.h"
00025 #include "cartographer/sensor/point_cloud.h"
00026 #include "cartographer/sensor/proto/sensor.pb.h"
00027 
00028 namespace cartographer {
00029 namespace sensor {
00030 
00031 // A compressed representation of a point cloud consisting of a collection of
00032 // points (Vector3f) without time information.
00033 // Internally, points are grouped by blocks. Each block encodes a bit of meta
00034 // data (number of points in block, coordinates of the block) and encodes each
00035 // point with a fixed bit rate in relation to the block.
00036 class CompressedPointCloud {
00037  public:
00038   class ConstIterator;
00039 
00040   CompressedPointCloud() : num_points_(0) {}
00041   explicit CompressedPointCloud(const PointCloud& point_cloud);
00042   explicit CompressedPointCloud(const proto::CompressedPointCloud& proto);
00043 
00044   // Returns decompressed point cloud.
00045   PointCloud Decompress() const;
00046 
00047   bool empty() const;
00048   size_t size() const;
00049   ConstIterator begin() const;
00050   ConstIterator end() const;
00051 
00052   bool operator==(const CompressedPointCloud& right_hand_container) const;
00053   proto::CompressedPointCloud ToProto() const;
00054 
00055  private:
00056   std::vector<int32> point_data_;
00057   size_t num_points_;
00058 };
00059 
00060 // Forward iterator for compressed point clouds.
00061 class CompressedPointCloud::ConstIterator {
00062  public:
00063   using iterator_category = std::forward_iterator_tag;
00064   using value_type = RangefinderPoint;
00065   using difference_type = int64;
00066   using pointer = const RangefinderPoint*;
00067   using reference = const RangefinderPoint&;
00068 
00069   // Creates begin iterator.
00070   explicit ConstIterator(const CompressedPointCloud* compressed_point_cloud);
00071 
00072   // Creates end iterator.
00073   static ConstIterator EndIterator(
00074       const CompressedPointCloud* compressed_point_cloud);
00075 
00076   RangefinderPoint operator*() const;
00077   ConstIterator& operator++();
00078   bool operator!=(const ConstIterator& it) const;
00079 
00080  private:
00081   // Reads next point from buffer. Also handles reading the meta data of the
00082   // next block, if the current block is depleted.
00083   void ReadNextPoint();
00084 
00085   const CompressedPointCloud* compressed_point_cloud_;
00086   size_t remaining_points_;
00087   int32 remaining_points_in_current_block_;
00088   Eigen::Vector3f current_point_;
00089   Eigen::Vector3i current_block_coordinates_;
00090   std::vector<int32>::const_iterator input_;
00091 };
00092 
00093 }  // namespace sensor
00094 }  // namespace cartographer
00095 
00096 #endif  // CARTOGRAPHER_SENSOR_COMPRESSED_POINT_CLOUD_H_


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