From b4c766bf75041e57020c05f6a4b5179bc4e8788f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Tue, 30 Apr 2019 16:06:11 +0200 Subject: [PATCH] added processor voting/permit auxiliary frames machinery --- include/base/processor/processor_base.h | 36 ++++++++++++++++++++++--- src/processor/processor_IMU.cpp | 2 -- src/processor/processor_base.cpp | 5 ++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/include/base/processor/processor_base.h b/include/base/processor/processor_base.h index 5d68c43c7..9e149abcb 100644 --- a/include/base/processor/processor_base.h +++ b/include/base/processor/processor_base.h @@ -110,16 +110,19 @@ struct ProcessorParamsBase ProcessorParamsBase() = default; ProcessorParamsBase(bool _voting_active, - Scalar _time_tolerance) - : voting_active(_voting_active) - , time_tolerance(_time_tolerance) + Scalar _time_tolerance, + bool _voting_aux_active = false) : + voting_active(_voting_active), + voting_aux_active(_voting_aux_active), + time_tolerance(_time_tolerance) { // } virtual ~ProcessorParamsBase() = default; - bool voting_active = false; + bool voting_active = false; ///< Whether this processor is allowed to vote for a Key Frame or not + bool voting_aux_active = false; ///< Whether this processor is allowed to vote for an Auxiliary Frame or not ///< maximum time difference between a Keyframe time stamp and /// a particular Capture of this processor to allow assigning @@ -159,8 +162,19 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce */ virtual bool voteForKeyFrame() = 0; + /** \brief Vote for Auxiliary Frame generation + * + * If a Auxiliary Frame criterion is validated, this function returns true, + * meaning that it wants to create a Auxiliary Frame at the \b last Capture. + * + * WARNING! This function only votes! It does not create Auxiliary Frames! + */ + virtual bool voteForAuxFrame(){return false;}; + virtual bool permittedKeyFrame() final; + virtual bool permittedAuxFrame() final; + /**\brief make a Frame with the provided Capture * * Provide the following functionality: @@ -192,7 +206,11 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce bool isVotingActive() const; + bool isVotingAuxActive() const; + void setVotingActive(bool _voting_active = true); + + void setVotingAuxActive(bool _voting_active = true); }; inline bool ProcessorBase::isVotingActive() const @@ -200,11 +218,21 @@ inline bool ProcessorBase::isVotingActive() const return params_->voting_active; } +inline bool ProcessorBase::isVotingAuxActive() const +{ + return params_->voting_aux_active; +} + inline void ProcessorBase::setVotingActive(bool _voting_active) { params_->voting_active = _voting_active; } +inline void ProcessorBase::setVotingAuxActive(bool _voting_active) +{ + params_->voting_aux_active = _voting_active; +} + } #include "base/sensor/sensor_base.h" diff --git a/src/processor/processor_IMU.cpp b/src/processor/processor_IMU.cpp index 2dfa2cd7d..b192163cc 100644 --- a/src/processor/processor_IMU.cpp +++ b/src/processor/processor_IMU.cpp @@ -35,8 +35,6 @@ ProcessorBasePtr ProcessorIMU::create(const std::string& _unique_name, const Pro bool ProcessorIMU::voteForKeyFrame() { - if(!isVotingActive()) - return false; // time span if (getBuffer().get().back().ts_ - getBuffer().get().front().ts_ > params_motion_IMU_->max_time_span) { diff --git a/src/processor/processor_base.cpp b/src/processor/processor_base.cpp index 260f41698..77e00b835 100644 --- a/src/processor/processor_base.cpp +++ b/src/processor/processor_base.cpp @@ -26,6 +26,11 @@ bool ProcessorBase::permittedKeyFrame() return isVotingActive() && getProblem()->permitKeyFrame(shared_from_this()); } +bool ProcessorBase::permittedAuxFrame() +{ + return isVotingAuxActive() && getProblem()->permitAuxFrame(shared_from_this()); +} + FrameBasePtr ProcessorBase::emplaceFrame(FrameType _type, CaptureBasePtr _capture_ptr) { std::cout << "Making " << (_type == KEY ? "key-" : (_type == AUXILIARY ? "aux-" : "")) << "frame" << std::endl; -- GitLab