24 #include <pcl/io/pcd_io.h> 25 #include <pcl/common/time.h> 34 PbMapLocaliser::PbMapLocaliser(
PbMap &mPbM,
const string &config_file) :
36 m_pbMapLocaliser_must_stop(false),
37 m_pbMapLocaliser_finished(false)
51 cout <<
"PbMapLocaliser::LoadPreviousPbMaps(...)\n";
52 std::ifstream configFile;
53 configFile.open(fileMaps.c_str());
56 string mapFile, filepath =
"/home/edu/newPbMaps/";
58 while( !configFile.eof() )
61 getline(configFile, mapFile);
65 if(mapFile.at(0) ==
'%')
67 cout <<
"Load map: " << filepath << mapFile << endl;
70 previousPbMap.
loadPbMap(filepath + mapFile);
88 cout <<
"PbMapLocaliser:: previous PbMaps loaded\n";
94 cout <<
"PbMapLocaliser::compareSubgraphNeighbors\n";
153 cout <<
"getAreaMatch " << area << endl;
166 cout <<
"\nSearching plane P" << searchPlane.
id <<
" numNeigs " << searchPlane.
neighborPlanes.size()
178 for(
size_t i=0; i < prevPbMap.
vPlanes.size(); i++)
195 Subgraph targetSubgraph(&prevPbMap, targetPlane.
id);
203 if( resultingMatch.size() >
bestMatch.size())
227 cout <<
"Context matched\n";
239 pcl::PointXYZ placePos(0,0,0);
249 cout <<
"Re-assign plane label\n";
262 cout <<
"Assign plane label\n";
298 Eigen::Matrix4f rigidTransf;
299 Eigen::Matrix4f rigidTransfInv;
302 rigidTransfInv =
inverse(rigidTransf);
305 pcl::PCDReader reader;
306 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
model (
new pcl::PointCloud<pcl::PointXYZRGBA>);
308 reader.read (filename, *
model);
322 bool placeFound =
false;
324 std::map<unsigned,vector<double> > timeLocalizer;
325 std::map<unsigned,vector<int> > nCheckLocalizer;
363 double search_plane_start = pcl::getTime ();
370 double search_plane_end = pcl::getTime ();
371 std::cout <<
"PLACE FOUND. Search took " << double (search_plane_end - search_plane_start) <<
" s\n";
379 double search_plane_end = pcl::getTime ();
387 vector<double> firstElement(1,
double(search_plane_end - search_plane_start));
394 double search_plane_end = pcl::getTime ();
395 std::cout <<
"Search a plane took " << double (search_plane_end - search_plane_start) << std::endl;
402 cout <<
"Print TIME PbLocalizer\n";
403 cout <<
"Tiempo1 " <<
time1 <<
" tiempo2 " <<
time2 << endl;;
404 std::map<unsigned,vector<int> >
::iterator itChecks = nCheckLocalizer.begin();
405 for(std::map<
unsigned,vector<double> >::
iterator it=timeLocalizer.begin(); it != timeLocalizer.end(); it++)
407 double sum_times = 0;
408 double sum_nChecks = 0;
409 for(
unsigned j=0; j < it->second.size(); j++)
411 sum_times += it->second[j];
412 sum_nChecks += itChecks->second[j];
416 cout <<
"Size " << it->first <<
" time " << sum_times/it->second.size() << endl;
417 cout <<
"... nChecks " << sum_nChecks/it->second.size() << endl;
427 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::map< std::string, pcl::PointXYZ > foundPlaces
unsigned min_planes_recognition
A class used to store a planar feature (Plane for short).
std::map< std::string, std::pair< int, double > > planeRecognitionLUT
float intensity_threshold
bool m_pbMapLocaliser_must_stop
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr alignedModelPtr
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
std::set< unsigned > nearbyPlanes
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
void clear()
Mark the handle as invalid.
GLsizei const GLchar ** string
std::map< unsigned, unsigned > neighborPlanes
bool stop_pbMapLocaliser()
std::vector< unsigned > vQueueObservedPlanes
void BASE_IMPEXP joinThread(TThreadHandle &threadHandle)
Waits until the given thread ends.
std::map< unsigned, unsigned > bestMatch
TThreadHandle createThreadFromObjectMethod(CLASS *obj, void(CLASS::*func)(PARAM), PARAM param)
Creates a new thread running a non-static method (so it will have access to "this") from another meth...
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
mrpt::system::TThreadHandle pbMapLocaliser_hd
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).
Eigen::Matrix4f getRTwithModel(std::map< unsigned, unsigned > &matched_planes)