10 #ifndef CICPCRITERIAERD_IMPL_H 11 #define CICPCRITERIAERD_IMPL_H 22 template <
class GRAPH_T>
25 m_search_disk_color(142, 142, 56),
26 m_laser_scans_color(0, 20, 255),
27 m_is_using_3DScan(false)
41 this->logFmt(LVL_DEBUG,
"Initialized class object");
45 template <
class GRAPH_T>
53 template <
class GRAPH_T>
65 bool registered_new_node =
false;
67 if (this->m_last_total_num_nodes < this->
m_graph->nodeCount())
69 registered_new_node =
true;
71 this->logFmt(LVL_DEBUG,
"New node has been registered!");
103 if (registered_new_node)
110 LVL_DEBUG,
"Added laser scans of nodeID: %lu",
111 this->
m_graph->nodeCount() - 1);
118 LVL_DEBUG,
"Added laser scans of nodeID: %lu",
119 this->
m_graph->nodeCount() - 1);
136 if (registered_new_node)
139 std::set<mrpt::utils::TNodeID> nodes_to_check_ICP;
141 &nodes_to_check_ICP, this->
m_graph->nodeCount() - 1,
144 LVL_DEBUG,
"Found * %lu * nodes close to nodeID %lu",
145 nodes_to_check_ICP.size(), this->
m_graph->nodeCount() - 1);
149 registered_new_node =
false;
165 template <
class GRAPH_T>
167 const std::set<mrpt::utils::TNodeID>& nodes_set)
170 using namespace mrpt;
182 curr_laser_scan = search->second;
191 node_it != nodes_set.end(); ++node_it)
202 prev_laser_scan = search->second;
206 this->
m_graph->nodes[*node_it];
210 *prev_laser_scan, *curr_laser_scan, &rel_edge,
211 &initial_pose, &icp_info);
216 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" 219 "ICP constraint between NON-successive nodes: " 220 << *node_it <<
" => " << curr_nodeID << std::endl
222 <<
"\tgoodness = " << icp_info.
goodness);
224 "ICP_goodness_thresh: " <<
params.ICP_goodness_thresh);
226 "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" 235 if (
absDiff(curr_nodeID, *node_it) >
236 params.LC_min_nodeid_diff)
248 template <
class GRAPH_T>
250 const std::set<mrpt::utils::TNodeID>& nodes_set)
265 curr_laser_scan = search->second;
274 node_it != nodes_set.end(); ++node_it)
285 prev_laser_scan = search->second;
290 *prev_laser_scan, *curr_laser_scan, &rel_edge,
nullptr,
300 if (
absDiff(curr_nodeID, *node_it) >
301 params.LC_min_nodeid_diff)
314 template <
class GRAPH_T>
322 this->
m_graph->insertEdge(from, to, rel_edge);
325 template <
class GRAPH_T>
327 std::set<mrpt::utils::TNodeID>* nodes_set,
339 double curr_distance = this->
m_graph->nodes[nodeID].distanceTo(
340 this->
m_graph->nodes[cur_nodeID]);
343 nodes_set->insert(nodeID);
349 this->
m_graph->getAllNodes(*nodes_set);
355 template <
class GRAPH_T>
357 const std::map<std::string, bool>& events_occurred)
363 if (events_occurred.find(
params.keystroke_laser_scans)->second)
371 template <
class GRAPH_T>
380 this->logFmt(mrpt::utils::LVL_INFO,
"Toggling LaserScans visualization...");
384 if (
params.visualize_laser_scans)
387 obj->setVisibility(!
obj->isVisible());
400 template <
class GRAPH_T>
402 std::map<std::string, int>* edge_types_to_num)
const 411 template <
class GRAPH_T>
416 this->logFmt(mrpt::utils::LVL_DEBUG,
"Initializing visuals");
421 params.has_read_config,
"Configuration parameters aren't loaded yet");
424 params.keystroke_laser_scans,
"Toggle LaserScans Visualization");
427 if (
params.ICP_max_distance > 0)
433 obj->setPose(initial_pose);
434 obj->setName(
"ICP_max_distance");
437 params.ICP_max_distance,
params.ICP_max_distance - 0.1);
445 if (
params.visualize_laser_scans)
450 mrpt::make_aligned_shared<mrpt::opengl::CPlanarLaserScan>();
451 laser_scan_viz->enablePoints(
true);
452 laser_scan_viz->enableLine(
true);
453 laser_scan_viz->enableSurface(
true);
454 laser_scan_viz->setSurfaceColor(
458 laser_scan_viz->setName(
"laser_scan_viz");
460 scene->insert(laser_scan_viz);
480 template <
class GRAPH_T>
499 disk_obj->
setPose(this->
m_graph->nodes[this->m_graph->nodeCount() - 1]);
528 if (search != this->
m_graph->nodes.end())
530 laser_scan_viz->setPose(
531 this->
m_graph->nodes[this->m_graph->nodeCount() - 1]);
534 laser_scan_viz->setPose(
536 laser_scan_viz->getPoseX(), laser_scan_viz->getPoseY(),
537 -0.15,
DEG2RAD(laser_scan_viz->getPoseYaw()),
538 DEG2RAD(laser_scan_viz->getPosePitch()),
539 DEG2RAD(laser_scan_viz->getPoseRoll())));
550 template <
class GRAPH_T>
556 using namespace mrpt;
560 "Cannot toggle visibility of specified object.\n " 561 "Make sure that the corresponding visualization flag ( %s " 562 ") is set to true in the .ini file.\n",
564 std::this_thread::sleep_for(std::chrono::milliseconds(sleep_time));
569 template <
class GRAPH_T>
576 params.loadFromConfigFileName(
577 source_fname,
"EdgeRegistrationDeciderParameters");
578 this->logFmt(LVL_DEBUG,
"Successfully loaded parameters. ");
582 int min_verbosity_level =
source.read_int(
583 "EdgeRegistrationDeciderParameters",
"class_verbosity", 1,
false);
584 this->setMinLoggingLevel(VerbosityLevel(min_verbosity_level));
588 template <
class GRAPH_T>
598 template <
class GRAPH_T>
609 stringstream class_props_ss;
610 class_props_ss <<
"ICP Goodness-based Registration Procedure Summary: " 616 const std::string output_res = this->getLogAsString();
622 *report_str += class_props_ss.str();
625 *report_str += time_res;
628 *report_str += output_res;
637 template <
class GRAPH_T>
639 : decider(d), keystroke_laser_scans(
"l"), has_read_config(false)
643 template <
class GRAPH_T>
648 template <
class GRAPH_T>
655 "------------------[ Goodness-based ICP Edge Registration " 656 "]------------------\n");
658 "ICP goodness threshold = %.2f%% \n",
659 ICP_goodness_thresh * 100);
660 out.
printf(
"ICP max radius for edge search = %.2f\n", ICP_max_distance);
661 out.
printf(
"Min. node difference for LC = %lu\n", LC_min_nodeid_diff);
662 out.
printf(
"Visualize laser scans = %d\n", visualize_laser_scans);
664 "3DScans Image Directory = %s\n",
665 scans_img_external_dir.c_str());
669 template <
class GRAPH_T>
675 LC_min_nodeid_diff =
source.read_int(
676 "GeneralConfiguration",
"LC_min_nodeid_diff", 30,
false);
678 source.read_double(section,
"ICP_max_distance", 10,
false);
679 ICP_goodness_thresh =
680 source.read_double(section,
"ICP_goodness_thresh", 0.75,
false);
681 visualize_laser_scans =
source.read_bool(
682 "VisualizationParameters",
"visualize_laser_scans",
true,
false);
683 scans_img_external_dir =
source.read_string(
684 section,
"scan_images_external_directory",
"./",
false);
686 has_read_config =
true;
virtual void notifyOfWindowEvents(const std::map< std::string, bool > &events_occurred)
Get a list of the window events that happened since the last call.
virtual void loadParams(const std::string &source_fname)
Fetch the latest observation that the current instance received (most probably during a call to the u...
void unlockAccess3DScene()
Unlocks the access to the internal 3D scene.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
ICP-based Edge Registration.
mrpt::gui::CDisplayWindow3D * m_win
Window to use.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void notifyOfWindowEvents(const std::map< std::string, bool > &events_occurred)
Get a list of the window events that happened since the last call.
virtual void printParams() const
Print the problem parameters - relevant to the decider/optimizer to the screen in a unified/compact w...
mrpt::opengl::COpenGLScene::Ptr & get3DSceneAndLock()
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introductio...
void dumpVisibilityErrorMsg(std::string viz_flag, int sleep_time=500)
This class allows loading and storing values and vectors of different types from ".ini" files easily.
void getICPEdge(const mrpt::obs::CObservation2DRangeScan &from, const mrpt::obs::CObservation2DRangeScan &to, constraint_t *rel_edge, const mrpt::poses::CPose2D *initial_pose=nullptr, mrpt::slam::CICP::TReturnInfo *icp_info=nullptr)
Align the 2D range scans provided and fill the potential edge that can transform the one into the oth...
void checkRegistrationCondition2D(const std::set< mrpt::utils::TNodeID > &nodes_set)
static const std::string header_sep
Separator string to be used in debugging messages.
GRAPH_T::constraint_t constraint_t
Handy typedefs.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
std::shared_ptr< CObservation3DRangeScan > Ptr
bool updateState(mrpt::obs::CActionCollection::Ptr action, mrpt::obs::CSensoryFrame::Ptr observations, mrpt::obs::CObservation::Ptr observation)
Generic method for fetching the incremental action/observation readings from the calling function...
std::shared_ptr< CRenderizable > Ptr
mrpt::graphslam::CWindowObserver * m_win_observer
CWindowObserver object for monitoring various visual-oriented events.
size_t m_last_total_num_nodes
Keep track of the total number of registered nodes since the last time class method was called...
const Scalar * const_iterator
mrpt::obs::CObservation2DRangeScan::Ptr m_last_laser_scan2D
mrpt::utils::TColor m_search_disk_color
see Constructor for initialization
void registerKeystroke(const std::string key_str, const std::string key_desc)
Make new keystrokes available in the help message box.
void addTextMessage(const double x, const double y, const std::string &text, const mrpt::utils::TColorf &color=mrpt::utils::TColorf(1.0, 1.0, 1.0), const size_t unique_index=0)
Wrapper around the CDisplayWindow3D::addTextMessage method, so that the user does not have to specify...
std::shared_ptr< CObservation2DRangeScan > Ptr
mrpt::obs::CObservation3DRangeScan::Ptr m_last_laser_scan3D
GLsizei GLsizei GLuint * obj
void toggleLaserScansVisualization()
togle the LaserScans visualization on and off
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::graphslam::CWindowManager * m_win_manager
Pointer to the CWindowManager object used to store visuals-related instances.
float goodness
A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
int m_text_index_search_disk
std::map< mrpt::utils::TNodeID, mrpt::obs::CObservation2DRangeScan::Ptr > m_nodes_to_laser_scans2D
uint64_t TNodeID
The type for node IDs in graphs of different types.
virtual void initializeVisuals()
Initialize visual objects in CDisplayWindow (e.g.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
static const std::string report_sep
std::string getStatsAsText(const size_t column_width=80) const
Dump all stats to a multi-line text string.
A planar disk in the XY plane.
void getDescriptiveReport(std::string *report_str) const
Fill the provided string with a detailed report of the decider/optimizer state.
std::shared_ptr< CPlanarLaserScan > Ptr
virtual void registerNewEdge(const mrpt::utils::TNodeID &from, const mrpt::utils::TNodeID &to, const constraint_t &rel_edge)
Register a new constraint/edge in the current graph.
This namespace contains representation of robot actions and observations.
This object renders a 2D laser scan by means of three elements: the points, the line along end-points...
std::shared_ptr< CSensoryFrame > Ptr
double m_offset_y_search_disk
uint64_t TNodeID
The type for node IDs in graphs of different types.
virtual void initializeLoggers(const std::string &name)
Initialize the COutputLogger, CTimeLogger instances given the name of the decider/optimizer at hand...
std::shared_ptr< CObservation > Ptr
GRAPH_T * m_graph
Pointer to the graph that is under construction.
unsigned short nIterations
The number of executed iterations until convergence.
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void dumpToTextStream(mrpt::utils::CStream &out) const
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
mrpt::utils::TColor m_laser_scans_color
see Constructor for initialization
std::map< std::string, int > m_edge_types_to_nums
void forceRepaint()
Repaints the window.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void registerNewEdge(const mrpt::utils::TNodeID &from, const mrpt::utils::TNodeID &to, const constraint_t &rel_edge)
Register a new constraint/edge in the current graph.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion)
This method load the options from a ".ini"-like file or memory-stored string list.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
std::shared_ptr< CActionCollection > Ptr
mrpt::utils::CTimeLogger m_time_logger
Time logger instance.
virtual void getDescriptiveReport(std::string *report_str) const
Fill the provided string with a detailed report of the decider/optimizer state.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
bool convert3DTo2DRangeScan(mrpt::obs::CObservation3DRangeScan::Ptr &scan3D_in, mrpt::obs::CObservation2DRangeScan::Ptr *scan2D_out=nullptr)
Wrapper around the CObservation3DRangeScan::convertTo2DScan corresponding method. ...
virtual void updateVisuals()
Update the relevant visual features in CDisplayWindow.
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
std::shared_ptr< COpenGLScene > Ptr
The ICP algorithm return information.
The namespace for 3D scene representation and rendering.
void printParams() const
Print the problem parameters - relevant to the decider/optimizer to the screen in a unified/compact w...
GLsizei GLsizei GLchar * source
A RGB color - floats in the range [0,1].
double leave(const char *func_name)
End of a named section.
void getNearbyNodesOf(std::set< mrpt::utils::TNodeID > *nodes_set, const mrpt::utils::TNodeID &cur_nodeID, double distance)
Get a list of the nodeIDs whose position is within a certain distance to the specified nodeID...
mrpt::obs::CObservation2DRangeScan::Ptr m_fake_laser_scan2D
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
T absDiff(const T &lhs, const T &rhs)
Absolute difference between two numbers.
GRAPH_T::constraint_t::type_value pose_t
type of underlying poses (2D/3D).
std::shared_ptr< CDisk > Ptr
void updateVisuals()
Update the relevant visual features in CDisplayWindow.
void getEdgesStats(std::map< std::string, int > *edge_types_to_num) const
Fill the given map with the type of registered edges as well as the corresponding number of registrat...
std::map< mrpt::utils::TNodeID, mrpt::obs::CObservation3DRangeScan::Ptr > m_nodes_to_laser_scans3D
void enter(const char *func_name)
Start of a named section.
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
#define ASSERTMSG_(f, __ERROR_MSG)
GLenum const GLfloat * params
void setScan(const mrpt::obs::CObservation2DRangeScan &scan)
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
void loadParams(const std::string &source_fname)
Fetch the latest observation that the current instance received (most probably during a call to the u...
void assignTextMessageParameters(double *offset_y, int *text_index)
Assign the next available offset_y and text_index for the textMessage under construction.
void initializeVisuals()
Initialize visual objects in CDisplayWindow (e.g.
void checkRegistrationCondition3D(const std::set< mrpt::utils::TNodeID > &nodes_set)