22 template <
class GRAPH_T>
32 using constraint_t =
typename GRAPH_T::constraint_t;
34 const bool is_3D_graph = constraint_t::is_3D();
40 const bool show_ID_labels =
42 const bool show_ground_grid =
44 const bool show_edges =
46 const bool show_node_corners =
48 const bool show_edge_rel_poses =
50 const double nodes_point_size =
52 const double nodes_corner_scale =
54 const double nodes_edges_corner_scale =
57 "nodes_point_color", (
unsigned int)0xA0A0A0);
58 const unsigned int edge_color =
61 "edge_rel_poses_color", (
unsigned int)0x40FF8000);
69 for (
auto itNod =
g.nodes.begin(); itNod !=
g.nodes.end(); ++itNod)
71 const CPose3D
p = CPose3D(
84 const double grid_frequency = 5.0;
86 BB_min.x, BB_max.
x, BB_min.y, BB_max.
y, BB_min.z, grid_frequency);
87 grid->setColor(0.3, 0.3, 0.3);
92 if (nodes_point_size > 0)
97 pnts->setPointSize(nodes_point_size);
100 for (
auto itNod =
g.nodes.begin(); itNod !=
g.nodes.end(); ++itNod)
102 const CPose3D
p = CPose3D(
104 pnts->insertPoint(
p.x(),
p.y(),
p.z());
107 pnts->enablePointSmooth();
113 if (show_node_corners || show_ID_labels)
115 for (
auto itNod =
g.nodes.begin(); itNod !=
g.nodes.end(); ++itNod)
117 const CPose3D
p = CPose3D(
123 nodes_corner_scale, 1.0 )
125 nodes_corner_scale, 1.0 ))
126 : std::make_shared<CSetOfObjects>();
127 gl_corner->setPose(
p);
131 format(
"%u", static_cast<unsigned int>(itNod->first)));
132 gl_corner->enableShowName();
134 ret->insert(gl_corner);
138 if (show_edge_rel_poses)
141 edge_rel_poses_color & 0xffffff, edge_rel_poses_color >> 24);
143 for (
const auto& edge :
g)
146 const auto node_id_start =
g.edges_store_inverse_poses
151 auto itNod =
g.nodes.find(node_id_start);
152 if (itNod !=
g.nodes.end())
154 const CPose3D pSource = CPose3D(itNod->second);
158 gl_rel_edge->setPose(pSource);
160 const auto& edge_pose = edge.second.getPoseMean();
163 auto gl_edge_corner =
166 nodes_edges_corner_scale, 1.0 )
168 nodes_edges_corner_scale, 1.0 ));
170 gl_edge_corner->setPose(edge_pose);
171 gl_rel_edge->insert(gl_edge_corner);
174 0, 0, 0, edge_pose_pt.x(), edge_pose_pt.y(),
176 gl_line->setColor_u8(col8bit);
177 gl_line->setLineWidth(edge_width);
178 gl_rel_edge->insert(gl_line);
180 ret->insert(gl_rel_edge);
189 edge_color & 0xffffff, edge_color >> 24);
191 gl_edges->setColor_u8(col8bit);
192 gl_edges->setLineWidth(edge_width);
194 for (
const auto& edge :
g)
196 const auto id1 = edge.first.first;
197 const auto id2 = edge.first.second;
200 auto itNod1 =
g.nodes.find(id1);
201 auto itNod2 =
g.nodes.find(id2);
202 if (itNod1 !=
g.nodes.end() && itNod2 !=
g.nodes.end())
204 const CPose3D p1 = CPose3D(itNod1->second);
205 const CPose3D p2 = CPose3D(itNod2->second);
206 gl_edges->appendLine(
211 ret->insert(gl_edges);
double x
X,Y,Z coordinates.
#define MRPT_TRY_END
The end of a standard MRPT "try...catch()" block that allows tracing throw the call stack after an ex...
CSetOfObjects::Ptr CornerXYSimple(float scale=1.0, float lineWidth=1.0)
Returns two arrows representing a X,Y 2D corner (just thick lines, fast to render).
static Ptr Create(Args &&... args)
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
#define MRPT_TRY_START
The start of a standard MRPT "try...catch()" block that allows tracing throw the call stack after an ...
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...
A class used to store a 3D point.
RET getWithDefaultVal(const std::string &s, const RET &defaultVal) const
A const version of the [] operator and with a default value in case the parameter is not set (for usa...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CSetOfObjects::Ptr 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...
A RGB color - floats in the range [0,1].
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
CSetOfObjects::Ptr graph_visualize(const GRAPH_T &g, const mrpt::system::TParametersDouble &extra_params=mrpt::system::TParametersDouble())
Returns an opengl objects representation of an arbitrary graph, as a network of 3D pose frames...
static Ptr Create(Args &&... args)
static Ptr Create(Args &&... args)