types_slam2d_online.h
Go to the documentation of this file.
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_SLAM2D_ONLINE_H
00018 #define TYPES_SLAM2D_ONLINE_H
00019 
00020 #include "g2o/types/slam2d/edge_se2.h"
00021 
00022 #include <iostream>
00023 
00024 namespace g2o {
00025 
00026   class OnlineVertexSE2 : public VertexSE2
00027   {
00028     public:
00029       EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
00030       OnlineVertexSE2() : VertexSE2() {}
00031 
00032       virtual void oplus(double* update)
00033       {
00034         VertexSE2::oplus(update);
00035         updatedEstimate = _estimate;
00036       }
00037 
00038       void oplusUpdatedEstimate(double* update)
00039       {
00040         updatedEstimate.translation().x()  = _estimate.translation().x() + update[0];
00041         updatedEstimate.translation().y()  = _estimate.translation().y() + update[1];
00042         updatedEstimate.rotation().angle() = normalize_theta(_estimate.rotation().angle() + update[2]);
00043         //std::cerr << PVAR(updatedEstimate.toVector()) << " " << PVAR(_estimate.toVector()) << std::endl;
00044       }
00045 
00046       VertexSE2::EstimateType updatedEstimate;
00047   };
00048 
00049   class OnlineEdgeSE2 : public EdgeSE2
00050   {
00051     public:
00052       EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
00053       OnlineEdgeSE2() : EdgeSE2() {}
00054 
00055       void initialEstimate(const OptimizableGraph::VertexSet& from, OptimizableGraph::Vertex* /* to */)
00056       {
00057         OnlineVertexSE2* fromEdge = static_cast<OnlineVertexSE2*>(_vertices[0]);
00058         OnlineVertexSE2* toEdge   = static_cast<OnlineVertexSE2*>(_vertices[1]);
00059         if (from.count(fromEdge) > 0) {
00060           toEdge->updatedEstimate = fromEdge->updatedEstimate * _measurement;
00061           toEdge->estimate() = toEdge->updatedEstimate;
00062         } else {
00063           fromEdge->updatedEstimate = toEdge->updatedEstimate * _inverseMeasurement;
00064           fromEdge->estimate() = fromEdge->updatedEstimate;
00065         }
00066       }
00067   };
00068 
00069 } // end namespace
00070 
00071 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:33:29