diff --git a/include/core/common/params_base.h b/include/core/common/params_base.h index 4760d1cdd5185f6842297902ed335c039e673b4e..14b8dcb18cce99dc793e89f66281b04e7c07eb2e 100644 --- a/include/core/common/params_base.h +++ b/include/core/common/params_base.h @@ -23,6 +23,7 @@ #define PARAMS_BASE_H_ #include "core/utils/params_server.h" +#include "yaml-schema-cpp/yaml-schema-cpp.hpp" namespace wolf { struct ParamsBase @@ -32,6 +33,10 @@ namespace wolf { { // } + ParamsBase(const YAML::Node& _n) + { + // + } virtual ~ParamsBase() = default; virtual std::string print() const = 0; diff --git a/include/core/processor/factory_processor.h b/include/core/processor/factory_processor.h index 5abc327f4a61796829fba72117a797c0c028001f..c4918dea51cc9a233954827fa52979e12201dd64 100644 --- a/include/core/processor/factory_processor.h +++ b/include/core/processor/factory_processor.h @@ -152,6 +152,14 @@ inline std::string FactoryProcessorYaml::getClass() const return "FactoryProcessorYaml"; } +typedef Factory<ProcessorBase, + const YAML::Node&> FactoryProcessorYamlNode; +template<> +inline std::string FactoryProcessorYamlNode::getClass() const +{ + return "FactoryProcessorYamlNode"; +} + // ParamsProcessor factory struct ParamsProcessorBase; typedef Factory<ParamsProcessorBase, @@ -162,14 +170,15 @@ inline std::string FactoryParamsProcessor::getClass() const return "FactoryParamsProcessor"; } -#define WOLF_REGISTER_PROCESSOR(ProcessorType) \ - namespace{ const bool WOLF_UNUSED ProcessorType##ServerRegistered = \ - wolf::FactoryProcessorServer::registerCreator(#ProcessorType, ProcessorType::create); } \ - namespace{ const bool WOLF_UNUSED ProcessorType##Registered = \ - wolf::FactoryProcessor::registerCreator(#ProcessorType, ProcessorType::create); } \ - namespace{ const bool WOLF_UNUSED ProcessorType##YamlRegistered = \ - wolf::FactoryProcessorYaml::registerCreator(#ProcessorType, ProcessorType::create); } \ - +#define WOLF_REGISTER_PROCESSOR(ProcessorType) \ + namespace{ const bool WOLF_UNUSED ProcessorType##ServerRegistered = \ + wolf::FactoryProcessorServer::registerCreator(#ProcessorType, ProcessorType::create); } \ + namespace{ const bool WOLF_UNUSED ProcessorType##Registered = \ + wolf::FactoryProcessor::registerCreator(#ProcessorType, ProcessorType::create); } \ + namespace{ const bool WOLF_UNUSED ProcessorType##YamlRegistered = \ + wolf::FactoryProcessorYaml::registerCreator(#ProcessorType, ProcessorType::create); } \ + namespace{ const bool WOLF_UNUSED ProcessorType##YamlNodeRegistered = \ + wolf::FactoryProcessorYamlNode::registerCreator(#ProcessorType, ProcessorType::create); } \ } /* namespace wolf */ #endif /* PROCESSOR_FACTORY_H_ */ diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 931ab1bac3a8e6b381dd9d305091d5fb7939d792..3e529411d32fff7d9a2adc907b4c1e5eaffef88f 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -92,6 +92,16 @@ static ProcessorBasePtr create(const std::string& _unique_name, \ return processor; \ } \ +static ProcessorBasePtr create(const YAML::Node& _input_node) \ +{ \ + auto params = std::make_shared<ParamsProcessorClass>(_input_node); \ + \ + auto processor = std::make_shared<ProcessorClass>(params); \ + \ + processor ->setName(_unique_name); \ + \ + return processor; \ +} \ /** \brief Buffer for arbitrary type objects @@ -223,6 +233,13 @@ struct ParamsProcessorBase : public ParamsBase voting_active = _server.getParam<bool>(prefix + _unique_name + "/keyframe_vote/voting_active"); apply_loss_function = _server.getParam<bool>(prefix + _unique_name + "/apply_loss_function"); } + ParamsProcessorBase(const YAML::Node& _n): + ParamsBase(_n) + { + time_tolerance = _n["time_tolerance"].as<double>(); + voting_active = _n["keyframe_vote"]["voting_active"].as<bool>(); + apply_loss_function = _n["apply_loss_function"].as<bool>(); + } ~ParamsProcessorBase() override = default; diff --git a/include/core/processor/processor_diff_drive.h b/include/core/processor/processor_diff_drive.h index 20ed2330334aea821c7ca8bc6510f7438c555063..5e9b1012c8408f481fae04c1f4cb40e1dcfbbaba 100644 --- a/include/core/processor/processor_diff_drive.h +++ b/include/core/processor/processor_diff_drive.h @@ -43,6 +43,10 @@ struct ParamsProcessorDiffDrive : public ParamsProcessorOdom2d ParamsProcessorOdom2d(_unique_name, _server) { } + ParamsProcessorDiffDrive(const YAML::Node& _n) : + ParamsProcessorOdom2d(_n) + { + } std::string print() const override { return ParamsProcessorOdom2d::print(); diff --git a/include/core/processor/processor_fixed_wing_model.h b/include/core/processor/processor_fixed_wing_model.h index b882750a5c75d65c6e2efca0ff68926433156f08..607f2cf9d25c6b352edac0c69f4fa4b3cbb8dce9 100644 --- a/include/core/processor/processor_fixed_wing_model.h +++ b/include/core/processor/processor_fixed_wing_model.h @@ -52,6 +52,15 @@ struct ParamsProcessorFixedWingModel : public ParamsProcessorBase assert(std::abs(velocity_local.norm() - 1.0) < wolf::Constants::EPS && "ParamsProcessorFixedWingModel: 'velocity_local' must be normalized"); } + ParamsProcessorFixedWingModel(const YAML::Node & _n) : + ParamsProcessorBase(_n) + { + velocity_local = _n["velocity_local"].as<Eigen::Vector3d>(); + angle_stdev = _n["angle_stdev"].as<double>(); + min_vel_norm = _n["min_vel_norm"].as<double>(); + + assert(std::abs(velocity_local.norm() - 1.0) < wolf::Constants::EPS && "ParamsProcessorFixedWingModel: 'velocity_local' must be normalized"); + } std::string print() const override { return ParamsProcessorBase::print() + "\n" diff --git a/include/core/processor/processor_loop_closure.h b/include/core/processor/processor_loop_closure.h index cf602f451f52ebb725e98db2e2dd98467908e921..78e480fdd2eee35d426f18549acce013b1d246e5 100644 --- a/include/core/processor/processor_loop_closure.h +++ b/include/core/processor/processor_loop_closure.h @@ -39,6 +39,11 @@ struct ParamsProcessorLoopClosure : public ParamsProcessorBase { max_loops = _server.getParam<int>(prefix + _unique_name + "/max_loops"); } + ParamsProcessorLoopClosure(const YAML::Node& _n): + ParamsProcessorBase(_n) + { + max_loops = _n["max_loops"].as<int>(); + } std::string print() const override { diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h index 3e34bf694453a080cd79b307e43d0136bd4f68ea..be64fda51927defcaedfed31c7683a1be5b6f77f 100644 --- a/include/core/processor/processor_motion.h +++ b/include/core/processor/processor_motion.h @@ -63,6 +63,16 @@ struct ParamsProcessorMotion : public ParamsProcessorBase, public ParamsMotionPr angle_turned = _server.getParam<double>(prefix + _unique_name + "/keyframe_vote/angle_turned"); unmeasured_perturbation_std = _server.getParam<double>(prefix + _unique_name + "/unmeasured_perturbation_std"); } + ParamsProcessorMotion(const YAML::Node& _n): + ParamsProcessorBase(_n), + ParamsMotionProvider(_n) + { + max_time_span = _n["keyframe_vote"]["max_time_span"].as<double>(); + max_buff_length = _n["keyframe_vote"]["max_buff_length"].as<unsigned int>(); + dist_traveled = _n["keyframe_vote"]["dist_traveled"].as<double>(); + angle_turned = _n["keyframe_vote"]["angle_turned"].as<double>(); + unmeasured_perturbation_std = _n["unmeasured_perturbation_std"].as<double>(); + } std::string print() const override { return ParamsProcessorBase::print() + "\n" + diff --git a/src/landmark/landmark_base.cpp b/src/landmark/landmark_base.cpp index e7acd4f0d90ef0883eea1af949928b0458e25a44..921fe7896652ba7b3f3eec865136a6c6dda05237 100644 --- a/src/landmark/landmark_base.cpp +++ b/src/landmark/landmark_base.cpp @@ -27,7 +27,7 @@ #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" +// #include "core/yaml/yaml_conversion.h" namespace wolf { diff --git a/test/gtest_map_yaml.cpp b/test/gtest_map_yaml.cpp index 5c4b2b7893837316736ab7a69a49f1b08c169b9b..5f12596a9d39ae9d0da598b5f8eddf90613a9f71 100644 --- a/test/gtest_map_yaml.cpp +++ b/test/gtest_map_yaml.cpp @@ -34,7 +34,7 @@ #include "core/state_block/state_block.h" #include "core/state_block/state_quaternion.h" #include "core/state_block/local_parametrization_quaternion.h" -#include "core/yaml/yaml_conversion.h" +// #include "core/yaml/yaml_conversion.h" #include <iostream> using namespace wolf; diff --git a/test/gtest_yaml_conversions.cpp b/test/gtest_yaml_conversions.cpp index 21a4f89781b017807033f8c33d59dff716ec68ac..389aa92d80a48faa12b323df97a9385a7764a7ba 100644 --- a/test/gtest_yaml_conversions.cpp +++ b/test/gtest_yaml_conversions.cpp @@ -19,16 +19,11 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // //--------LICENSE_END-------- -/** - * \file test_yaml_conversions.cpp - * - * Created on: May 15, 2016 - * \author: jsola - */ #include "core/common/wolf.h" #include "core/utils/utils_gtest.h" -#include "core/yaml/yaml_conversion.h" +// #include "core/yaml/yaml_conversion.h" +#include <yaml-schema-cpp/yaml_conversion.h> #include <yaml-cpp/yaml.h> #include <eigen3/Eigen/Dense> #include <iostream>