Skip to content
Snippets Groups Projects
Commit 0b8395f2 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Deprecated processor_capture_holder. Closes #243

parent d51252e5
No related branches found
No related tags found
No related merge requests found
...@@ -249,7 +249,6 @@ SET(HDRS_PROCESSOR ...@@ -249,7 +249,6 @@ SET(HDRS_PROCESSOR
include/core/processor/diff_drive_tools.hpp include/core/processor/diff_drive_tools.hpp
include/core/processor/motion_buffer.h include/core/processor/motion_buffer.h
include/core/processor/processor_base.h include/core/processor/processor_base.h
include/core/processor/processor_capture_holder.h
include/core/processor/processor_diff_drive.h include/core/processor/processor_diff_drive.h
include/core/processor/processor_factory.h include/core/processor/processor_factory.h
include/core/processor/processor_logging.h include/core/processor/processor_logging.h
...@@ -343,7 +342,6 @@ SET(SRCS_LANDMARK ...@@ -343,7 +342,6 @@ SET(SRCS_LANDMARK
SET(SRCS_PROCESSOR SET(SRCS_PROCESSOR
src/processor/motion_buffer.cpp src/processor/motion_buffer.cpp
src/processor/processor_base.cpp src/processor/processor_base.cpp
src/processor/processor_capture_holder.cpp
src/processor/processor_diff_drive.cpp src/processor/processor_diff_drive.cpp
src/processor/processor_loopclosure.cpp src/processor/processor_loopclosure.cpp
src/processor/processor_motion.cpp src/processor/processor_motion.cpp
......
/**
* \file processor_capture_holder.h
*
* Created on: Jul 12, 2017
* \author: Jeremie Deray
*/
#ifndef _WOLF_PROCESSOR_CAPTURE_HOLDER_H_
#define _WOLF_PROCESSOR_CAPTURE_HOLDER_H_
//Wolf includes
#include "core/processor/processor_base.h"
#include "core/capture/capture_base.h"
namespace wolf {
WOLF_PTR_TYPEDEFS(ProcessorCaptureHolder);
WOLF_STRUCT_PTR_TYPEDEFS(ProcessorParamsCaptureHolder);
/**
* \brief ProcessorParamsCaptureHolder
*/
struct ProcessorParamsCaptureHolder : public ProcessorParamsBase
{
using ProcessorParamsBase::ProcessorParamsBase;
};
/**
* \brief ProcessorCaptureHolder
*/
class ProcessorCaptureHolder : public ProcessorBase
{
public:
ProcessorCaptureHolder(ProcessorParamsCaptureHolderPtr _params_capture_holder);
virtual ~ProcessorCaptureHolder() = default;
virtual void configure(SensorBasePtr _sensor) override { };
protected:
/** \brief process an incoming capture
*
* The ProcessorCaptureHolder is only triggered in KF (see triggerInCapture()) so this function is not called.
*/
virtual void processCapture(CaptureBasePtr) override {};
/** \brief process an incoming key-frame
*
* Each derived processor should implement this function. It will be called if:
* - A new KF arrived and triggerInKF() returned true.
*/
virtual void processKeyFrame(FrameBasePtr _keyframe_ptr, const Scalar& _time_tolerance) override;
/** \brief trigger in capture
*
* The ProcessorCaptureHolder only processes incoming KF, then it returns false.
*/
virtual bool triggerInCapture(CaptureBasePtr) override {return false;}
/** \brief trigger in key-frame
*
* Returns true if processKeyFrame() should be called after the provided KF arrived.
*/
virtual bool triggerInKeyFrame(FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other) override { return true; }
/** \brief Vote for KeyFrame generation
*
* If a KeyFrame criterion is validated, this function returns true,
* meaning that it wants to create a KeyFrame at the \b last Capture.
*
* WARNING! This function only votes! It does not create KeyFrames!
*/
virtual bool voteForKeyFrame() override { return false; }
ProcessorParamsCaptureHolderPtr params_capture_holder_;
public:
static ProcessorBasePtr create(const std::string& _unique_name,
const ProcessorParamsBasePtr _params,
const SensorBasePtr sensor_ptr = nullptr);
};
} // namespace wolf
#endif // _WOLF_PROCESSOR_CAPTURE_HOLDER_H_
/**
* \file processor_capture_holder.h
*
* Created on: Jul 12, 2017
* \author: Jeremie Deray
*/
//Wolf includes
#include "core/processor/processor_capture_holder.h"
namespace wolf {
ProcessorCaptureHolder::ProcessorCaptureHolder(ProcessorParamsCaptureHolderPtr _params_capture_holder) :
ProcessorBase("CAPTURE HOLDER", _params_capture_holder),
params_capture_holder_(_params_capture_holder)
{
//
}
void ProcessorCaptureHolder::processKeyFrame(FrameBasePtr _keyframe_ptr, const Scalar& _time_tolerance)
{
assert(_keyframe_ptr->getTrajectory() != nullptr
&& "ProcessorMotion::keyFrameCallback: key frame must be in the trajectory.");
// get keyframe's time stamp
const TimeStamp new_ts = _keyframe_ptr->getTimeStamp();
// find capture whose buffer is affected by the new keyframe
CaptureBasePtr existing_capture = buffer_capture_.selectFirstBefore(new_ts, _time_tolerance);
buffer_capture_.removeUpTo(existing_capture->getTimeStamp());
if (existing_capture == nullptr)
{
WOLF_WARN("Could not find a capture at ts: ", new_ts.get(), " within time tolerance: ", _time_tolerance);
return;
}
WOLF_DEBUG("ProcessorCaptureHolder::keyFrameCallback time tolerance ", _time_tolerance);
WOLF_DEBUG("Capture of type : ", existing_capture->getType());
WOLF_DEBUG("CaptureBuffer size : ", buffer_capture_.size());
// add capture to keyframe
auto frame_ptr = existing_capture->getFrame();
if (frame_ptr != nullptr && frame_ptr->isKey())
{
WOLF_WARN_COND(frame_ptr != _keyframe_ptr, "found a capture already in a different KF");
WOLF_INFO_COND(frame_ptr == _keyframe_ptr, "found a capture already in a this KF");
}
else
{
WOLF_INFO("Adding capture laser !");
existing_capture->link(_keyframe_ptr);
if (frame_ptr)
frame_ptr->remove();
}
}
ProcessorBasePtr ProcessorCaptureHolder::create(const std::string& _unique_name,
const ProcessorParamsBasePtr _params,
const SensorBasePtr)
{
ProcessorParamsCaptureHolderPtr params;
params = std::static_pointer_cast<ProcessorParamsCaptureHolder>(_params);
// if cast failed use default value
if (params == nullptr)
params = std::make_shared<ProcessorParamsCaptureHolder>();
ProcessorCaptureHolderPtr prc_ptr = std::make_shared<ProcessorCaptureHolder>(params);
prc_ptr->setName(_unique_name);
return prc_ptr;
}
} // namespace wolf
// Register in the ProcessorFactory
#include "core/processor/processor_factory.h"
namespace wolf {
WOLF_REGISTER_PROCESSOR("CAPTURE HOLDER", ProcessorCaptureHolder)
} // namespace wolf
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment