min_max_range_filtering_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 
22 
23 namespace cartographer {
24 namespace io {
25 
26 std::unique_ptr<MinMaxRangeFiteringPointsProcessor>
28  common::LuaParameterDictionary* const dictionary,
29  PointsProcessor* const next) {
30  return common::make_unique<MinMaxRangeFiteringPointsProcessor>(
31  dictionary->GetDouble("min_range"), dictionary->GetDouble("max_range"),
32  next);
33 }
34 
36  const double min_range, const double max_range, PointsProcessor* next)
37  : min_range_(min_range), max_range_(max_range), next_(next) {}
38 
40  std::unique_ptr<PointsBatch> batch) {
41  std::vector<int> to_remove;
42  for (size_t i = 0; i < batch->points.size(); ++i) {
43  const float range = (batch->points[i] - batch->origin).norm();
44  if (!(min_range_ <= range && range <= max_range_)) {
45  to_remove.push_back(i);
46  }
47  }
48  RemovePoints(to_remove, batch.get());
49  next_->Process(std::move(batch));
50 }
51 
53  return next_->Flush();
54 }
55 
56 } // namespace io
57 } // namespace cartographer
void RemovePoints(std::vector< int > to_remove, PointsBatch *batch)
Definition: points_batch.cc:22
virtual void Process(std::unique_ptr< PointsBatch > points_batch)=0
MinMaxRangeFiteringPointsProcessor(double min_range, double max_range, PointsProcessor *next)
virtual FlushResult Flush()=0
static std::unique_ptr< MinMaxRangeFiteringPointsProcessor > FromDictionary(common::LuaParameterDictionary *dictionary, PointsProcessor *next)


cartographer
Author(s):
autogenerated on Mon Jun 10 2019 12:51:39