From 51967d5efc062524bb96a7c9b9937172fad6c74b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu>
Date: Sat, 12 Dec 2020 21:54:53 +0100
Subject: [PATCH] Work on params:print()

---
 demos/hello_wolf/processor_range_bearing.h                   | 2 +-
 demos/hello_wolf/sensor_range_bearing.h                      | 2 +-
 include/core/common/params_base.h                            | 5 +----
 include/core/processor/processor_base.h                      | 5 ++---
 include/core/processor/processor_diff_drive.h                | 2 +-
 include/core/processor/processor_motion.h                    | 2 +-
 include/core/processor/processor_odom_2d.h                   | 2 +-
 include/core/processor/processor_odom_3d.h                   | 2 +-
 include/core/sensor/sensor_base.h                            | 2 +-
 include/core/sensor/sensor_diff_drive.h                      | 2 +-
 include/core/sensor/sensor_odom_2d.h                         | 4 ++--
 include/core/sensor/sensor_odom_3d.h                         | 4 ++--
 include/core/solver/solver_manager.h                         | 4 ++++
 include/core/tree_manager/tree_manager_base.h                | 4 ++--
 include/core/tree_manager/tree_manager_sliding_window.h      | 2 +-
 .../tree_manager/tree_manager_sliding_window_dual_rate.h     | 2 +-
 test/dummy/tree_manager_dummy.h                              | 2 +-
 17 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/demos/hello_wolf/processor_range_bearing.h b/demos/hello_wolf/processor_range_bearing.h
index bdcefb3a7..f086da907 100644
--- a/demos/hello_wolf/processor_range_bearing.h
+++ b/demos/hello_wolf/processor_range_bearing.h
@@ -33,7 +33,7 @@ struct ParamsProcessorRangeBearing : public ParamsProcessorBase
         }
         std::string print() const
         {
-            return "\n" + ParamsProcessorBase::print();
+            return ParamsProcessorBase::print();
         }
 };
 
diff --git a/demos/hello_wolf/sensor_range_bearing.h b/demos/hello_wolf/sensor_range_bearing.h
index 59c217fe0..70684f779 100644
--- a/demos/hello_wolf/sensor_range_bearing.h
+++ b/demos/hello_wolf/sensor_range_bearing.h
@@ -31,7 +31,7 @@ struct ParamsSensorRangeBearing : public ParamsSensorBase
     }
     std::string print() const
     {
-        return "" + ParamsSensorBase::print()                                         + "\n"
+        return ParamsSensorBase::print()                                         + "\n"
         + "noise_range_metres_std: "    + std::to_string(noise_range_metres_std)    + "\n"
         + "noise_bearing_degrees_std: " + std::to_string(noise_bearing_degrees_std) + "\n";
     }
diff --git a/include/core/common/params_base.h b/include/core/common/params_base.h
index 80f651641..b9a4886c2 100644
--- a/include/core/common/params_base.h
+++ b/include/core/common/params_base.h
@@ -13,10 +13,7 @@ namespace wolf {
     }
 
     virtual ~ParamsBase() = default;
-    std::string print() const
-    {
-        return "";
-    }
+    virtual std::string print() const = 0;
   };
 }
 #endif
diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h
index ffdc78fe0..f6b5cc5fb 100644
--- a/include/core/processor/processor_base.h
+++ b/include/core/processor/processor_base.h
@@ -242,11 +242,10 @@ struct ParamsProcessorBase : public ParamsBase
     bool voting_aux_active;     ///< Whether this processor is allowed to vote for an Auxiliary Frame or not
     bool apply_loss_function;   ///< Whether this processor emplaces factors with loss function or not
 
-    std::string print() const
+    std::string print() const override
     {
-        return ParamsBase::print() + "\n"
-                + "voting_active: "         + std::to_string(voting_active)         + "\n"
                 + "voting_aux_active: "     + std::to_string(voting_aux_active)     + "\n"
+        return    "voting_active: "         + std::to_string(voting_active)         + "\n"
                 + "time_tolerance: "        + std::to_string(time_tolerance)        + "\n"
                 + "apply_loss_function: "   + std::to_string(apply_loss_function)   + "\n";
     }
diff --git a/include/core/processor/processor_diff_drive.h b/include/core/processor/processor_diff_drive.h
index 6fb9eb40f..b1917f708 100644
--- a/include/core/processor/processor_diff_drive.h
+++ b/include/core/processor/processor_diff_drive.h
@@ -24,7 +24,7 @@ struct ParamsProcessorDiffDrive : public ParamsProcessorOdom2d
         }
         std::string print() const
         {
-            return "\n" + ParamsProcessorOdom2d::print();
+            return ParamsProcessorOdom2d::print();
         }
 };
 
diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h
index 6a0f15a90..7804114d0 100644
--- a/include/core/processor/processor_motion.h
+++ b/include/core/processor/processor_motion.h
@@ -43,7 +43,7 @@ struct ParamsProcessorMotion : public ParamsProcessorBase
         }
         std::string print() const
         {
-          return "\n" + ParamsProcessorBase::print() + "\n"
+          return ParamsProcessorBase::print() + "\n"
             + "max_time_span: "     + std::to_string(max_time_span)     + "\n"
             + "max_buff_length: "   + std::to_string(max_buff_length)   + "\n"
             + "dist_traveled: "     + std::to_string(dist_traveled)     + "\n"
diff --git a/include/core/processor/processor_odom_2d.h b/include/core/processor/processor_odom_2d.h
index de3aebb4a..b61b4ba6e 100644
--- a/include/core/processor/processor_odom_2d.h
+++ b/include/core/processor/processor_odom_2d.h
@@ -33,7 +33,7 @@ struct ParamsProcessorOdom2d : public ParamsProcessorMotion
 
         std::string print() const
         {
-            return "\n" + ParamsProcessorMotion::print()    + "\n"
+            return ParamsProcessorMotion::print()    + "\n"
             + "cov_det: "   + std::to_string(cov_det)       + "\n";
         }
 };
diff --git a/include/core/processor/processor_odom_3d.h b/include/core/processor/processor_odom_3d.h
index 0ff94590e..c6ca8dbaf 100644
--- a/include/core/processor/processor_odom_3d.h
+++ b/include/core/processor/processor_odom_3d.h
@@ -29,7 +29,7 @@ struct ParamsProcessorOdom3d : public ParamsProcessorMotion
         }
         std::string print() const
         {
-            return "\n" + ParamsProcessorMotion::print();
+            return ParamsProcessorMotion::print();
         }
 };
 
diff --git a/include/core/sensor/sensor_base.h b/include/core/sensor/sensor_base.h
index bf9556bab..4c27ecb6e 100644
--- a/include/core/sensor/sensor_base.h
+++ b/include/core/sensor/sensor_base.h
@@ -76,7 +76,7 @@ struct ParamsSensorBase: public ParamsBase
     std::string prefix = "sensor/";
     ~ParamsSensorBase() override = default;
     using ParamsBase::ParamsBase;
-    std::string print() const
+    std::string print() const override
     {
         return "";
     }
diff --git a/include/core/sensor/sensor_diff_drive.h b/include/core/sensor/sensor_diff_drive.h
index 8238139c3..cb08a2dd0 100644
--- a/include/core/sensor/sensor_diff_drive.h
+++ b/include/core/sensor/sensor_diff_drive.h
@@ -39,7 +39,7 @@ struct ParamsSensorDiffDrive : public ParamsSensorBase
     }
     std::string print() const
     {
-        return "\n" + ParamsSensorBase::print()                                           + "\n"
+        return ParamsSensorBase::print()                                         + "\n"
         + "radius_left: "                   + std::to_string(radius_left)               + "\n"
         + "radius_right: "                  + std::to_string(radius_right)              + "\n"
         + "wheel_separation: "              + std::to_string(wheel_separation)          + "\n"
diff --git a/include/core/sensor/sensor_odom_2d.h b/include/core/sensor/sensor_odom_2d.h
index b2a989a6f..5f2fc1a71 100644
--- a/include/core/sensor/sensor_odom_2d.h
+++ b/include/core/sensor/sensor_odom_2d.h
@@ -25,9 +25,9 @@ struct ParamsSensorOdom2d : public ParamsSensorBase
         k_disp_to_disp = _server.getParam<double>(prefix + _unique_name + "/k_disp_to_disp");
         k_rot_to_rot   = _server.getParam<double>(prefix + _unique_name + "/k_rot_to_rot");
     }
-    std::string print() const
+    std::string print() const override
     {
-        return "\n" + ParamsSensorBase::print()                               + "\n"
+        return ParamsSensorBase::print()                               + "\n"
                 + "k_disp_to_disp: "    + std::to_string(k_disp_to_disp)    + "\n"
                 + "k_rot_to_rot: "      + std::to_string(k_rot_to_rot)      + "\n";
     }
diff --git a/include/core/sensor/sensor_odom_3d.h b/include/core/sensor/sensor_odom_3d.h
index 37ec082f5..ab0e8b468 100644
--- a/include/core/sensor/sensor_odom_3d.h
+++ b/include/core/sensor/sensor_odom_3d.h
@@ -36,9 +36,9 @@ struct ParamsSensorOdom3d : public ParamsSensorBase
         min_disp_var   = _server.getParam<double>(prefix + _unique_name + "/min_disp_var");
         min_rot_var    = _server.getParam<double>(prefix + _unique_name + "/min_rot_var");
     }
-    std::string print() const
+    std::string print() const override
     {
-      return "\n" + ParamsSensorBase::print()                      + "\n"
+      return ParamsSensorBase::print()                      + "\n"
         + "k_disp_to_disp: "    + std::to_string(k_disp_to_disp) + "\n"
         + "k_disp_to_rot: "     + std::to_string(k_disp_to_rot)  + "\n"
         + "k_rot_to_rot: "      + std::to_string(k_rot_to_rot)   + "\n"
diff --git a/include/core/solver/solver_manager.h b/include/core/solver/solver_manager.h
index 26ac49efb..53fc181cb 100644
--- a/include/core/solver/solver_manager.h
+++ b/include/core/solver/solver_manager.h
@@ -202,6 +202,10 @@ struct ParamsSolver: public ParamsBase
             period  = _server.getParam<double>(prefix + "period");
             verbose = (SolverManager::ReportVerbosity)_server.getParam<int>(prefix + "verbose");
         }
+        std::string print() const override
+        {
+            return  "period: "                   + std::to_string(period)         + "\n";
+        }
 
         ~ParamsSolver() override = default;
 };
diff --git a/include/core/tree_manager/tree_manager_base.h b/include/core/tree_manager/tree_manager_base.h
index 2ffef15ed..9fd06f2f0 100644
--- a/include/core/tree_manager/tree_manager_base.h
+++ b/include/core/tree_manager/tree_manager_base.h
@@ -55,9 +55,9 @@ struct ParamsTreeManagerBase : public ParamsBase
 
     ~ParamsTreeManagerBase() override = default;
 
-    std::string print() const
+    std::string print() const override
     {
-        return ParamsBase::print() + "\n";
+        return "";
     }
 };
 
diff --git a/include/core/tree_manager/tree_manager_sliding_window.h b/include/core/tree_manager/tree_manager_sliding_window.h
index ce44fe003..86bc095f4 100644
--- a/include/core/tree_manager/tree_manager_sliding_window.h
+++ b/include/core/tree_manager/tree_manager_sliding_window.h
@@ -21,7 +21,7 @@ struct ParamsTreeManagerSlidingWindow : public ParamsTreeManagerBase
         }
         std::string print() const
         {
-            return "\n" + ParamsTreeManagerBase::print()                                            + "\n"
+            return  ParamsTreeManagerBase::print()                                            + "\n"
                         + "n_frames: "                  + std::to_string(n_frames)                  + "\n"
                         + "fix_first_frame: "           + std::to_string(fix_first_frame)           + "\n"
                         + "viral_remove_empty_parent: " + std::to_string(viral_remove_empty_parent) + "\n";
diff --git a/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h b/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h
index e9fcbd133..3d455f890 100644
--- a/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h
+++ b/include/core/tree_manager/tree_manager_sliding_window_dual_rate.h
@@ -21,7 +21,7 @@ struct ParamsTreeManagerSlidingWindowDualRate : public ParamsTreeManagerSlidingW
         }
         std::string print() const
         {
-            return "\n" + ParamsTreeManagerBase::print()                            + "\n"
+            return ParamsTreeManagerBase::print()                            + "\n"
                         + "n_frames_recent: "   + std::to_string(n_frames_recent)   + "\n"
                         + "rate_old_frames: "   + std::to_string(rate_old_frames)   + "\n";
         }
diff --git a/test/dummy/tree_manager_dummy.h b/test/dummy/tree_manager_dummy.h
index 662c7d156..1e7e70f2e 100644
--- a/test/dummy/tree_manager_dummy.h
+++ b/test/dummy/tree_manager_dummy.h
@@ -20,7 +20,7 @@ struct ParamsTreeManagerDummy : public ParamsTreeManagerBase
 
     bool toy_param;
 
-    std::string print() const
+    std::string print() const override
     {
         return ParamsTreeManagerBase::print() + "\n"
                + "toy_param: " + std::to_string(toy_param) + "\n";
-- 
GitLab