From 561a466de94ab2f7a7785789aa92a368d2fb283f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu> Date: Wed, 1 Aug 2018 15:31:35 +0200 Subject: [PATCH] ProcessorMotion::getState() returning bool instead of throwing exception --- src/problem.cpp | 6 ++---- src/processor_motion.cpp | 5 +++-- src/processor_motion.h | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/problem.cpp b/src/problem.cpp index 7dbe0b736..5e646aef1 100644 --- a/src/problem.cpp +++ b/src/problem.cpp @@ -286,10 +286,8 @@ void Problem::getState(const TimeStamp& _ts, Eigen::VectorXs& state) { assert(state.size() == getFrameStructureSize() && "Problem::getStateAtTimeStamp: bad state size"); - if (processor_motion_ptr_ != nullptr) - processor_motion_ptr_->getState(_ts, state); - - else + // try to get the state from processor_motion if any, otherwise... + if (processor_motion_ptr_ == nullptr || !processor_motion_ptr_->getState(_ts, state)) { FrameBasePtr closest_frame = trajectory_ptr_->closestKeyFrameToTimeStamp(_ts); if (closest_frame != nullptr) diff --git a/src/processor_motion.cpp b/src/processor_motion.cpp index a89aa763c..d15a942a7 100644 --- a/src/processor_motion.cpp +++ b/src/processor_motion.cpp @@ -257,7 +257,7 @@ void ProcessorMotion::process(CaptureBasePtr _incoming_ptr) } -void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x) +bool ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x) { CaptureMotionPtr capture_motion; if (origin_ptr_ && _ts >= origin_ptr_->getTimeStamp()) @@ -291,8 +291,9 @@ void ProcessorMotion::getState(const TimeStamp& _ts, Eigen::VectorXs& _x) // We could not find any CaptureMotion for the time stamp requested WOLF_ERROR("Could not find any Capture for the time stamp requested. "); WOLF_TRACE("Did you forget to call Problem::setPrior() in your application?") - throw std::runtime_error("Could not find any Capture for the time stamp requested. Did you forget to call Problem::setPrior() in your application?"); + return false; } + return true; } //CaptureMotionPtr ProcessorMotion::findCaptureContainingTimeStamp(const TimeStamp& _ts) const diff --git a/src/processor_motion.h b/src/processor_motion.h index a93a4bfb6..7087ef593 100644 --- a/src/processor_motion.h +++ b/src/processor_motion.h @@ -157,8 +157,9 @@ class ProcessorMotion : public ProcessorBase /** \brief Fill the state corresponding to the provided time-stamp * \param _ts the time stamp * \param _x the returned state + * \return if state in the provided time-stamp could be resolved */ - void getState(const TimeStamp& _ts, Eigen::VectorXs& _x); + bool getState(const TimeStamp& _ts, Eigen::VectorXs& _x); /** \brief Get the state corresponding to the provided time-stamp * \param _ts the time stamp -- GitLab