diff --git a/src/capture_base.h b/src/capture_base.h index 06e8541bafb3eff92903e1b982c86dabdcc087f2..d705be3764535be62e13f5067867de4a2e7a29b0 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 9361d298fd53e9b4d307284f5ebdbca0f8f27e4e..630a856e7f9b1786b13b0d02fa5f3570d989e4b5 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 e888d2d67b08156f91a9882da3fdc9d9dd5111f7..00fdf888326cb1da7be91afca719d2ff3fd765d1 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);