From 60f5743b7a8e6a6f815a121d71e5d28777812b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0=20Ortega?= <jsola@iri.upc.edu> Date: Tue, 22 Jan 2019 19:15:51 +0100 Subject: [PATCH] Feature/capture process --- src/capture_base.h | 10 ++++++++++ src/processor_tracker.cpp | 3 ++- src/test/gtest_capture_base.cpp | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/capture_base.h b/src/capture_base.h index 06e8541ba..d705be376 100644 --- a/src/capture_base.h +++ b/src/capture_base.h @@ -50,6 +50,8 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture // Type virtual bool isMotion() const { return false; } + bool process(); + unsigned int id(); TimeStamp getTimeStamp() const; void setTimeStamp(const TimeStamp& _ts); @@ -220,6 +222,14 @@ inline void CaptureBase::setTimeStampToNow() time_stamp_.setToNow(); } +inline bool CaptureBase::process() +{ + assert (getSensorPtr() != nullptr && "Attempting to process a capture with no associated sensor. Either set the capture's sensor or call sensor->process(capture) instead."); + + return getSensorPtr()->process(shared_from_this()); +} + + } // namespace wolf #endif diff --git a/src/processor_tracker.cpp b/src/processor_tracker.cpp index 9361d298f..630a856e7 100644 --- a/src/processor_tracker.cpp +++ b/src/processor_tracker.cpp @@ -61,8 +61,9 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr) pack->key_frame->addCapture(incoming_ptr_); // Process info + // TrackerFeature: We only process new features in Last, here last = nullptr, so we do not have anything to do. + // TrackerLandmark: If we have given a map, all landmarks in the map are know. Process them. processKnown(); - // We only process new features in Last, here last = nullptr, so we do not have anything to do. // Update pointers resetDerived(); diff --git a/src/test/gtest_capture_base.cpp b/src/test/gtest_capture_base.cpp index e888d2d67..00fdf8883 100644 --- a/src/test/gtest_capture_base.cpp +++ b/src/test/gtest_capture_base.cpp @@ -103,6 +103,15 @@ TEST(CaptureBase, addFeatureList) ASSERT_EQ(C->getFeatureList().back(), f_last); } +TEST(CaptureBase, process) +{ + SensorBasePtr S(std::make_shared<SensorBase>("DUMMY", nullptr, nullptr, nullptr, 2)); + CaptureBasePtr C(std::make_shared<CaptureBase>("DUMMY", 1.5, nullptr)); + ASSERT_DEATH({C->process();},""); // No sensor in the capture should fail + C->setSensorPtr(S); + ASSERT_TRUE(C->process()); // This should not fail (although it does nothing) +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); -- GitLab