From 4fa9996f178a9b794f8ddd7f299cda791986e3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Tue, 29 Jan 2019 09:41:34 +0100 Subject: [PATCH] changed is_removing to node_base --- src/capture_base.cpp | 1 - src/capture_base.h | 3 +-- src/constraint_base.cpp | 2 -- src/constraint_base.h | 3 +-- src/feature_base.cpp | 1 - src/feature_base.h | 3 +-- src/frame_base.cpp | 2 -- src/frame_base.h | 3 +-- src/landmark_base.cpp | 1 - src/landmark_base.h | 3 +-- src/node_base.h | 12 +++++++++++- src/sensor_base.cpp | 2 -- src/sensor_base.h | 3 +-- 13 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/capture_base.cpp b/src/capture_base.cpp index d5d76ba8e..880303f49 100644 --- a/src/capture_base.cpp +++ b/src/capture_base.cpp @@ -18,7 +18,6 @@ CaptureBase::CaptureBase(const std::string& _type, sensor_ptr_(_sensor_ptr), state_block_vec_(3), calib_size_(0), - is_removing_(false), capture_id_(++capture_id_count_), time_stamp_(_ts) { diff --git a/src/capture_base.h b/src/capture_base.h index d705be376..9da734e64 100644 --- a/src/capture_base.h +++ b/src/capture_base.h @@ -29,7 +29,6 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture SizeEigen calib_size_; ///< size of the calibration parameters (dynamic or static sensor params that are not fixed) static unsigned int capture_id_count_; - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int capture_id_; @@ -45,7 +44,7 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture StateBlockPtr _intr_ptr = nullptr); virtual ~CaptureBase(); - void remove(); + virtual void remove(); // Type virtual bool isMotion() const { return false; } diff --git a/src/constraint_base.cpp b/src/constraint_base.cpp index d88dedbf0..3e33cc6cc 100644 --- a/src/constraint_base.cpp +++ b/src/constraint_base.cpp @@ -11,7 +11,6 @@ ConstraintBase::ConstraintBase(const std::string& _tp, ConstraintStatus _status) : NodeBase("CONSTRAINT", _tp), feature_ptr_(), // nullptr - is_removing_(false), constraint_id_(++constraint_id_count_), status_(_status), apply_loss_function_(_apply_loss_function), @@ -32,7 +31,6 @@ ConstraintBase::ConstraintBase(const std::string& _tp, bool _apply_loss_function, ConstraintStatus _status) : NodeBase("CONSTRAINT", _tp), feature_ptr_(), - is_removing_(false), constraint_id_(++constraint_id_count_), status_(_status), apply_loss_function_(_apply_loss_function), diff --git a/src/constraint_base.h b/src/constraint_base.h index 838d50c23..3341a55c8 100644 --- a/src/constraint_base.h +++ b/src/constraint_base.h @@ -42,7 +42,6 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons FeatureBaseWPtr feature_ptr_; ///< FeatureBase pointer (upper node) static unsigned int constraint_id_count_; - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int constraint_id_; @@ -75,7 +74,7 @@ class ConstraintBase : public NodeBase, public std::enable_shared_from_this<Cons virtual ~ConstraintBase() = default; - void remove(); + virtual void remove(); unsigned int id() const; diff --git a/src/feature_base.cpp b/src/feature_base.cpp index 3cc0b6ca3..6459ffc24 100644 --- a/src/feature_base.cpp +++ b/src/feature_base.cpp @@ -9,7 +9,6 @@ unsigned int FeatureBase::feature_id_count_ = 0; FeatureBase::FeatureBase(const std::string& _type, const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance) : NodeBase("FEATURE", _type), capture_ptr_(), - is_removing_(false), feature_id_(++feature_id_count_), track_id_(0), landmark_id_(0), diff --git a/src/feature_base.h b/src/feature_base.h index 3bd60033a..1eb4fbf85 100644 --- a/src/feature_base.h +++ b/src/feature_base.h @@ -25,7 +25,6 @@ class FeatureBase : public NodeBase, public std::enable_shared_from_this<Feature ConstraintBaseList constrained_by_list_; static unsigned int feature_id_count_; - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int feature_id_; @@ -46,7 +45,7 @@ class FeatureBase : public NodeBase, public std::enable_shared_from_this<Feature FeatureBase(const std::string& _type, const Eigen::VectorXs& _measurement, const Eigen::MatrixXs& _meas_covariance); virtual ~FeatureBase(); - void remove(); + virtual void remove(); virtual void setProblem(ProblemPtr _problem) final; diff --git a/src/frame_base.cpp b/src/frame_base.cpp index c605ae015..4f0f619fe 100644 --- a/src/frame_base.cpp +++ b/src/frame_base.cpp @@ -15,7 +15,6 @@ FrameBase::FrameBase(const TimeStamp& _ts, StateBlockPtr _p_ptr, StateBlockPtr _ NodeBase("FRAME", "Base"), trajectory_ptr_(), state_block_vec_(3), // allow for 3 state blocks by default. Resize in derived constructors if needed. - is_removing_(false), frame_id_(++frame_id_count_), type_(NON_KEY_FRAME), time_stamp_(_ts) @@ -29,7 +28,6 @@ FrameBase::FrameBase(const FrameType & _tp, const TimeStamp& _ts, StateBlockPtr NodeBase("FRAME", "Base"), trajectory_ptr_(), state_block_vec_(3), // allow for 3 state blocks by default. Resize in derived constructors if needed. - is_removing_(false), frame_id_(++frame_id_count_), type_(_tp), time_stamp_(_ts) diff --git a/src/frame_base.h b/src/frame_base.h index d5202bb69..f7e5f8379 100644 --- a/src/frame_base.h +++ b/src/frame_base.h @@ -37,7 +37,6 @@ class FrameBase : public NodeBase, public std::enable_shared_from_this<FrameBase std::vector<StateBlockPtr> state_block_vec_; ///< vector of state blocks, in the order: Position, Orientation, Velocity. static unsigned int frame_id_count_; - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int frame_id_; @@ -67,7 +66,7 @@ class FrameBase : public NodeBase, public std::enable_shared_from_this<FrameBase FrameBase(const FrameType & _tp, const TimeStamp& _ts, StateBlockPtr _p_ptr, StateBlockPtr _o_ptr = nullptr, StateBlockPtr _v_ptr = nullptr); virtual ~FrameBase(); - void remove(); + virtual void remove(); diff --git a/src/landmark_base.cpp b/src/landmark_base.cpp index 750911457..830ae2940 100644 --- a/src/landmark_base.cpp +++ b/src/landmark_base.cpp @@ -13,7 +13,6 @@ LandmarkBase::LandmarkBase(const std::string& _type, StateBlockPtr _p_ptr, State NodeBase("LANDMARK", _type), map_ptr_(), state_block_vec_(2), // allow for 2 state blocks by default. Resize in derived constructors if needed. - is_removing_(false), landmark_id_(++landmark_id_count_) { state_block_vec_[0] = _p_ptr; diff --git a/src/landmark_base.h b/src/landmark_base.h index e4b721db9..66485387a 100644 --- a/src/landmark_base.h +++ b/src/landmark_base.h @@ -29,7 +29,6 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma std::vector<StateBlockPtr> state_block_vec_; ///< vector of state blocks, in the order P, O. static unsigned int landmark_id_count_; - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int landmark_id_; ///< landmark unique id @@ -48,7 +47,7 @@ class LandmarkBase : public NodeBase, public std::enable_shared_from_this<Landma **/ LandmarkBase(const std::string& _type, StateBlockPtr _p_ptr, StateBlockPtr _o_ptr = nullptr); virtual ~LandmarkBase(); - void remove(); + virtual void remove(); virtual YAML::Node saveToYaml() const; // Properties diff --git a/src/node_base.h b/src/node_base.h index 1cf31eb69..68b9960db 100644 --- a/src/node_base.h +++ b/src/node_base.h @@ -67,15 +67,19 @@ class NodeBase std::string node_type_; ///< Text label identifying the type or subcategory of node ("Pin Hole", "Point 2D", etc) std::string node_name_; ///< Text label identifying each specific object ("left camera", "LIDAR 1", "PointGrey", "Andrew", etc) + bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). + public: NodeBase(const std::string& _category, const std::string& _type = "Undefined", const std::string& _name = ""); virtual ~NodeBase() = default; + virtual void remove(){}; unsigned int nodeId() const; std::string getCategory() const; std::string getType() const; std::string getName() const; + bool isRemoving() const; void setType(const std::string& _type); void setName(const std::string& _name); @@ -95,7 +99,8 @@ inline NodeBase::NodeBase(const std::string& _category, const std::string& _type node_id_(++node_id_count_), node_category_(_category), node_type_(_type), - node_name_(_name) + node_name_(_name), + is_removing_(false) { // } @@ -120,6 +125,11 @@ inline std::string NodeBase::getName() const return node_name_; } +inline bool NodeBase::isRemoving() const +{ + return is_removing_; +} + inline void NodeBase::setType(const std::string& _type) { node_type_ = _type; diff --git a/src/sensor_base.cpp b/src/sensor_base.cpp index e16a01fb3..429aaf9f1 100644 --- a/src/sensor_base.cpp +++ b/src/sensor_base.cpp @@ -17,7 +17,6 @@ SensorBase::SensorBase(const std::string& _type, hardware_ptr_(), state_block_vec_(3), // allow for 3 state blocks by default. Resize in derived constructors if needed. calib_size_(0), - is_removing_(false), sensor_id_(++sensor_id_count_), // simple ID factory extrinsic_dynamic_(_extr_dyn), intrinsic_dynamic_(_intr_dyn), @@ -44,7 +43,6 @@ SensorBase::SensorBase(const std::string& _type, hardware_ptr_(), state_block_vec_(3), // allow for 3 state blocks by default. Resize in derived constructors if needed. calib_size_(0), - is_removing_(false), sensor_id_(++sensor_id_count_), // simple ID factory extrinsic_dynamic_(_extr_dyn), intrinsic_dynamic_(_intr_dyn), diff --git a/src/sensor_base.h b/src/sensor_base.h index 3c740bc88..b52e8816e 100644 --- a/src/sensor_base.h +++ b/src/sensor_base.h @@ -39,7 +39,6 @@ class SensorBase : public NodeBase, public std::enable_shared_from_this<SensorBa SizeEigen calib_size_; static unsigned int sensor_id_count_; ///< Object counter (acts as simple ID factory) - bool is_removing_; ///< A flag for safely removing nodes from the Wolf tree. See remove(). protected: unsigned int sensor_id_; // sensor ID @@ -91,7 +90,7 @@ class SensorBase : public NodeBase, public std::enable_shared_from_this<SensorBa const bool _intr_dyn = false); virtual ~SensorBase(); - void remove(); + virtual void remove(); unsigned int id(); -- GitLab