motion_filter.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 
20 #include "glog/logging.h"
21 
22 namespace cartographer {
23 namespace mapping_3d {
24 
25 proto::MotionFilterOptions CreateMotionFilterOptions(
26  common::LuaParameterDictionary* const parameter_dictionary) {
27  proto::MotionFilterOptions options;
28  options.set_max_time_seconds(
29  parameter_dictionary->GetDouble("max_time_seconds"));
30  options.set_max_distance_meters(
31  parameter_dictionary->GetDouble("max_distance_meters"));
32  options.set_max_angle_radians(
33  parameter_dictionary->GetDouble("max_angle_radians"));
34  return options;
35 }
36 
37 MotionFilter::MotionFilter(const proto::MotionFilterOptions& options)
38  : options_(options) {}
39 
41  const transform::Rigid3d& pose) {
42  LOG_IF_EVERY_N(INFO, num_total_ >= 500, 500)
43  << "Motion filter reduced the number of scans to "
44  << 100. * num_different_ / num_total_ << "%.";
45  ++num_total_;
46  if (num_total_ > 1 &&
47  time - last_time_ <= common::FromSeconds(options_.max_time_seconds()) &&
48  (pose.translation() - last_pose_.translation()).norm() <=
49  options_.max_distance_meters() &&
51  options_.max_angle_radians()) {
52  return true;
53  }
54  last_time_ = time;
55  last_pose_ = pose;
57  return false;
58 }
59 
60 } // namespace mapping_3d
61 } // namespace cartographer
proto::RangeDataInserterOptions options_
bool IsSimilar(common::Time time, const transform::Rigid3d &pose)
UniversalTimeScaleClock::time_point Time
Definition: time.h:44
transform::Rigid3d pose
Duration FromSeconds(const double seconds)
Definition: time.cc:24
const proto::MotionFilterOptions options_
Definition: motion_filter.h:44
const Vector & translation() const
FloatType GetAngle(const Rigid3< FloatType > &transform)
Definition: transform.h:34
MotionFilter(const proto::MotionFilterOptions &options)
proto::MotionFilterOptions CreateMotionFilterOptions(common::LuaParameterDictionary *const parameter_dictionary)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58