translation_delta_cost_functor_3d.h
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 
17 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_TRANSLATION_DELTA_COST_FUNCTOR_3D_H_
18 #define CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_TRANSLATION_DELTA_COST_FUNCTOR_3D_H_
19 
20 #include "Eigen/Core"
21 #include "ceres/ceres.h"
22 
23 namespace cartographer {
24 namespace mapping {
25 namespace scan_matching {
26 
27 // Computes the cost of translating 'translation' to 'target_translation'.
28 // Cost increases with the solution's distance from 'target_translation'.
30  public:
31  static ceres::CostFunction* CreateAutoDiffCostFunction(
32  const double scaling_factor, const Eigen::Vector3d& target_translation) {
33  return new ceres::AutoDiffCostFunction<TranslationDeltaCostFunctor3D,
34  3 /* residuals */,
35  3 /* translation variables */>(
36  new TranslationDeltaCostFunctor3D(scaling_factor, target_translation));
37  }
38 
39  template <typename T>
40  bool operator()(const T* const translation, T* residual) const {
41  residual[0] = scaling_factor_ * (translation[0] - x_);
42  residual[1] = scaling_factor_ * (translation[1] - y_);
43  residual[2] = scaling_factor_ * (translation[2] - z_);
44  return true;
45  }
46 
47  private:
48  // Constructs a new TranslationDeltaCostFunctor3D from the given
49  // 'target_translation'.
51  const double scaling_factor, const Eigen::Vector3d& target_translation)
52  : scaling_factor_(scaling_factor),
53  x_(target_translation.x()),
54  y_(target_translation.y()),
55  z_(target_translation.z()) {}
56 
59  const TranslationDeltaCostFunctor3D&) = delete;
60 
61  const double scaling_factor_;
62  const double x_;
63  const double y_;
64  const double z_;
65 };
66 
67 } // namespace scan_matching
68 } // namespace mapping
69 } // namespace cartographer
70 
71 #endif // CARTOGRAPHER_MAPPING_INTERNAL_3D_SCAN_MATCHING_TRANSLATION_DELTA_COST_FUNCTOR_3D_H_
TranslationDeltaCostFunctor3D & operator=(const TranslationDeltaCostFunctor3D &)=delete
TranslationDeltaCostFunctor3D(const double scaling_factor, const Eigen::Vector3d &target_translation)
static ceres::CostFunction * CreateAutoDiffCostFunction(const double scaling_factor, const Eigen::Vector3d &target_translation)


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