From a16a55f80592ff08ac62f52db1c0bb3ca9b73fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0=20Ortega?= <jsola@iri.upc.edu> Date: Tue, 13 Aug 2019 15:31:03 +0200 Subject: [PATCH] Arrange factories --- include/core/common/factory.h | 38 ---------------------- include/core/processor/processor_factory.h | 11 +++++++ include/core/sensor/sensor_factory.h | 12 +++++++ src/landmark/landmark_base.cpp | 5 +-- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/include/core/common/factory.h b/include/core/common/factory.h index 8152d007c..4a760ddc0 100644 --- a/include/core/common/factory.h +++ b/include/core/common/factory.h @@ -314,26 +314,6 @@ namespace wolf // Some specializations //====================== -// Intrinsics -struct IntrinsicsBase; -typedef Factory<IntrinsicsBase, - const std::string&> IntrinsicsFactory; -template<> -inline std::string IntrinsicsFactory::getClass() -{ - return "IntrinsicsFactory"; -} - -// ProcessorParams -struct ProcessorParamsBase; -typedef Factory<ProcessorParamsBase, - const std::string&> ProcessorParamsFactory; -template<> -inline std::string ProcessorParamsFactory::getClass() -{ - return "ProcessorParamsFactory"; -} - // Landmarks from YAML class LandmarkBase; typedef Factory<LandmarkBase, @@ -344,20 +324,6 @@ inline std::string LandmarkFactory::getClass() return "LandmarkFactory"; } -// Frames -class TimeStamp; -} // namespace wolf -#include "core/frame/frame_base.h" -namespace wolf{ -typedef Factory<FrameBase, const FrameType&, const TimeStamp&, const Eigen::VectorXs&> FrameFactory; -template<> -inline std::string FrameFactory::getClass() -{ - return "FrameFactory"; -} - -//#define UNUSED(x) (void)x; -//#define UNUSED(x) (void)(sizeof((x), 0)); #ifdef __GNUC__ #define WOLF_UNUSED __attribute__((used)) @@ -372,10 +338,6 @@ inline std::string FrameFactory::getClass() # define UNUSED(x) x #endif -#define WOLF_REGISTER_FRAME(FrameType, FrameName) \ - namespace{ const bool WOLF_UNUSED FrameName##Registered = \ - wolf::FrameFactory::get().registerCreator(FrameType, FrameName::create); }\ - } /* namespace wolf */ #endif /* FACTORY_H_ */ diff --git a/include/core/processor/processor_factory.h b/include/core/processor/processor_factory.h index c5068dc0e..1f1d8606c 100644 --- a/include/core/processor/processor_factory.h +++ b/include/core/processor/processor_factory.h @@ -165,6 +165,17 @@ namespace wolf * You can also check the code in the example file ````src/examples/test_wolf_factories.cpp````. */ +// ProcessorParams factory +struct ProcessorParamsBase; +typedef Factory<ProcessorParamsBase, + const std::string&> ProcessorParamsFactory; +template<> +inline std::string ProcessorParamsFactory::getClass() +{ + return "ProcessorParamsFactory"; +} + +// Processor factory typedef Factory<ProcessorBase, const std::string&, const ProcessorParamsBasePtr> ProcessorFactory; diff --git a/include/core/sensor/sensor_factory.h b/include/core/sensor/sensor_factory.h index 1cd726227..3c74b0fd7 100644 --- a/include/core/sensor/sensor_factory.h +++ b/include/core/sensor/sensor_factory.h @@ -16,6 +16,7 @@ struct IntrinsicsBase; // wolf #include "core/common/factory.h" +#include "core/utils/params_server.hpp" namespace wolf { @@ -208,6 +209,17 @@ namespace wolf * You can also check the code in the example file ````src/examples/test_wolf_factories.cpp````. */ +// Intrinsics factory +struct IntrinsicsBase; +typedef Factory<IntrinsicsBase, + const std::string&> IntrinsicsFactory; +template<> +inline std::string IntrinsicsFactory::getClass() +{ + return "IntrinsicsFactory"; +} + +// Sensor factory typedef Factory<SensorBase, const std::string&, const Eigen::VectorXs&, const IntrinsicsBasePtr> SensorFactory; diff --git a/src/landmark/landmark_base.cpp b/src/landmark/landmark_base.cpp index 83712a918..5f245efc3 100644 --- a/src/landmark/landmark_base.cpp +++ b/src/landmark/landmark_base.cpp @@ -3,6 +3,7 @@ #include "core/factor/factor_base.h" #include "core/map/map_base.h" #include "core/state_block/state_block.h" +#include "core/state_block/state_angle.h" #include "core/state_block/state_quaternion.h" #include "core/common/factory.h" #include "core/yaml/yaml_conversion.h" @@ -217,7 +218,7 @@ LandmarkBasePtr LandmarkBase::create(const YAML::Node& _node) if (ori.size() == 4) ori_sb = std::make_shared<StateQuaternion>(ori, ori_fixed); else - ori_sb = std::make_shared<StateBlock>(ori, ori_fixed); + ori_sb = std::make_shared<StateAngle>(ori(0), ori_fixed); } LandmarkBasePtr lmk = std::make_shared<LandmarkBase>("BASE", pos_sb, ori_sb); @@ -229,7 +230,7 @@ LandmarkBasePtr LandmarkBase::create(const YAML::Node& _node) // Register landmark creator namespace { -const bool WOLF_UNUSED registered_lmk_ahp = LandmarkFactory::get().registerCreator("BASE", LandmarkBase::create); +const bool WOLF_UNUSED registered_lmk_base = LandmarkFactory::get().registerCreator("BASE", LandmarkBase::create); } } // namespace wolf -- GitLab