Skip to content
Snippets Groups Projects
Commit af61bf40 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

added register and create macros and gtest_processor_base fixed

parent 7e5b0e32
No related branches found
No related tags found
No related merge requests found
Pipeline #5138 passed
......@@ -58,6 +58,7 @@ unsigned int ProcessorTrackerFeatureDummy::detectNewFeatures(const int& _max_new
FeatureBasePtrList& _features_out)
{
unsigned int max_features = _max_new_features;
WOLF_INFO("Detecting " , _max_new_features , " new features..." );
if (max_features == -1)
{
......@@ -70,7 +71,7 @@ unsigned int ProcessorTrackerFeatureDummy::detectNewFeatures(const int& _max_new
for (unsigned int i = 0; i < max_features; i++)
{
FeatureBasePtr ftr = FeatureBase::emplace<FeatureBase>(_capture,
"DUMMY FEATURE",
"FeatureDummy",
Eigen::Vector1d::Ones(),
Eigen::MatrixXd::Ones(1, 1));
_features_out.push_back(ftr);
......@@ -92,26 +93,11 @@ FactorBasePtr ProcessorTrackerFeatureDummy::emplaceFactor(FeatureBasePtr _featur
return FactorBase::emplace<FactorFeatureDummy>(_feature_ptr, _feature_ptr, _feature_other_ptr, shared_from_this());
}
ProcessorBasePtr ProcessorTrackerFeatureDummy::create(const std::string& _unique_name,
const ProcessorParamsBasePtr _params)
{
auto params = std::static_pointer_cast<ProcessorParamsTrackerFeatureDummy>(_params);
// if cast failed use default value
if (params == nullptr)
params = std::make_shared<ProcessorParamsTrackerFeatureDummy>();
auto prc_ptr = std::make_shared<ProcessorTrackerFeatureDummy>(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("ProcessorTrackerFeatureDummy", ProcessorTrackerFeatureDummy)
WOLF_REGISTER_PROCESSOR_AUTO("ProcessorTrackerFeatureDummy", ProcessorTrackerFeatureDummy)
} // namespace wolf
......@@ -39,6 +39,10 @@ class ProcessorTrackerFeatureDummy : public ProcessorTrackerFeature
public:
ProcessorTrackerFeatureDummy(ProcessorParamsTrackerFeatureDummyPtr _params_tracker_feature);
virtual ~ProcessorTrackerFeatureDummy();
// Factory method for high level API
WOLF_PROCESSOR_CREATE(ProcessorTrackerFeatureDummy, ProcessorParamsTrackerFeatureDummy);
virtual void configure(SensorBasePtr _sensor) { };
protected:
......@@ -101,12 +105,6 @@ class ProcessorTrackerFeatureDummy : public ProcessorTrackerFeature
* This function emplaces a factor of the appropriate type for the derived processor.
*/
virtual FactorBasePtr emplaceFactor(FeatureBasePtr _feature_ptr, FeatureBasePtr _feature_other_ptr);
public:
static ProcessorBasePtr create(const std::string& _unique_name,
const ProcessorParamsBasePtr _params);
};
inline ProcessorTrackerFeatureDummy::ProcessorTrackerFeatureDummy(ProcessorParamsTrackerFeatureDummyPtr _params_tracker_feature_dummy) :
......
......@@ -112,4 +112,12 @@ FactorBasePtr ProcessorTrackerLandmarkDummy::emplaceFactor(FeatureBasePtr _featu
return FactorBase::emplace<FactorLandmarkDummy>(_feature_ptr, _feature_ptr, _landmark_ptr, shared_from_this());
}
} //namespace wolf
} // namespace wolf
// Register in the ProcessorFactory
#include "core/processor/processor_factory.h"
namespace wolf {
WOLF_REGISTER_PROCESSOR("ProcessorTrackerLandmarkDummy", ProcessorTrackerLandmarkDummy)
WOLF_REGISTER_PROCESSOR_AUTO("ProcessorTrackerLandmarkDummy", ProcessorTrackerLandmarkDummy)
} // namespace wolf
......@@ -34,6 +34,10 @@ class ProcessorTrackerLandmarkDummy : public ProcessorTrackerLandmark
public:
ProcessorTrackerLandmarkDummy(ProcessorParamsTrackerLandmarkDummyPtr _params_tracker_landmark_dummy);
virtual ~ProcessorTrackerLandmarkDummy();
// Factory method for high level API
WOLF_PROCESSOR_CREATE(ProcessorTrackerLandmarkDummy, ProcessorParamsTrackerLandmarkDummy);
virtual void configure(SensorBasePtr _sensor) { };
protected:
......
......@@ -23,14 +23,6 @@
using namespace wolf;
using namespace Eigen;
// Register in the ProcessorFactory
#include "core/processor/processor_factory.h"
namespace wolf {
WOLF_REGISTER_PROCESSOR("TRACKER FEATURE DUMMY", ProcessorTrackerFeatureDummy)
} // namespace wolf
TEST(ProcessorBase, IsMotion)
{
using namespace wolf;
......@@ -84,11 +76,13 @@ TEST(ProcessorBase, KeyFrameCallback)
// Install tracker (sensor and processor)
auto sens_trk = SensorBase::emplace<SensorBase>(problem->getHardware(),
"SensorOdom2d",
"SensorTrackerDummy",
std::make_shared<StateBlock>(Eigen::VectorXd::Zero(2)),
std::make_shared<StateBlock>(Eigen::VectorXd::Zero(1)),
std::make_shared<StateBlock>(Eigen::VectorXd::Zero(2)), 2);
auto proc_trk = problem->installProcessor("ProcessorTrackerFeatureDummy", "dummy", sens_trk);
auto proc_trk_params = make_shared<ProcessorParamsTrackerFeatureDummy>();
proc_trk_params->time_tolerance = dt/2;
auto proc_trk = problem->installProcessor("ProcessorTrackerFeatureDummy", "dummy", sens_trk, proc_trk_params);
// Install odometer (sensor and processor)
SensorBasePtr sens_odo = problem->installSensor("SensorOdom2d", "odometer", Vector3d(0,0,0), wolf_root + "/test/yaml/sensor_odom_2d.yaml");
......
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