fast_global_localizer.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 "glog/logging.h"
20 
21 namespace cartographer {
22 namespace mapping_2d {
23 namespace scan_matching {
24 
26  const float cutoff,
28  const std::vector<
30  matchers,
31  const cartographer::sensor::PointCloud& point_cloud,
32  transform::Rigid2d* const best_pose_estimate, float* const best_score) {
33  CHECK(best_pose_estimate != nullptr)
34  << "Need a non-null output_pose_estimate!";
35  CHECK(best_score != nullptr) << "Need a non-null best_score!";
36  *best_score = cutoff;
37  transform::Rigid2d pose_estimate;
38  const sensor::PointCloud filtered_point_cloud =
39  voxel_filter.Filter(point_cloud);
40  bool success = false;
41  if (matchers.size() == 0) {
42  LOG(WARNING) << "Map not yet large enough to localize in!";
43  return false;
44  }
45  for (auto& matcher : matchers) {
46  float score = -1;
47  transform::Rigid2d pose_estimate;
48  if (matcher->MatchFullSubmap(filtered_point_cloud, *best_score, &score,
49  &pose_estimate)) {
50  CHECK_GT(score, *best_score) << "MatchFullSubmap lied!";
51  *best_score = score;
52  *best_pose_estimate = pose_estimate;
53  success = true;
54  }
55  }
56  return success;
57 }
58 
59 } // namespace scan_matching
60 } // namespace mapping_2d
61 } // namespace cartographer
bool PerformGlobalLocalization(const float cutoff, const cartographer::sensor::AdaptiveVoxelFilter &voxel_filter, const std::vector< cartographer::mapping_2d::scan_matching::FastCorrelativeScanMatcher * > &matchers, const cartographer::sensor::PointCloud &point_cloud, transform::Rigid2d *const best_pose_estimate, float *const best_score)
PointCloud Filter(const PointCloud &point_cloud) const
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:30


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