Main MRPT website > C++ reference
MRPT logo
alloc_kf2kf_edge.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 
11 #pragma once
12 
13 namespace mrpt { namespace srba {
14 
15 // See header & papers for docs
16 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS>
18  const TPairKeyFrameID &ids,
19  const pose_t &init_inv_pose_val )
20 {
21  // Create edge:
22 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
23  k2k_edges.push_back( stlplus::smart_ptr<k2k_edge_t>(new k2k_edge_t)); // O(1)
24  k2k_edge_t & new_edge = *(*k2k_edges.rbegin());
25 #else
26  k2k_edges.push_back(k2k_edge_t()); // O(1)
27  k2k_edge_t & new_edge = *k2k_edges.rbegin();
28 #endif
29 
30  new_edge.from = ids.first;
31  new_edge.to = ids.second;
32 
33  ASSERT_(new_edge.from!=new_edge.to)
34 
35  new_edge.inv_pose = init_inv_pose_val;
36 
37  new_edge.id = k2k_edges.size()-1; // For convenience, save index within the same structure.
38 
39 #ifdef _DEBUG
40  {
41  // Security consistency check for user introducing duplicated edges:
42  std::deque<k2k_edge_t*> &edges = keyframes[ids.first ].adjacent_k2k_edges;
43  for (size_t i=0;i<edges.size();++i)
44  {
45  const k2k_edge_t &e = *edges[i];
46  if ( (e.to==ids.first && e.from==ids.second) ||
47  (e.from==ids.first && e.to==ids.second) )
48  {
49  throw std::runtime_error( mrpt::format("[alloc_kf2kf_edge] ERROR: Edge already exists between %u -> %u",static_cast<unsigned int>(ids.first),static_cast<unsigned int>(ids.second) ) );
50  }
51  }
52  }
53 #endif
54 
55  // Update adjacency lists: O(1)
56  keyframes[ids.first ].adjacent_k2k_edges.push_back(&new_edge);
57  keyframes[ids.second].adjacent_k2k_edges.push_back(&new_edge);
58 
59  // Expand dh_dAp Jacobian to make room for a new column for this new edge:
60  const size_t remapIdx = new_edge.id;
61  //TSparseBlocksJacobians_dh_dAp::col_t & col =
62  lin_system.dh_dAp.appendCol(remapIdx); // O(1) with map_as_vector
63 
64  return new_edge.id;
65 
66 } // end of alloc_kf2kf_edge
67 
68 } } // end NS
size_t alloc_kf2kf_edge(const TPairKeyFrameID &ids, const pose_t &init_inv_pose_val=pose_t())
Creates a new kf2kf edge variable.
size_t id
0-based index of this edge, in the std::list "k2k_edges".
Definition: srba_types.h:88
Keyframe-to-keyframe edge: an unknown of the problem.
Definition: srba_types.h:82
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
pose_t inv_pose
Inverse pose: pose_from (-) pose_to , that is: "from" as seen from "to".
Definition: srba_types.h:86
std::pair< TKeyFrameID, TKeyFrameID > TPairKeyFrameID
Used to represent the IDs of a directed edge (first –> second)
Definition: srba_types.h:34
#define ASSERT_(f)
KF2KF_POSE_TYPE::pose_t pose_t
Definition: srba_types.h:476



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015