00001 // g2o - General Graph Optimization 00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard 00003 // 00004 // g2o is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU Lesser General Public License as published 00006 // by the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // g2o is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #ifndef TYPES_SLAM3D_ONLINE_H 00018 #define TYPES_SLAM3D_ONLINE_H 00019 00020 #include "g2o/types/slam3d/edge_se3_quat.h" 00021 00022 #include <iostream> 00023 00024 namespace g2o { 00025 00026 using namespace Eigen; 00027 00028 class OnlineVertexSE3 : public VertexSE3 00029 { 00030 public: 00031 EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 00032 OnlineVertexSE3() : VertexSE3() {} 00033 00034 virtual void oplus(double* update) 00035 { 00036 VertexSE3::oplus(update); 00037 updatedEstimate = _estimate; 00038 } 00039 00040 void oplusUpdatedEstimate(double* update) 00041 { 00042 Map<Vector6d> v(update); 00043 SE3Quat increment(v); 00044 updatedEstimate = estimate() * increment; 00045 } 00046 00047 VertexSE3::EstimateType updatedEstimate; 00048 }; 00049 00050 class OnlineEdgeSE3 : public EdgeSE3 00051 { 00052 public: 00053 EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 00054 OnlineEdgeSE3() : EdgeSE3() {} 00055 00056 void initialEstimate(const OptimizableGraph::VertexSet& from, OptimizableGraph::Vertex* /* to */) 00057 { 00058 OnlineVertexSE3* fromEdge = static_cast<OnlineVertexSE3*>(_vertices[0]); 00059 OnlineVertexSE3* toEdge = static_cast<OnlineVertexSE3*>(_vertices[1]); 00060 if (from.count(fromEdge) > 0) { 00061 toEdge->updatedEstimate = fromEdge->updatedEstimate * _measurement; 00062 toEdge->estimate() = toEdge->updatedEstimate; 00063 } else { 00064 fromEdge->updatedEstimate = toEdge->updatedEstimate * _inverseMeasurement; 00065 fromEdge->estimate() = fromEdge->updatedEstimate; 00066 } 00067 } 00068 }; 00069 00070 } // end namespace 00071 00072 #endif