From c6ea193eb12eea9617365db9513db962ebb44863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu> Date: Thu, 22 Mar 2018 00:00:21 +0100 Subject: [PATCH] Move voting_active_ to ProcessorBase --- src/processor_IMU.cpp | 4 +++- src/processor_IMU.h | 2 -- src/processor_base.cpp | 5 +++-- src/processor_base.h | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/processor_IMU.cpp b/src/processor_IMU.cpp index bb0ae86bf..1010aa8ba 100644 --- a/src/processor_IMU.cpp +++ b/src/processor_IMU.cpp @@ -15,6 +15,8 @@ ProcessorIMU::ProcessorIMU(const ProcessorParamsIMU& _params) : jacobian_delta_preint_.setIdentity(9,9); // dDp'/dDp, dDv'/dDv, all zeros jacobian_delta_.setIdentity(9,9); // jacobian_calib_.setZero(9,6); + + setVotingActive(_params.voting_active ); } ProcessorIMU::~ProcessorIMU() @@ -44,7 +46,7 @@ ProcessorBasePtr ProcessorIMU::create(const std::string& _unique_name, const Pro bool ProcessorIMU::voteForKeyFrame() { - if(!voting_active_) + if(!isVotingActive()) return false; // time span if (getBuffer().get().back().ts_ - getBuffer().get().front().ts_ > max_time_span_) diff --git a/src/processor_IMU.h b/src/processor_IMU.h index 911d50f8c..3954d5ac1 100644 --- a/src/processor_IMU.h +++ b/src/processor_IMU.h @@ -16,7 +16,6 @@ struct ProcessorParamsIMU : public ProcessorParamsBase Size max_buff_length = 10; Scalar dist_traveled = 5; Scalar angle_turned = 0.5; - bool voting_active = false; //IMU will not vote for key Frames to be created }; WOLF_PTR_TYPEDEFS(ProcessorIMU); @@ -70,7 +69,6 @@ class ProcessorIMU : public ProcessorMotion{ Size max_buff_length_;// maximum buffer size before keyframe Scalar dist_traveled_; // maximum linear motion between keyframes Scalar angle_turned_; // maximum rotation between keyframes - bool voting_active_; // IMU will be voting for KeyFrame only if this is true public: diff --git a/src/processor_base.cpp b/src/processor_base.cpp index 2cc289cdd..c6a1e4529 100644 --- a/src/processor_base.cpp +++ b/src/processor_base.cpp @@ -12,7 +12,8 @@ ProcessorBase::ProcessorBase(const std::string& _type, const Scalar& _time_toler processor_id_(++processor_id_count_), time_tolerance_(_time_tolerance), sensor_ptr_(), - is_removing_(false) + is_removing_(false), + voting_active_(true) { // WOLF_DEBUG("constructed +p" , id()); } @@ -24,7 +25,7 @@ ProcessorBase::~ProcessorBase() bool ProcessorBase::permittedKeyFrame() { - return getProblem()->permitKeyFrame(shared_from_this()); + return isVotingActive() && getProblem()->permitKeyFrame(shared_from_this()); } FrameBasePtr ProcessorBase::emplaceFrame(FrameType _type, CaptureBasePtr _capture_ptr) diff --git a/src/processor_base.h b/src/processor_base.h index 7d7fe4226..de6ecd94b 100644 --- a/src/processor_base.h +++ b/src/processor_base.h @@ -111,6 +111,7 @@ struct ProcessorParamsBase std::string type; std::string name; Scalar time_tolerance; ///< maximum time difference between a Keyframe time stamp and a particular Capture of this processor to allow assigning this Capture to the Keyframe. + bool voting_active; }; //class ProcessorBase @@ -125,6 +126,8 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce SensorBaseWPtr sensor_ptr_; bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). + bool voting_active_; ///< A flag for allowing the processor to vote for KF or not. + static unsigned int processor_id_count_; public: @@ -176,8 +179,21 @@ class ProcessorBase : public NodeBase, public std::enable_shared_from_this<Proce void setTimeTolerance(Scalar _time_tolerance); + bool isVotingActive() const; + + void setVotingActive(bool _voting_active = true); }; +inline bool ProcessorBase::isVotingActive() const +{ + return voting_active_; +} + +inline void ProcessorBase::setVotingActive(bool _voting_active) +{ + voting_active_ = _voting_active; +} + } #include "sensor_base.h" -- GitLab