ceres_pose.cc
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 #include "cartographer/mapping/internal/optimization/ceres_pose.h"
00018 
00019 namespace cartographer {
00020 namespace mapping {
00021 namespace optimization {
00022 
00023 CeresPose::Data FromPose(const transform::Rigid3d& pose) {
00024   return CeresPose::Data{{{pose.translation().x(), pose.translation().y(),
00025                            pose.translation().z()}},
00026                          {{pose.rotation().w(), pose.rotation().x(),
00027                            pose.rotation().y(), pose.rotation().z()}}};
00028 }
00029 
00030 CeresPose::CeresPose(
00031     const transform::Rigid3d& pose,
00032     std::unique_ptr<ceres::LocalParameterization> translation_parametrization,
00033     std::unique_ptr<ceres::LocalParameterization> rotation_parametrization,
00034     ceres::Problem* problem)
00035     : data_(std::make_shared<CeresPose::Data>(FromPose(pose))) {
00036   problem->AddParameterBlock(data_->translation.data(), 3,
00037                              translation_parametrization.release());
00038   problem->AddParameterBlock(data_->rotation.data(), 4,
00039                              rotation_parametrization.release());
00040 }
00041 
00042 const transform::Rigid3d CeresPose::ToRigid() const {
00043   return transform::Rigid3d::FromArrays(data_->rotation, data_->translation);
00044 }
00045 
00046 }  // namespace optimization
00047 }  // namespace mapping
00048 }  // namespace cartographer


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