Skip to content
Snippets Groups Projects

Resolve "New ProcessorLoopClosure"

Merged Joan Vallvé Navarro requested to merge 398-new-processorloopclosure into devel
Files
9
+ 110
0
#ifndef _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H
#define _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H
// Wolf related headers
#include "core/processor/processor_base.h"
namespace wolf{
WOLF_STRUCT_PTR_TYPEDEFS(ParamsProcessorLoopClosure);
struct ParamsProcessorLoopClosure : public ParamsProcessorBase
{
int max_loops=-1;
ParamsProcessorLoopClosure() = default;
ParamsProcessorLoopClosure(std::string _unique_name, const ParamsServer& _server):
ParamsProcessorBase(_unique_name, _server)
{
max_loops = _server.getParam<int>(prefix + _unique_name + "/max_loops");
}
std::string print() const override
{
return "\n" + ParamsProcessorBase::print()
+ "max_loops: " + std::to_string(max_loops) + "\n";
}
};
WOLF_STRUCT_PTR_TYPEDEFS(MatchLoopClosure);
/** \brief Match between a capture and a capture
*
* Match between a capture and a capture (capture-capture correspondence)
*
*/
struct MatchLoopClosure
{
CaptureBasePtr capture_reference_ptr_; ///< Capture reference
CaptureBasePtr capture_target_ptr_; ///< Capture target
double normalized_score_; ///< normalized similarity score (0 is bad, 1 is good)
};
/** \brief General loop closure processor
*
* This is an abstract class.
* + You must define the following classes :
* - voteFindLoopClosures(CaptureBasePtr)
* - emplaceFeatures(CaptureBasePtr)
* - findLoopClosures(CaptureBasePtr)
* - validateLoop(CaptureBasePtr, CaptureBasePtr)
* - emplaceFactors(CaptureBasePtr, CaptureBasePtr)
* + You can override the following classes :
* - process(CaptureBasePtr)
*/
class ProcessorLoopClosure : public ProcessorBase
{
protected:
ParamsProcessorLoopClosurePtr params_loop_closure_;
public:
ProcessorLoopClosure(const std::string& _type, int _dim, ParamsProcessorLoopClosurePtr _params_loop_closure);
~ProcessorLoopClosure() override = default;
void configure(SensorBasePtr _sensor) override { };
protected:
/** \brief Process a capture (linked to a frame)
* If voteFindLoopClosures() returns true, findLoopClosures() is called.
* emplaceFactors() is called for pairs of current capture and each capture returned by findLoopClosures()
*/
virtual void process(CaptureBasePtr);
/** \brief Returns if findLoopClosures() has to be called for the given capture
*/
virtual bool voteFindLoopClosures(CaptureBasePtr cap) = 0;
/** \brief detects and emplaces all features of the given capture
*/
virtual void emplaceFeatures(CaptureBasePtr cap) = 0;
/** \brief Find captures that correspond to loop closures with the given capture
*/
virtual std::map<double,MatchLoopClosurePtr> findLoopClosures(CaptureBasePtr _capture) = 0;
/** \brief validates a loop closure
*/
virtual bool validateLoopClosure(MatchLoopClosurePtr) = 0;
/** \brief emplaces the factor(s) corresponding to a Loop Closure between two captures
*/
virtual void emplaceFactors(MatchLoopClosurePtr) = 0;
void processCapture(CaptureBasePtr) override;
void processKeyFrame(FrameBasePtr, const double&) override;
bool triggerInCapture(CaptureBasePtr _cap) const override { return true;};
bool triggerInKeyFrame(FrameBasePtr _frm, const double& _time_tol) const override { return true;};
bool storeKeyFrame(FrameBasePtr _frm) override { return false;};
bool storeCapture(CaptureBasePtr _cap) override { return false;};
bool voteForKeyFrame() const override { return false;};
};
} // namespace wolf
#endif /* _WOLF_PROCESSOR_LOOP_CLOSURE_BASE_H */
Loading