spa_cost_function_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_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_
18 #define CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_
19 
20 #include <array>
21 
22 #include "Eigen/Core"
23 #include "Eigen/Geometry"
29 #include "ceres/ceres.h"
30 #include "ceres/jet.h"
31 
32 namespace cartographer {
33 namespace mapping {
34 namespace optimization {
35 
37  public:
38  static ceres::CostFunction* CreateAutoDiffCostFunction(
39  const PoseGraph::Constraint::Pose& pose) {
40  return new ceres::AutoDiffCostFunction<
41  SpaCostFunction3D, 6 /* residuals */, 4 /* rotation variables */,
42  3 /* translation variables */, 4 /* rotation variables */,
43  3 /* translation variables */>(new SpaCostFunction3D(pose));
44  }
45 
46  template <typename T>
47  bool operator()(const T* const c_i_rotation, const T* const c_i_translation,
48  const T* const c_j_rotation, const T* const c_j_translation,
49  T* const e) const {
50  const std::array<T, 6> error = ScaleError(
51  ComputeUnscaledError(pose_.zbar_ij, c_i_rotation, c_i_translation,
52  c_j_rotation, c_j_translation),
53  pose_.translation_weight, pose_.rotation_weight);
54  std::copy(std::begin(error), std::end(error), e);
55  return true;
56  }
57 
58  private:
59  explicit SpaCostFunction3D(const PoseGraph::Constraint::Pose& pose)
60  : pose_(pose) {}
61 
62  const PoseGraph::Constraint::Pose pose_;
63 };
64 
65 } // namespace optimization
66 } // namespace mapping
67 } // namespace cartographer
68 
69 #endif // CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_
bool operator()(const T *const c_i_rotation, const T *const c_i_translation, const T *const c_j_rotation, const T *const c_j_translation, T *const e) const
SpaCostFunction3D(const PoseGraph::Constraint::Pose &pose)
std::array< T, 3 > ScaleError(const std::array< T, 3 > &error, double translation_weight, double rotation_weight)
transform::Rigid3d pose
static std::array< T, 3 > ComputeUnscaledError(const transform::Rigid2d &relative_pose, const T *const start, const T *const end)
static ceres::CostFunction * CreateAutoDiffCostFunction(const PoseGraph::Constraint::Pose &pose)


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