cost_helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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_COST_HELPERS_H_
18 #define CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_COST_HELPERS_H_
19 
20 #include "Eigen/Core"
21 #include "Eigen/Geometry"
24 
25 namespace cartographer {
26 namespace mapping {
27 namespace optimization {
28 
29 // Computes the error between the given relative pose and the difference of
30 // poses 'start' and 'end' which are both in an arbitrary common frame.
31 //
32 // 'start' and 'end' poses have the format [x, y, rotation].
33 template <typename T>
34 static std::array<T, 3> ComputeUnscaledError(
35  const transform::Rigid2d& relative_pose, const T* const start,
36  const T* const end);
37 template <typename T>
38 std::array<T, 3> ScaleError(const std::array<T, 3>& error,
39  double translation_weight, double rotation_weight);
40 
41 // Computes the error between the given relative pose and the difference of
42 // poses 'start' and 'end' which are both in an arbitrary common frame.
43 //
44 // 'start' and 'end' translation has the format [x, y, z].
45 // 'start' and 'end' rotation are quaternions in the format [w, n_1, n_2, n_3].
46 template <typename T>
47 static std::array<T, 6> ComputeUnscaledError(
48  const transform::Rigid3d& relative_pose, const T* const start_rotation,
49  const T* const start_translation, const T* const end_rotation,
50  const T* const end_translation);
51 
52 template <typename T>
53 std::array<T, 6> ScaleError(const std::array<T, 6>& error,
54  double translation_weight, double rotation_weight);
55 
56 // Computes spherical linear interpolation of unit quaternions.
57 //
58 // 'start' and 'end' are quaternions in the format [w, n_1, n_2, n_3].
59 template <typename T>
60 std::array<T, 4> SlerpQuaternions(const T* const start, const T* const end,
61  double factor);
62 
63 // Interpolates 3D poses. Linear interpolation is performed for translation and
64 // spherical-linear one for rotation.
65 template <typename T>
66 std::tuple<std::array<T, 4> /* rotation */, std::array<T, 3> /* translation */>
67 InterpolateNodes3D(const T* const prev_node_rotation,
68  const T* const prev_node_translation,
69  const T* const next_node_rotation,
70  const T* const next_node_translation,
71  const double interpolation_parameter);
72 
73 // Embeds 2D poses into 3D and interpolates them. Linear interpolation is
74 // performed for translation and spherical-linear one for rotation.
75 template <typename T>
76 std::tuple<std::array<T, 4> /* rotation */, std::array<T, 3> /* translation */>
77 InterpolateNodes2D(const T* const prev_node_pose,
78  const Eigen::Quaterniond& prev_node_gravity_alignment,
79  const T* const next_node_pose,
80  const Eigen::Quaterniond& next_node_gravity_alignment,
81  const double interpolation_parameter);
82 
83 } // namespace optimization
84 } // namespace mapping
85 } // namespace cartographer
86 
88 
89 #endif // CARTOGRAPHER_MAPPING_INTERNAL_OPTIMIZATION_COST_FUNCTIONS_COST_HELPERS_H_
Rigid3< double > Rigid3d
Rigid2< double > Rigid2d
std::tuple< std::array< T, 4 >, std::array< T, 3 > > InterpolateNodes3D(const T *const prev_node_rotation, const T *const prev_node_translation, const T *const next_node_rotation, const T *const next_node_translation, const double interpolation_parameter)
std::array< T, 3 > ScaleError(const std::array< T, 3 > &error, double translation_weight, double rotation_weight)
std::tuple< std::array< T, 4 >, std::array< T, 3 > > InterpolateNodes2D(const T *const prev_node_pose, const Eigen::Quaterniond &prev_node_gravity_alignment, const T *const next_node_pose, const Eigen::Quaterniond &next_node_gravity_alignment, const double interpolation_parameter)
static std::array< T, 3 > ComputeUnscaledError(const transform::Rigid2d &relative_pose, const T *const start, const T *const end)
std::array< T, 4 > SlerpQuaternions(const T *const start, const T *const end, double factor)


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