From 1be38ec608be86bd0ddb8247ca0b79fc24f1c957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu> Date: Wed, 1 Apr 2020 02:00:51 +0200 Subject: [PATCH] Add API shortcuts to factors --- include/core/factor/factor_base.h | 8 ++++++++ src/factor/factor_base.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/core/factor/factor_base.h b/include/core/factor/factor_base.h index 16311a196..cd1439f96 100644 --- a/include/core/factor/factor_base.h +++ b/include/core/factor/factor_base.h @@ -144,6 +144,14 @@ class FactorBase : public NodeBase, public std::enable_shared_from_this<FactorBa **/ CaptureBasePtr getCapture() const; + /** \brief Returns a pointer to its frame + **/ + FrameBasePtr getFrame() const; + + /** \brief Returns a pointer to its capture's sensor + **/ + SensorBasePtr getSensor() const; + /** \brief Returns the factor residual size **/ virtual unsigned int getSize() const = 0; diff --git a/src/factor/factor_base.cpp b/src/factor/factor_base.cpp index 3b6b99fe8..72b36c519 100644 --- a/src/factor/factor_base.cpp +++ b/src/factor/factor_base.cpp @@ -155,6 +155,18 @@ CaptureBasePtr FactorBase::getCapture() const return getFeature()->getCapture(); } +FrameBasePtr FactorBase::getFrame() const +{ + assert(getCapture() != nullptr && "calling getFrame before linking with a capture"); + return getCapture()->getFrame(); +} + +SensorBasePtr FactorBase::getSensor() const +{ + assert(getCapture() != nullptr && "calling getSensor before linking with a capture"); + return getCapture()->getSensor(); +} + void FactorBase::setStatus(FactorStatus _status) { if (getProblem() == nullptr) -- GitLab