23 #include <pcl/io/pcd_io.h> 24 #include <pcl/common/time.h> 33 PbMapLocaliser::PbMapLocaliser(
PbMap& mPbM,
const string& config_file)
35 m_pbMapLocaliser_must_stop(false),
36 m_pbMapLocaliser_finished(false)
39 std::cout <<
"PbMapLocaliser::PbMapLocaliser min_planes_recognition " 53 cout <<
"PbMapLocaliser::LoadPreviousPbMaps(...)\n";
54 std::ifstream configFile;
55 configFile.open(fileMaps.c_str());
57 string mapFile, filepath =
"/home/edu/newPbMaps/";
59 while (!configFile.eof())
62 getline(configFile, mapFile);
63 if (mapFile ==
"")
break;
65 if (mapFile.at(0) ==
'%')
continue;
66 cout <<
"Load map: " << filepath << mapFile << endl;
69 previousPbMap.
loadPbMap(filepath + mapFile);
88 cout <<
"PbMapLocaliser:: previous PbMaps loaded\n";
94 cout <<
"PbMapLocaliser::compareSubgraphNeighbors\n";
113 matchedPbMap.
vPlanes[it->second].nearbyPlanes.begin();
114 it2 != matchedPbMap.
vPlanes[it->second].nearbyPlanes.end();
122 matchedPbMap,
false))
128 it_matched !=
bestMatch.end(); it_matched++)
133 matchedPbMap.
vPlanes[it_matched->second]))
144 it1 !=
mPbMap.
vPlanes[it->first].neighborPlanes.end(); it1++)
150 matchedPbMap.
vPlanes[it->second]
151 .neighborPlanes.begin();
153 matchedPbMap.
vPlanes[it->second].neighborPlanes.end();
162 matchedPbMap.
vPlanes[it2->first], matchedPbMap,
168 it_matched !=
bestMatch.end(); it_matched++)
172 matchedPbMap.
vPlanes[it2->first],
173 matchedPbMap.
vPlanes[it_matched->second]))
191 cout <<
"getAreaMatch " << area << endl;
204 cout <<
"\nSearching plane P" << searchPlane.
id <<
" numNeigs " 218 for (
size_t i = 0; i < prevPbMap.
vPlanes.size(); i++)
241 Subgraph targetSubgraph(&prevPbMap, targetPlane.
id);
248 std::map<unsigned, unsigned> resultingMatch =
253 if (resultingMatch.size() >
bestMatch.size())
271 cout <<
"bestMatch size " <<
bestMatch.size() <<
" min " 280 cout <<
"Context matched\n";
291 pcl::PointXYZ placePos(0, 0, 0);
296 winnerPbMap.
vPlanes[it->second].label)
302 winnerPbMap.
vPlanes[it->second].label))
304 cout <<
"Re-assign plane label\n";
312 [winnerPbMap.
vPlanes[it->second].label]
316 winnerPbMap.
vPlanes[it->second].label;
328 cout <<
"Assign plane label\n";
335 winnerPbMap.
vPlanes[it->second].label;
372 Eigen::Matrix4f rigidTransf;
373 Eigen::Matrix4f rigidTransfInv;
376 rigidTransfInv =
inverse(rigidTransf);
379 pcl::PCDReader reader;
380 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
model(
381 new pcl::PointCloud<pcl::PointXYZRGBA>);
382 string filename =
"/home/edu/Projects/PbMaps/" +
384 reader.read(filename, *
model);
399 bool placeFound =
false;
401 std::map<unsigned, vector<double>> timeLocalizer;
402 std::map<unsigned, vector<int>> nCheckLocalizer;
410 std::this_thread::sleep_for(50ms);
425 .nearbyPlanes.size() <
439 .neighborPlanes.size() <
451 double search_plane_start = pcl::getTime();
458 double search_plane_end = pcl::getTime();
459 std::cout <<
"PLACE FOUND. Search took " 460 << double(search_plane_end - search_plane_start)
469 double search_plane_end = pcl::getTime();
470 if (timeLocalizer.count(
472 .neighborPlanes.size()) == 0)
475 .neighborPlanes.size()]
477 double(search_plane_end - search_plane_start));
479 .neighborPlanes.size()]
484 vector<double> firstElement(
485 1,
double(search_plane_end - search_plane_start));
488 .neighborPlanes.size()] = firstElement;
490 .neighborPlanes.size()] = firstElement_;
494 double search_plane_end = pcl::getTime();
496 <<
"Search a plane took " 497 << double(search_plane_end - search_plane_start)
505 cout <<
"Print TIME PbLocalizer\n";
506 cout <<
"Tiempo1 " <<
time1 <<
" tiempo2 " <<
time2 << endl;
508 std::map<unsigned, vector<int>>
::iterator itChecks =
509 nCheckLocalizer.begin();
510 for (std::map<
unsigned, vector<double>>::
iterator it =
511 timeLocalizer.begin();
512 it != timeLocalizer.end(); it++)
514 double sum_times = 0;
515 double sum_nChecks = 0;
516 for (
unsigned j = 0; j < it->second.size(); j++)
518 sum_times += it->second[j];
519 sum_nChecks += itChecks->second[j];
523 cout <<
"Size " << it->first <<
" time " 524 << sum_times / it->second.size() << endl;
525 cout <<
"... nChecks " << sum_nChecks / it->second.size() << endl;
533 cout <<
"Waiting for PbMapLocaliser thread to die.." << endl;
void loadPbMap(std::string PbMapFile)
void load_params(const std::string &config_file_name)
std::vector< std::string > previousPbMapNames
std::thread pbMapLocaliser_hd
std::map< std::string, pcl::PointXYZ > foundPlaces
unsigned min_planes_recognition
A class used to store a planar feature (Plane for short).
float intensity_threshold
std::map< unsigned, unsigned > neighborPlanes
bool m_pbMapLocaliser_must_stop
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr alignedModelPtr
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
std::set< unsigned > nearbyPlanes
GLsizei const GLchar ** string
bool stop_pbMapLocaliser()
std::vector< unsigned > vQueueObservedPlanes
std::map< unsigned, unsigned > bestMatch
bool searchPlaneContext(Plane &searchPlane)
! Searches the input plane in the rest of planes of the map taking into account the neighboring relat...
bool m_pbMapLocaliser_finished
void compareSubgraphNeighbors(SubgraphMatcher &matcher)
config_heuristics configLocaliser
std::map< unsigned, unsigned > compareSubgraphs(Subgraph &subgraphSource, Subgraph &subgraphTarget, const int option=0)
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
bool evalUnaryConstraints(Plane &plane1, Plane &plane2, PbMap &trgPbMap, bool useStructure=false)
! Check if the two input planes could be the same
bool evalBinaryConstraints(Plane &plane1, Plane &plane2, Plane &planeA, Plane &planeB)
! Compares the relation between Ref-neigRef with the relation between Check-neigCheck.
void LoadPreviousPbMaps(std::string fileMaps)
std::set< unsigned > subgraphPlanesIdx
std::vector< Plane > vPlanes
std::vector< PbMap > previousPbMaps
A class used to store a Plane-based Map (PbMap).
std::map< std::string, std::pair< int, double > > planeRecognitionLUT
*PbMapLocaliser y montarlo en un define *size_t totalPrevPlanes
Eigen::Matrix4f getRTwithModel(std::map< unsigned, unsigned > &matched_planes)