spa_cost_function_3d.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_
00018 #define CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_
00019 
00020 #include <array>
00021 
00022 #include "Eigen/Core"
00023 #include "Eigen/Geometry"
00024 #include "cartographer/common/math.h"
00025 #include "cartographer/mapping/internal/optimization/cost_functions/cost_helpers.h"
00026 #include "cartographer/mapping/pose_graph.h"
00027 #include "cartographer/transform/rigid_transform.h"
00028 #include "cartographer/transform/transform.h"
00029 #include "ceres/ceres.h"
00030 #include "ceres/jet.h"
00031 
00032 namespace cartographer {
00033 namespace mapping {
00034 namespace optimization {
00035 
00036 class SpaCostFunction3D {
00037  public:
00038   static ceres::CostFunction* CreateAutoDiffCostFunction(
00039       const PoseGraph::Constraint::Pose& pose) {
00040     return new ceres::AutoDiffCostFunction<
00041         SpaCostFunction3D, 6 /* residuals */, 4 /* rotation variables */,
00042         3 /* translation variables */, 4 /* rotation variables */,
00043         3 /* translation variables */>(new SpaCostFunction3D(pose));
00044   }
00045 
00046   template <typename T>
00047   bool operator()(const T* const c_i_rotation, const T* const c_i_translation,
00048                   const T* const c_j_rotation, const T* const c_j_translation,
00049                   T* const e) const {
00050     const std::array<T, 6> error = ScaleError(
00051         ComputeUnscaledError(pose_.zbar_ij, c_i_rotation, c_i_translation,
00052                              c_j_rotation, c_j_translation),
00053         pose_.translation_weight, pose_.rotation_weight);
00054     std::copy(std::begin(error), std::end(error), e);
00055     return true;
00056   }
00057 
00058  private:
00059   explicit SpaCostFunction3D(const PoseGraph::Constraint::Pose& pose)
00060       : pose_(pose) {}
00061 
00062   const PoseGraph::Constraint::Pose pose_;
00063 };
00064 
00065 }  // namespace optimization
00066 }  // namespace mapping
00067 }  // namespace cartographer
00068 
00069 #endif  // CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_SPA_COST_FUNCTION_3D_H_


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:36