From 2331477db852d75c75c0def1d5ce5e1e979339fa Mon Sep 17 00:00:00 2001
From: joanvallve <jvallve@iri.upc.edu>
Date: Mon, 8 Jul 2024 17:06:31 +0200
Subject: [PATCH] making falko stuff more easy

---
 CMakeLists.txt                              |  1 +
 include/laser_scan_utils/scene_falko.h      |  9 +---
 include/laser_scan_utils/scene_falko_base.h | 56 +++++++++++++++++++++
 src/icp.cpp                                 |  2 +-
 4 files changed, 60 insertions(+), 8 deletions(-)
 create mode 100644 include/laser_scan_utils/scene_falko_base.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e7f34cc..d39a73d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,6 +96,7 @@ SET(HDRS
     SET(HDRS ${HDRS}
       include/${PROJECT_NAME}/corner_falko_2d.h
       include/${PROJECT_NAME}/loop_closure_falko.h
+      include/${PROJECT_NAME}/scene_falko_base.h
       include/${PROJECT_NAME}/scene_falko.h
       include/${PROJECT_NAME}/match_loop_closure_scene.h)
   ENDIF(falkolib_FOUND)
diff --git a/include/laser_scan_utils/scene_falko.h b/include/laser_scan_utils/scene_falko.h
index 9719b46..3775176 100644
--- a/include/laser_scan_utils/scene_falko.h
+++ b/include/laser_scan_utils/scene_falko.h
@@ -38,7 +38,7 @@
 /**************************
  *      LaserScanUtils includes      *
  **************************/
-#include "scene_base.h"
+#include "scene_falko_base.h"
 
 /**************************
  *      Falko includes      *
@@ -53,13 +53,8 @@ namespace laserscanutils {
 typedef falkolib::BSC bsc;
 typedef falkolib::CGH cgh;
 
-template <typename D> struct SceneFalko : public SceneBase
+template <typename D> struct SceneFalko : public SceneFalkoBase
 {
-    std::vector<falkolib::FALKO> keypoints_list_;
-    std::vector<falkolib::FALKO> keypoints_list_mid_point_;
-    std::vector<falkolib::FALKO> keypoints_list_transl_rot_;
-    std::vector<falkolib::FALKO> keypoints_list_rotated_;
-    std::vector<falkolib::FALKO> keypoints_list_rotated_reverse_;
     std::vector<D>               descriptors_list_;
     std::vector<D>               descriptors_list_rotated;
     std::vector<double>          angle_rotation_;
diff --git a/include/laser_scan_utils/scene_falko_base.h b/include/laser_scan_utils/scene_falko_base.h
new file mode 100644
index 0000000..62f7915
--- /dev/null
+++ b/include/laser_scan_utils/scene_falko_base.h
@@ -0,0 +1,56 @@
+//--------LICENSE_START--------
+//
+// Copyright (C) 2020,2021,2022,2023,2024 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
+// Authors: Joan Vallvé Navarro (jvallve@iri.upc.edu)
+// All rights reserved.
+//
+// This file is part of laser_scan_utils
+// laser_scan_utils is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+//--------LICENSE_END--------
+
+#ifndef SCENE_FALKO_BASE_H_
+#define SCENE_FALKO_BASE_H_
+
+#include <fstream>
+#include <iostream>
+#include <iterator>
+#include <list>
+#include <memory>
+
+/**************************
+ *      LaserScanUtils includes      *
+ **************************/
+#include "scene_base.h"
+
+/**************************
+ *      Falko includes      *
+ **************************/
+
+#include <falkolib/Feature/FALKO.h>
+
+namespace laserscanutils {
+
+struct SceneFalkoBase : public SceneBase
+{
+    std::vector<falkolib::FALKO> keypoints_list_;
+    std::vector<falkolib::FALKO> keypoints_list_mid_point_;
+    std::vector<falkolib::FALKO> keypoints_list_transl_rot_;
+    std::vector<falkolib::FALKO> keypoints_list_rotated_;
+    std::vector<falkolib::FALKO> keypoints_list_rotated_reverse_;
+};
+
+} /* namespace laserscanutils */
+
+#endif /* SCENE_FALKO_H_ */
diff --git a/src/icp.cpp b/src/icp.cpp
index 8909a88..ba02420 100644
--- a/src/icp.cpp
+++ b/src/icp.cpp
@@ -205,7 +205,7 @@ icpOutput ICP::align(const LaserScan &_current_ls,
 
         if (_icp_params.verbose and not result.valid)
         {
-            std::cout << "Invalid result, trying again!" << std::endl;
+            std::cout << (result.attempts < _icp_params.attempts ? "Invalid result, trying again!" : "Invalid result") << std::endl;
         }
 
     } while (not result.valid and result.attempts < _icp_params.attempts);
-- 
GitLab