SRBA: Sparser Relative Bundle Adjustment
|
00001 /* +---------------------------------------------------------------------------+ 00002 | Mobile Robot Programming Toolkit (MRPT) | 00003 | http://www.mrpt.org/ | 00004 | | 00005 | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file | 00006 | See: http://www.mrpt.org/Authors - All rights reserved. | 00007 | Released under BSD License. See details in http://www.mrpt.org/License | 00008 +---------------------------------------------------------------------------+ */ 00009 00010 #pragma once 00011 00012 namespace srba { 00013 00015 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS> 00016 template <class POSE_GRAPH> 00017 void RbaEngine<KF2KF_POSE_TYPE,LM_TYPE,OBS_TYPE,RBA_OPTIONS>::get_global_graphslam_problem( 00018 POSE_GRAPH &global_graph, 00019 const ExportGraphSLAM_Params ¶ms 00020 ) const 00021 { 00022 global_graph.clear(); 00023 if (rba_state.keyframes.empty()) 00024 return; // Nothing to do 00025 00026 // 1) Initialize global poses with a Spanning-tree: 00027 // ------------------------------------------------ 00028 frameid2pose_map_t spantree; 00029 create_complete_spanning_tree(params.root_kf_id,spantree); // Go thru COMPLETE graph (unbounded complexity, non O(1) ) 00030 00031 // For each key-frame, add a 3D corner: 00032 for (typename frameid2pose_map_t::const_iterator itP = spantree.begin();itP!=spantree.end();++itP) 00033 { 00034 const TKeyFrameID kf_id = itP->first; 00035 global_graph.nodes[kf_id] = itP->second.pose; 00036 } 00037 00038 // 2) Save KF-to-KF relative poses as edges: 00039 // ------------------------------------------------ 00040 for (typename k2k_edges_deque_t::const_iterator itEdge=rba_state.k2k_edges.begin();itEdge!=rba_state.k2k_edges.end();++itEdge) 00041 { 00042 const k2k_edge_t & edge = *itEdge; 00043 // Edges in RBA store *inverse* poses "from"->"to". 00044 // Save as "normal" poses "to"->"from" 00045 global_graph.insertEdgeAtEnd(edge.to, edge.from, edge.inv_pose); 00046 } 00047 00048 } 00049 00050 00051 } // End of namespaces