19 namespace mrpt {
namespace srba {
23 template <
class KF2KF_POSE_TYPE,
class LM_TYPE,
class OBS_TYPE,
class RBA_OPTIONS>
27 mrpt::opengl::CSetOfObjectsPtr out_scene,
28 mrpt::opengl::CSetOfObjectsPtr out_root_tree
41 if (!rba_state.keyframes.empty())
52 if (root_keyframe==itP->first)
continue;
54 const CPose3D p = itP->second.pose;
58 o->setName(
mrpt::format(
"%d",
int(itP->first)).c_str() );
71 gl_edges->setColor(1,0,1);
72 #ifdef SRBA_WORKAROUND_MSVC9_DEQUE_BUG
75 const k2k_edge_t * itEdge = itEdge2->pointer();
81 if (itEdge->
from!=root_keyframe)
84 if(itN1==spantree.end())
86 p1 = itN1->second.pose;
89 if (itEdge->
to!=root_keyframe)
92 if(itN2==spantree.end())
94 p2 = itN2->second.pose;
96 gl_edges->appendLine(p1.x(),p1.y(),p1.z(), p2.x(),p2.y(),p2.z());
98 out_scene->insert(gl_edges);
112 out_root_tree->clear();
114 const float NODE_RADIUS = 1;
115 const float ROW_HEIGHT = 4*NODE_RADIUS;
116 const float COL_WIDTH = 3*NODE_RADIUS;
119 ASSERT_(it_st_root != rba_state.spanning_tree.sym.next_edge.end())
121 const std::map<TKeyFrameID,TSpanTreeEntry> & st_root = it_st_root->second;
123 std::map<TKeyFrameID,topo_dist_t> children_depths;
124 std::map<
topo_dist_t,std::vector<TKeyFrameID> > children_by_depth;
127 children_depths[root_keyframe]=0;
128 children_by_depth[0].push_back(root_keyframe);
132 size_t max_depth = 0;
136 children_depths[it->first] = depth;
139 std::vector<TKeyFrameID> & v = children_by_depth[depth];
140 v.push_back(it->first);
145 std::map<TKeyFrameID, mrpt::math::TPoint3Df> node_coords;
147 for (
size_t d=0;d<=max_depth;d++)
149 const float y = -(d*ROW_HEIGHT);
151 std::vector<TKeyFrameID> & v = children_by_depth[d];
152 const float row_width = v.size()*COL_WIDTH;
154 for (
size_t i=0;i<v.size();i++)
156 const float x = - 0.5f*row_width + COL_WIDTH*i;
163 gl_edges->setLineWidth(1.5);
165 out_root_tree->insert(gl_edges);
168 ASSERT_(it_edges_from_root != rba_state.spanning_tree.sym.all_edges.end())
170 const std::map<TKeyFrameID, typename rba_problem_state_t::k2k_edge_vector_t> edges_from_root = it_edges_from_root->second;
175 for (
size_t k=0;k<edges_to_j.size();k++)
180 gl_edges->appendLine(node_coords[id1], node_coords[id2]);
186 gl_aux_draw_node(*out_root_tree,
mrpt::format(
"%u", static_cast<unsigned int>(it->first) ), it->second.x, it->second.y);
193 template <
class KF2KF_POSE_TYPE,
class LM_TYPE,
class OBS_TYPE,
class RBA_OPTIONS>
198 obj->setDiskRadius(1,0);
200 obj->setLocation(x,y,0);
206 obj->setFont(
"sans");
209 obj->setLocation(x-0.5,y-0.5,0);
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
A set of object, which are referenced to the coordinates framework established in this object...
kf2kf_pose_traits< KF2KF_POSE_TYPE >::k2k_edge_vector_t k2k_edge_vector_t
const Scalar * const_iterator
Keyframe-to-keyframe edge: an unknown of the problem.
uint64_t topo_dist_t
Unsigned integral type for topological distances in a graph/tree.
static CSetOfLinesPtr Create()
Lightweight 3D point (float version).
static CText3DPtr Create()
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CSetOfObjectsPtr OPENGL_IMPEXP CornerXYZSimple(float scale=1.0, float lineWidth=1.0)
Returns three arrows representing a X,Y,Z 3D corner (just thick lines instead of complex arrows for f...
size_t span_tree_max_depth
Maximum spanning tree depth for reconstructing relative poses (default=-1 : infinity) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
kf2kf_pose_traits_t::frameid2pose_map_t frameid2pose_map_t
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void insert(const CRenderizablePtr &newObject)
Insert a new object to the list.
void build_opengl_representation(const srba::TKeyFrameID root_keyframe, const TOpenGLRepresentationOptions &options, mrpt::opengl::CSetOfObjectsPtr out_scene, mrpt::opengl::CSetOfObjectsPtr out_root_tree=mrpt::opengl::CSetOfObjectsPtr()) const
Build an opengl representation of the current state of this RBA problem One of different representati...
void gl_aux_draw_node(mrpt::opengl::CSetOfObjects &soo, const std::string &label, const float x, const float y) const
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
uint64_t TKeyFrameID
Numeric IDs for key-frames (KFs)