Main MRPT website > C++ reference
MRPT logo
export_dot.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 #pragma once
11 
12 namespace mrpt { namespace srba {
13 
14 /** Exports all the keyframes and landmarks as a directed graph in DOT (graphviz) format */
15 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS>
17  const std::string &targetFileName,
18  const bool all_landmarks
19  ) const
20 {
21  using namespace std;
22 
23  std::ofstream f(targetFileName.c_str());
24  if (!f.is_open()) return false;
25 
26  f << "digraph G {\n";
27 
28  if (!rba_state.keyframes.empty())
29  {
30  // Keyframes:
31  f << "/* KEYFRAMES */\n"
32  "node [shape=box,style=filled];\n";
33  //for (typename rba_problem_state_t::keyframe_map_t::const_iterator it=rba_state.keyframes.begin();it!=rba_state.keyframes.end();++it)
34  for (size_t id=0;id<rba_state.keyframes.size();++id)
35  f << id << "; ";
36  f << "\n";
37 
38  // k2k edges:
39  f << "/* KEYFRAME->KEYFRAME edges */\n"
40  "edge [style=bold];\n";
41 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
42  for (typename rba_problem_state_t::k2k_edges_deque_t::const_iterator itEdge2 = rba_state.k2k_edges.begin();itEdge2!=rba_state.k2k_edges.end();++itEdge2)
43  {
44  const k2k_edge_t * itEdge = itEdge2->pointer();
45 #else
46  for (typename rba_problem_state_t::k2k_edges_deque_t::const_iterator itEdge = rba_state.k2k_edges.begin();itEdge!=rba_state.k2k_edges.end();++itEdge)
47  {
48 #endif
49  f << itEdge->from << "->" << itEdge->to << ";\n";
50  }
51 
52  if (all_landmarks)
53  {
54  // Landmarks with fixed position:
55  f << "/* LANDMARKS with known relative position, and its base keyframe */\n"
56  "node [shape=triangle,style=filled,fillcolor=gray80];\n"
57  "edge [style=bold,color=black];\n";
58  for (typename TRelativeLandmarkPosMap::const_iterator itLM = rba_state.known_lms.begin();itLM != rba_state.known_lms.end();++itLM)
59  f << itLM->second.id_frame_base << " -> " << "L"<<itLM->first << "; ";
60  f << "\n";
61 
62  // Landmarks with fixed position:
63  f << "/* LANDMARKS with unknown relative position */\n"
64  "node [shape=triangle,style=filled,fillcolor=white];\n"
65  "edge [style=solid,color=gray20];\n";
66  for (typename TRelativeLandmarkPosMap::const_iterator itLM = rba_state.unknown_lms.begin();itLM != rba_state.unknown_lms.end();++itLM)
67  f << itLM->second.id_frame_base << " -> " << "L"<<itLM->first << "; ";
68  f << "\n";
69 
70  // Observations:
71  f << "/* OBSERVATIONS */\n"
72  "edge [style=dotted,color=black];\n";
73 
74 
75  for (typename rba_problem_state_t::all_observations_deque_t::const_iterator itO=rba_state.all_observations.begin();itO!=rba_state.all_observations.end();++itO)
76  {
77 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
78  f << (*itO)->obs.kf_id << " -> L" << (*itO)->obs.obs.feat_id << ";\n";
79 #else
80  f << itO->obs.kf_id << " -> L" << itO->obs.obs.feat_id << ";\n";
81 #endif
82  }
83  f << "\n";
84  }
85 
86  } // end if graph is not empty
87 
88  f << "\n}\n";
89 
90  return true;
91 }
92 
93 
94 } } // end namespaces
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:24
Keyframe-to-keyframe edge: an unknown of the problem.
Definition: srba_types.h:82
bool save_graph_as_dot(const std::string &targetFileName, const bool all_landmarks=false) const
Exports all the keyframes (and optionally all landmarks) as a directed graph in DOT (graphviz) format...
Definition: export_dot.h:16
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



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