9 #ifndef CVISUALIZER_IMPL_H
10 #define CVISUALIZER_IMPL_H
20 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
21 class EDGE_ANNOTATIONS>
22 CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
30 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
31 class EDGE_ANNOTATIONS>
32 CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
33 EDGE_ANNOTATIONS>::~CVisualizer()
39 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
40 class EDGE_ANNOTATIONS>
41 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
51 const bool show_ID_labels =
53 const bool show_ground_grid =
56 const bool show_node_corners =
58 const bool show_edge_rel_poses =
60 const double nodes_point_size =
65 this->drawGroundGrid(
object, &viz_params);
68 if (nodes_point_size > 0)
70 this->drawNodePoints(
object, &viz_params);
73 if (show_node_corners || show_ID_labels)
75 this->drawNodeCorners(
object, &viz_params);
78 if (show_edge_rel_poses)
80 this->drawEdgeRelPoses(
object, &viz_params);
85 this->drawEdges(
object, &viz_params);
89 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
90 class EDGE_ANNOTATIONS>
91 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
99 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
105 m_graph.nodes.begin();
106 n_it != m_graph.nodes.end(); ++n_it)
121 const double grid_frequency = 5.0;
123 BB_min.x, BB_max.
x, BB_min.y, BB_max.
y, BB_min.z, grid_frequency);
124 grid->setColor(0.3, 0.3, 0.3);
125 object->insert(grid);
128 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
129 class EDGE_ANNOTATIONS>
130 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
136 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
141 const double nodes_point_size =
144 "nodes_point_color", (
unsigned int)0xA0A0A0);
148 pnts->setPointSize(nodes_point_size);
152 m_graph.nodes.begin();
153 n_it != m_graph.nodes.end(); ++n_it)
157 pnts->insertPoint(
p.x(),
p.y(),
p.z());
160 pnts->enablePointSmooth();
161 object->insert(pnts);
164 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
165 class EDGE_ANNOTATIONS>
166 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
176 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
178 const bool show_node_corners =
180 const bool show_ID_labels =
182 const double nodes_corner_scale =
186 m_graph.nodes.begin();
187 n_it != m_graph.nodes.end(); ++n_it)
195 nodes_corner_scale, 1.0 )
197 nodes_corner_scale, 1.0 ))
198 : mrpt::make_aligned_shared<CSetOfObjects>();
199 gl_corner->setPose(
p);
203 format(
"%u",
static_cast<unsigned int>(n_it->first)));
204 gl_corner->enableShowName();
206 object->insert(gl_corner);
210 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
211 class EDGE_ANNOTATIONS>
212 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
220 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
222 const double nodes_edges_corner_scale =
225 "edge_rel_poses_color", (
unsigned int)0x40FF8000);
227 edge_rel_poses_color & 0xffffff, edge_rel_poses_color >> 24);
231 edge_it != m_graph.end(); ++edge_it)
234 const TNodeID node_id_start = m_graph.edges_store_inverse_poses
235 ? edge_it->first.second
236 : edge_it->first.first;
240 m_graph.nodes.find(node_id_start);
241 if (n_it != m_graph.nodes.end())
247 mrpt::make_aligned_shared<mrpt::opengl::CSetOfObjects>();
248 gl_rel_edge->setPose(pSource);
251 edge_it->second.getPoseMean();
258 nodes_edges_corner_scale, 1.0 )
260 nodes_edges_corner_scale, 1.0 ));
262 gl_edge_corner->setPose(edge_pose);
263 gl_rel_edge->insert(gl_edge_corner);
267 0, 0, 0, edge_pose_pt.
x(), edge_pose_pt.
y(),
270 gl_line->setColor_u8(col8bit);
271 gl_line->setLineWidth(edge_width);
272 gl_rel_edge->insert(gl_line);
274 object->insert(gl_rel_edge);
279 template <
class CPOSE,
class MAPS_IMPLEMENTATION,
class NODE_ANNOTATIONS,
280 class EDGE_ANNOTATIONS>
281 void CVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS,
289 ASSERTMSG_(viz_params,
"Pointer to viz_params was not provided.");
292 const unsigned int edge_color =
296 const TColor col8bit(edge_color & 0xffffff, edge_color >> 24);
298 gl_edges->setColor_u8(col8bit);
299 gl_edges->setLineWidth(edge_width);
303 edge_it != m_graph.end(); ++edge_it)
305 const TNodeID id1 = edge_it->first.first;
306 const TNodeID id2 = edge_it->first.second;
310 m_graph.nodes.find(id1);
312 m_graph.nodes.find(id2);
313 if (n_it1 != m_graph.nodes.end() && n_it2 != m_graph.nodes.end())
317 gl_edges->appendLine(
322 object->insert(gl_edges);
edges_map_t::const_iterator const_iterator
A directed graph of pose constraints, with edges being the relative poses between pairs of nodes iden...
CPOSE::type_value constraint_no_pdf_t
The type of edges or their means if they are PDFs (that is, a simple "edge" value)
CPOSE constraint_t
The type of PDF poses in the contraints (edges) (=CPOSE template argument)
Base class for C*Visualizer classes.
static Ptr Create(Args &&... args)
std::shared_ptr< CGridPlaneXY > Ptr
std::shared_ptr< CPointCloud > Ptr
std::shared_ptr< CSetOfLines > Ptr
std::shared_ptr< CSetOfObjects > Ptr
std::shared_ptr< CSimpleLine > Ptr
static Ptr Create(Args &&... args)
A class used to store a 3D point.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double x() const
Common members of all points & poses classes.
uint64_t TNodeID
The type for node IDs in graphs of different types.
#define ASSERTMSG_(f, __ERROR_MSG)
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).
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...
The namespace for 3D scene representation and rendering.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
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.
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double x
X,Y,Z coordinates.
A RGB color - floats in the range [0,1].
T getWithDefaultVal(const std::string &s, const T &defaultVal) const
A const version of the [] operator and with a default value in case the parameter is not set (for usa...