fixed_ratio_sampling_points_processor.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 "Eigen/Core"
21 #include "glog/logging.h"
22 
23 namespace cartographer {
24 namespace io {
25 
26 std::unique_ptr<FixedRatioSamplingPointsProcessor>
28  common::LuaParameterDictionary* const dictionary,
29  PointsProcessor* const next) {
30  const double sampling_ratio(dictionary->GetDouble("sampling_ratio"));
31  CHECK_LT(0., sampling_ratio) << "Sampling ratio <= 0 makes no sense.";
32  CHECK_LT(sampling_ratio, 1.) << "Sampling ratio >= 1 makes no sense.";
33  return common::make_unique<FixedRatioSamplingPointsProcessor>(sampling_ratio,
34  next);
35 }
36 
38  const double sampling_ratio, PointsProcessor* next)
39  : sampling_ratio_(sampling_ratio),
40  next_(next),
41  sampler_(new common::FixedRatioSampler(sampling_ratio_)) {}
42 
44  std::unique_ptr<PointsBatch> batch) {
45  std::unordered_set<int> to_remove;
46  for (size_t i = 0; i < batch->points.size(); ++i) {
47  if (!sampler_->Pulse()) {
48  to_remove.insert(i);
49  }
50  }
51  RemovePoints(to_remove, batch.get());
52  next_->Process(std::move(batch));
53 }
54 
56  switch (next_->Flush()) {
59 
61  sampler_ =
62  common::make_unique<common::FixedRatioSampler>(sampling_ratio_);
64  }
65  LOG(FATAL);
66 }
67 
68 } // namespace io
69 } // namespace cartographer
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
void RemovePoints(std::unordered_set< int > to_remove, PointsBatch *batch)
Definition: points_batch.cc:22
void Process(std::unique_ptr< PointsBatch > batch) override
static std::unique_ptr< FixedRatioSamplingPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)
virtual FlushResult Flush()=0
FixedRatioSamplingPointsProcessor(double sampling_ratio, PointsProcessor *next)


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