From 778fccf5adbf0a0257954fc6409efef1572c92d6 Mon Sep 17 00:00:00 2001
From: jcasals <jcasals@iri.upc.edu>
Date: Thu, 18 Jul 2019 11:54:13 +0200
Subject: [PATCH] Implemented storeCapture() & storeKeyFrame() in core
 processors

---
 hello_wolf/processor_range_bearing.cpp            |  8 ++++++++
 hello_wolf/processor_range_bearing.h              | 12 ++++++++++++
 include/core/processor/processor_capture_holder.h | 12 ++++++++++++
 include/core/processor/processor_motion.h         | 12 ++++++++++++
 src/processor/processor_capture_holder.cpp        | 10 ++++++++++
 src/processor/processor_motion.cpp                |  9 +++++++++
 6 files changed, 63 insertions(+)

diff --git a/hello_wolf/processor_range_bearing.cpp b/hello_wolf/processor_range_bearing.cpp
index 7cf2c04fa..7ecc1ac43 100644
--- a/hello_wolf/processor_range_bearing.cpp
+++ b/hello_wolf/processor_range_bearing.cpp
@@ -190,6 +190,14 @@ Eigen::Vector2s ProcessorRangeBearing::rect(Scalar range, Scalar bearing) const
     return range * (Vector2s() << cos(bearing), sin(bearing)).finished();
 }
 
+bool ProcessorRangeBearing::storeKeyFrame(FrameBasePtr _frame_ptr)
+{
+  return true;
+}
+bool ProcessorRangeBearing::storeCapture(CaptureBasePtr _cap_ptr)
+{
+  return false;
+}
 } /* namespace wolf */
 
 // Register in the SensorFactory
diff --git a/hello_wolf/processor_range_bearing.h b/hello_wolf/processor_range_bearing.h
index ff99fddfb..3973a7339 100644
--- a/hello_wolf/processor_range_bearing.h
+++ b/hello_wolf/processor_range_bearing.h
@@ -65,6 +65,18 @@ class ProcessorRangeBearing : public ProcessorBase
         virtual bool triggerInKeyFrame  (FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other) override {return false;}
         virtual bool voteForKeyFrame    () override {return false;}
 
+        /** \brief store key frame
+        *
+        * Returns true if the key frame should be stored
+        */
+        virtual bool storeKeyFrame(FrameBasePtr) override;
+
+        /** \brief store capture
+        *
+        * Returns true if the capture should be stored
+        */
+        virtual bool storeCapture(CaptureBasePtr) override;
+
     private:
         // control variables
         Trf H_r_s; // transformation matrix, robot to sensor
diff --git a/include/core/processor/processor_capture_holder.h b/include/core/processor/processor_capture_holder.h
index 19b33f8f2..1ddce179b 100644
--- a/include/core/processor/processor_capture_holder.h
+++ b/include/core/processor/processor_capture_holder.h
@@ -63,6 +63,18 @@ class ProcessorCaptureHolder : public ProcessorBase
          */
         virtual bool triggerInKeyFrame(FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other) override { return true; }
 
+        /** \brief store key frame
+        *
+        * Returns true if the key frame should be stored
+        */
+        virtual bool storeKeyFrame(FrameBasePtr) override;
+
+        /** \brief store capture
+        *
+        * Returns true if the capture should be stored
+        */
+        virtual bool storeCapture(CaptureBasePtr) override;
+
         /** \brief Vote for KeyFrame generation
         *
         * If a KeyFrame criterion is validated, this function returns true,
diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h
index c7fc1771f..564b714b0 100644
--- a/include/core/processor/processor_motion.h
+++ b/include/core/processor/processor_motion.h
@@ -247,6 +247,18 @@ class ProcessorMotion : public ProcessorBase
          */
         virtual bool triggerInKeyFrame(FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other) override {return false;}
 
+        /** \brief store key frame
+        *
+        * Returns true if the key frame should be stored
+        */
+        virtual bool storeKeyFrame(FrameBasePtr) override;
+
+        /** \brief store capture
+        *
+        * Returns true if the capture should be stored
+        */
+        virtual bool storeCapture(CaptureBasePtr) override;
+
         virtual bool voteForKeyFrame() override;
 
         Scalar updateDt();
diff --git a/src/processor/processor_capture_holder.cpp b/src/processor/processor_capture_holder.cpp
index 5cad88a4e..c3fd19abd 100644
--- a/src/processor/processor_capture_holder.cpp
+++ b/src/processor/processor_capture_holder.cpp
@@ -75,6 +75,16 @@ ProcessorBasePtr ProcessorCaptureHolder::create(const std::string& _unique_name,
       return prc_ptr;
 }
 
+bool ProcessorCaptureHolder::storeKeyFrame(FrameBasePtr _frame_ptr)
+{
+  return false;
+}
+bool ProcessorCaptureHolder::storeCapture(CaptureBasePtr _cap_ptr)
+{
+  return true;
+}
+
+
 } // namespace wolf
 
 // Register in the ProcessorFactory
diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp
index 27b56edaa..b8076cb23 100644
--- a/src/processor/processor_motion.cpp
+++ b/src/processor/processor_motion.cpp
@@ -668,4 +668,13 @@ void ProcessorMotion::setProblem(ProblemPtr _problem)
         this->getProblem()->setProcessorMotion(std::static_pointer_cast<ProcessorMotion>(shared_from_this()));
 };
 
+bool ProcessorMotion::storeKeyFrame(FrameBasePtr _frame_ptr)
+{
+  return true;
+}
+bool ProcessorMotion::storeCapture(CaptureBasePtr _cap_ptr)
+{
+  return false;
+}
+
 }
-- 
GitLab