Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_MAPPING_INTERNAL_3D_ROTATION_PARAMETERIZATION_H_
00018 #define CARTOGRAPHER_MAPPING_INTERNAL_3D_ROTATION_PARAMETERIZATION_H_
00019
00020 #include "cartographer/common/math.h"
00021 #include "ceres/jet.h"
00022 #include "ceres/rotation.h"
00023
00024 namespace cartographer {
00025 namespace mapping {
00026
00027 struct YawOnlyQuaternionPlus {
00028 template <typename T>
00029 bool operator()(const T* x, const T* delta, T* x_plus_delta) const {
00030 const T clamped_delta = common::Clamp(delta[0], T(-0.5), T(0.5));
00031 T q_delta[4];
00032 q_delta[0] = ceres::sqrt(1. - clamped_delta * clamped_delta);
00033 q_delta[1] = T(0.);
00034 q_delta[2] = T(0.);
00035 q_delta[3] = clamped_delta;
00036 ceres::QuaternionProduct(q_delta, x, x_plus_delta);
00037 return true;
00038 }
00039 };
00040
00041 struct ConstantYawQuaternionPlus {
00042 template <typename T>
00043 bool operator()(const T* x, const T* delta, T* x_plus_delta) const {
00044 const T delta_norm =
00045 ceres::sqrt(common::Pow2(delta[0]) + common::Pow2(delta[1]));
00046 const T sin_delta_over_delta =
00047 delta_norm < 1e-6 ? T(1.) : ceres::sin(delta_norm) / delta_norm;
00048 T q_delta[4];
00049 q_delta[0] = delta_norm < 1e-6 ? T(1.) : ceres::cos(delta_norm);
00050 q_delta[1] = sin_delta_over_delta * delta[0];
00051 q_delta[2] = sin_delta_over_delta * delta[1];
00052 q_delta[3] = T(0.);
00053
00054
00055
00056
00057
00058
00059 ceres::QuaternionProduct(x, q_delta, x_plus_delta);
00060 return true;
00061 }
00062 };
00063
00064 }
00065 }
00066
00067 #endif // CARTOGRAPHER_MAPPING_INTERNAL_3D_ROTATION_PARAMETERIZATION_H_