From 66ce29a71fdd1b4b6e001e43939bd78891c6fc7a Mon Sep 17 00:00:00 2001 From: Sergi Pujol <sergi.pujol.badell@estudiantat.upc.edu> Date: Tue, 26 Jan 2021 16:03:12 +0100 Subject: [PATCH] corner_falko_class created. CMakelists updated --- src/CMakeLists.txt | 31 ++++++++++++++++ src/corner_falko_2d.cpp | 10 ++++++ src/corner_falko_2d.h | 58 ++++++++++++++++++++++++++++++ src/examples/CMakeLists.txt | 6 +++- src/examples/corner_falko_demo.cpp | 36 +++++++++++++++++++ 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/corner_falko_2d.cpp create mode 100644 src/corner_falko_2d.h create mode 100644 src/examples/corner_falko_demo.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a9977b..54c7fbd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,13 @@ ENDIF(faramotics_FOUND) FIND_PACKAGE(Eigen3 3.3 REQUIRED) FIND_PACKAGE(csm QUIET) +find_package(falkolib REQUIRED) +message(STATUS "falkolib_FOUND ${falkolib_FOUND}") +message(STATUS "falkolib_INCLUDE_DIRS ${falkolib_INCLUDE_DIRS}") +message(STATUS "falkolib_LIBRARY_DIRS ${falkolib_LIBRARY_DIRS}") +message(STATUS "falkolib_LIBRARIES ${falkolib_LIBRARIES}") + + #include directories INCLUDE_DIRECTORIES(. /usr/local/include) INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIRS}) @@ -23,6 +30,11 @@ IF(faramotics_FOUND) INCLUDE_DIRECTORIES(${faramotics_INCLUDE_DIRS}) ENDIF(faramotics_FOUND) +if(${falkolib_FOUND}) + include_directories(${falkolib_INCLUDE_DIRS}) + link_directories(${falkolib_LIBRARY_DIRS}) +endif() + #headers SET(HDRS_BASE laser_scan_utils.h) @@ -43,12 +55,18 @@ SET(HDRS point_set.h polyline.h scan_segment.h + corner_falko_2d.h ) IF(csm_FOUND) SET(HDRS ${HDRS} icp.h) ENDIF(csm_FOUND) + IF(falkolib_FOUND) + SET(HDRS ${HDRS} + corner_falko_2d.h) + ENDIF(falkolib_FOUND) + #sources SET(SRCS corner_finder.cpp @@ -71,6 +89,13 @@ SET(SRCS SET(SRCS ${SRCS} icp.cpp) ENDIF(csm_FOUND) + + IF(falkolib_FOUND) + SET(SRCS ${SRCS} + corner_falko_2d.cpp) + ENDIF(falkolib_FOUND) + + # create the shared library ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) @@ -78,6 +103,12 @@ IF(csm_FOUND) target_link_libraries(${PROJECT_NAME} ${csm_LIBRARY}) ENDIF(csm_FOUND) +IF(falkolib_FOUND) + target_link_libraries(${PROJECT_NAME} ${falkolib_LIBRARY}) +ENDIF(falkolib_FOUND) + + + # Examples IF(BUILD_DEMOS) MESSAGE("Building examples.") diff --git a/src/corner_falko_2d.cpp b/src/corner_falko_2d.cpp new file mode 100644 index 0000000..d0c8c90 --- /dev/null +++ b/src/corner_falko_2d.cpp @@ -0,0 +1,10 @@ +/** + * \file corner_falko_2d.cpp + * + * Created on: Jan 26, 2021 + * \author: spujol + */ + +#include "corner_falko_2d.h" + + diff --git a/src/corner_falko_2d.h b/src/corner_falko_2d.h new file mode 100644 index 0000000..476584a --- /dev/null +++ b/src/corner_falko_2d.h @@ -0,0 +1,58 @@ +/** + * \file corner_falko_2d.h + * + * Created on: Jan 26, 2021 + * \author: spujol + */ + +#ifndef CORNER_FALKO_2D_H_ +#define CORNER_FALKO_2D_H_ + +#include <iostream> +#include <fstream> + +/************************** + * WOLF includes * + **************************/ +//#include "core/landmark/landmark_base.h" + +/************************** + * Falko includes * + **************************/ +#include <falkolib/Feature/FALKO.h> +#include <falkolib/Feature/CGH.h> +#include <falkolib/Feature/BSC.h> +#include <falkolib/Feature/FALKOExtractor.h> + +#include <falkolib/Feature/BSCExtractor.h> +#include <falkolib/Feature/CGHExtractor.h> + +#include <falkolib/Matching/NNMatcher.h> +#include <falkolib/Matching/AHTMatcher.h> + + +namespace wolf +{ +class LandmarkCorner2d +{ +public: + std::vector<std::vector<falkolib::FALKO>> cornerSet; + std::vector<std::vector<falkolib::BSC>> descriptorSet; + + /** \brief Gets a set of landmarks/scenes to use as trained set. + **/ + void train(); + + /** \brief Extract landmark/scene (list of corners) from a given 2D scan + **/ + void extract(); + + /** \brief compare new scans against the training set in order to find loop closures + **/ + void findLoopClosure(); + +}; + +} /* namespace wolf */ + +#endif /* LANDMARK_POLYLINE_2d_H_ */ diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 005644f..86ea3bc 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -2,4 +2,8 @@ INCLUDE_DIRECTORIES(../src) # polylines demo ADD_EXECUTABLE(demo_polylines polyline_demo.cpp) -TARGET_LINK_LIBRARIES(demo_polylines ${PROJECT_NAME}) \ No newline at end of file +TARGET_LINK_LIBRARIES(demo_polylines ${PROJECT_NAME}) + +# falkocorners demo +ADD_EXECUTABLE(demo_corner_falko corner_falko_demo.cpp) +TARGET_LINK_LIBRARIES(demo_corner_falko ${PROJECT_NAME}) \ No newline at end of file diff --git a/src/examples/corner_falko_demo.cpp b/src/examples/corner_falko_demo.cpp new file mode 100644 index 0000000..b9a39af --- /dev/null +++ b/src/examples/corner_falko_demo.cpp @@ -0,0 +1,36 @@ +/** + * \file corner_falko_2d_test.cpp + * + * Created on: Jan 26, 2021 + * \author: spujol + */ + +//LaserScanUtils includes +#include "../line_finder_iterative.h" +#include "../corner_falko_2d.h" +#include "../laser_scan.h" + +//std includes +#include <ctime> +#include <iostream> +using namespace laserscanutils; + +int main(int argc, char** argv) +{ + LaserScanParams scan_params({-1.57079994678, 1.57079994678, 0.00875097513199, 0.0, 0.10000000149, 50.0, 0.1, 0.1}); + + std::vector<float> ranges({49.97591781616211, 49.996429443359375, 49.999759674072266, 50.0, 50.0, 50.0, 49.998634338378906, 50.0, 50.0, 49.99236297607422, 49.99384307861328, 50.0, 49.9869270324707, 50.0, 49.99005889892578, 49.99773406982422, 50.0, 49.98741912841797, 50.0, 49.99842071533203, 50.0, 49.99243927001953, 49.997291564941406, 50.0, 50.0, 49.98580551147461, 49.991844177246094, 49.98896026611328, 50.0, 50.0, 49.9897346496582, 49.998111724853516, 49.99882125854492, 50.0, 50.0, 50.0, 50.0, 49.999698638916016, 50.0, 50.0, 50.0, 50.0, 49.991397857666016, 49.99360275268555, 49.999027252197266, 49.99750900268555, 49.99100112915039, 49.998714447021484, 49.98794174194336, 50.0, 50.0, 50.0, 50.0, 50.0, 49.98186492919922, 50.0, 50.0, 50.0, 49.99155807495117, 49.997196197509766, 49.98872375488281, 49.99138259887695, 50.0, 49.99021530151367, 49.99164581298828, 50.0, 49.991390228271484, 50.0, 50.0, 50.0, 49.997249603271484, 50.0, 49.991851806640625, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 49.97983169555664, 49.98630142211914, 50.0, 20.6888370513916, 49.9797477722168, 49.98846435546875, 49.99418640136719, 50.0, 50.0, 50.0, 49.99342346191406, 50.0, 49.9906005859375, 50.0, 49.99853515625, 49.989444732666016, 38.552852630615234, 38.28703689575195, 38.04865264892578, 37.78112030029297, 37.54747772216797, 37.28171157836914, 37.206565856933594, 36.835411071777344, 36.61864471435547, 36.39655685424805, 36.1579475402832, 35.95964431762695, 35.75605773925781, 35.552188873291016, 35.75926208496094, 36.27781677246094, 35.16993713378906, 34.99699401855469, 34.82910919189453, 34.6483039855957, 34.48637390136719, 34.32539749145508, 34.16202163696289, 34.232051849365234, 33.86043167114258, 33.71691131591797, 33.566650390625, 33.42384338378906, 33.2882080078125, 33.16693115234375, 33.041419982910156, 32.906009674072266, 33.008323669433594, 33.706356048583984, 34.43825149536133, 35.25088119506836, 36.05652618408203, 36.930118560791016, 37.83384704589844, 33.12321472167969, 33.02351760864258, 32.9192008972168, 32.82925796508789, 32.74382781982422, 32.64959716796875, 32.580204010009766, 32.49120330810547, 33.05714797973633, 32.343536376953125, 32.26381301879883, 32.21063232421875, 32.12488555908203, 32.06965255737305, 32.0222282409668, 31.954957962036133, 31.903532028198242, 31.83578872680664, 32.51456832885742, 34.189456939697266, 31.12668228149414, 31.076339721679688, 31.047151565551758, 30.967018127441406, 30.956220626831055, 30.924589157104492, 30.893285751342773, 30.869199752807617, 30.843050003051758, 32.791847229003906, 30.809431076049805, 30.79128074645996, 30.779237747192383, 30.776460647583008, 30.74305534362793, 30.74994468688965, 30.7137393951416, 30.734609603881836, 30.719928741455078, 30.71673011779785, 49.99970626831055, 50.0, 49.987911224365234, 33.68583679199219, 31.76846694946289, 31.8026123046875, 31.802202224731445, 31.818490982055664, 31.85223960876465, 31.86141014099121, 31.906801223754883, 31.93423843383789, 31.964210510253906, 33.567230224609375, 32.055015563964844, 32.07001876831055, 32.13076400756836, 32.16000747680664, 32.22781753540039, 32.26890563964844, 32.323944091796875, 32.36326217651367, 32.430908203125, 49.980655670166016, 34.32135772705078, 33.09465789794922, 32.27247619628906, 32.33710479736328, 32.41763687133789, 32.498661041259766, 32.57213592529297, 32.67158126831055, 32.74591827392578, 32.814476013183594, 32.93477249145508, 33.04751968383789, 33.136863708496094, 33.23999786376953, 33.34675979614258, 33.42970657348633, 33.53573226928711, 33.66716003417969, 33.78378677368164, 33.905670166015625, 34.02836608886719, 34.151817321777344, 34.2794189453125, 34.41516876220703, 34.551273345947266, 34.702728271484375, 34.84151840209961, 34.986881256103516, 35.162757873535156, 35.332794189453125, 35.47941970825195, 35.65633010864258, 35.82624435424805, 36.00060272216797, 36.17729187011719, 36.36515808105469, 36.55763626098633, 36.744773864746094, 38.46407699584961, 37.869808197021484, 37.767921447753906, 37.958900451660156, 38.20857620239258, 38.38622283935547, 38.68323516845703, 38.871334075927734, 39.151519775390625, 39.377750396728516, 39.68268966674805, 39.89873123168945, 40.197330474853516, 40.47549819946289, 40.73743438720703, 41.04566955566406, 42.33650207519531, 41.92591094970703, 41.43912124633789, 41.045528411865234, 41.32114028930664, 41.581878662109375, 41.944580078125, 42.318912506103516, 42.6725959777832, 43.07264709472656, 43.443477630615234, 43.83216094970703, 44.19996643066406, 44.63225555419922, 45.06049346923828, 45.468536376953125, 45.89896774291992, 46.330604553222656, 46.778343200683594, 47.31666946411133, 47.789310455322266, 48.26376724243164, 48.826602935791016, 49.33188247680664, 49.990909576416016, 50.0, 50.0, 50.0, 50.0, 49.995697021484375, 49.99568176269531, 49.98163986206055, 50.0, 50.0, 49.9764289855957, 50.0, 50.0, 49.98639678955078, 49.99431228637695, 50.0, 50.0, 50.0, 50.0, 49.9874267578125, 50.0, 49.98714828491211, 50.0, 49.99470901489258, 49.99113464355469, 50.0, 50.0, 50.0, 49.985504150390625, 49.99067306518555, 50.0, 49.997161865234375, 50.0, 50.0, 50.0, 49.995513916015625, 49.993038177490234, 50.0, 49.99763107299805, 50.0, 49.98752975463867, 50.0, 49.988037109375, 50.0, 50.0, 50.0, 49.9975700378418, 50.0, 49.998756408691406, 49.97819519042969, 49.99104690551758, 49.99087905883789, 49.94268798828125, 49.85968017578125, 49.786617279052734, 49.70594787597656, 49.62562561035156, 49.56686782836914, 49.50475311279297, 49.416934967041016, 49.35699462890625, 49.308589935302734, 49.990482330322266, 50.0, 49.998836517333984, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 49.980472564697266, 49.99903869628906, 50.0, 50.0, 49.989845275878906, 49.98395919799805, 50.0, 49.99302673339844, 49.99530792236328, 49.99745559692383, 50.0, 49.99560546875, 21.569303512573242}); + LaserScan scan(ranges); + + std::cout << "scan created!" << std::endl; + + LineFinderIterative line_finder(LineFinderIterativeParams({1, 5, 1, 1})); + + std::cout << "line_finder created!" << std::endl; + + std::list<laserscanutils::Polyline> polyline_list; + line_finder.findPolylines(scan, scan_params, polyline_list); + + std::cout << polyline_list.size() << " polylines found!" << std::endl; + +} -- GitLab