fixed_ratio_sampling_points_processor.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_IO_FIXED_RATIO_SAMPLING_POINTS_PROCESSOR_H_
00018 #define CARTOGRAPHER_IO_FIXED_RATIO_SAMPLING_POINTS_PROCESSOR_H_
00019 
00020 #include <memory>
00021 
00022 #include "cartographer/common/fixed_ratio_sampler.h"
00023 #include "cartographer/common/lua_parameter_dictionary.h"
00024 #include "cartographer/io/points_processor.h"
00025 
00026 namespace cartographer {
00027 namespace io {
00028 
00029 // Only let a fixed 'sampling_ratio' of points through. A 'sampling_ratio' of 1.
00030 // makes this filter a no-op.
00031 class FixedRatioSamplingPointsProcessor : public PointsProcessor {
00032  public:
00033   constexpr static const char* kConfigurationFileActionName =
00034       "fixed_ratio_sampler";
00035 
00036   FixedRatioSamplingPointsProcessor(double sampling_ratio,
00037                                     PointsProcessor* next);
00038 
00039   static std::unique_ptr<FixedRatioSamplingPointsProcessor> FromDictionary(
00040       common::LuaParameterDictionary* dictionary, PointsProcessor* next);
00041 
00042   ~FixedRatioSamplingPointsProcessor() override{};
00043 
00044   FixedRatioSamplingPointsProcessor(const FixedRatioSamplingPointsProcessor&) =
00045       delete;
00046   FixedRatioSamplingPointsProcessor& operator=(
00047       const FixedRatioSamplingPointsProcessor&) = delete;
00048 
00049   void Process(std::unique_ptr<PointsBatch> batch) override;
00050   FlushResult Flush() override;
00051 
00052  private:
00053   const double sampling_ratio_;
00054   PointsProcessor* const next_;
00055   std::unique_ptr<common::FixedRatioSampler> sampler_;
00056 };
00057 
00058 }  // namespace io
00059 }  // namespace cartographer
00060 
00061 #endif  // CARTOGRAPHER_IO_FIXED_RATIO_SAMPLING_POINTS_PROCESSOR_H_


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