diff --git a/CMakeLists.txt b/CMakeLists.txt index d38ad4c78a6bd847c943ea362f77fadc06b7673a..eb55130b4c3687e278683c638d9ffde6288898c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -697,7 +697,7 @@ ADD_LIBRARY(${PROJECT_NAME} ${SRCS_WRAPPER} ${SRCS_YAML} ) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} dl) #Link the created libraries #============================================================= diff --git a/include/base/problem/problem.h b/include/base/problem/problem.h index 156077ec8048fe77e9ba10567969aa64a57ac82a..bfae71978ca916f52616d8f3af7c88160ca056c4 100644 --- a/include/base/problem/problem.h +++ b/include/base/problem/problem.h @@ -54,6 +54,7 @@ class Problem : public std::enable_shared_from_this<Problem> public: static ProblemPtr create(const std::string& _frame_structure); // USE THIS AS A CONSTRUCTOR! + static ProblemPtr autoSetup(const std::string& _frame_structure, const std::string& _yaml_file); virtual ~Problem(); // Properties ----------------------------------------- diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 301eb1a6d64cfd98371c9d7d6f0c098f9a3f87c7..0d9f055b259a1558822ded587872299feeb93a1a 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -11,6 +11,9 @@ #include "base/sensor/sensor_factory.h" #include "base/processor/processor_factory.h" #include "base/state_block/state_block.h" +#include "base/yaml/parser_yaml.hpp" +#include "base/utils/params_server.hpp" +#include "base/utils/loader.hpp" // IRI libs includes @@ -71,6 +74,37 @@ ProblemPtr Problem::create(const std::string& _frame_structure) p->setup(); return p->shared_from_this(); } +ProblemPtr Problem::autoSetup(const std::string& _frame_structure, const std::string& _yaml_file) +{ + auto p = Problem::create(_frame_structure); + // string file = "/home/jcasals/catkin_ws/src/wolf_ros_wrapper/src/params.yaml"; + parserYAML parser = parserYAML(_yaml_file); + parser.parse(); + paramsServer server = paramsServer(parser.getParams(), parser.sensorsSerialization(), parser.processorsSerialization()); + // cout << "PRINTING SERVER MAP" << endl; + // server.print(); + // cout << "-----------------------------------" << endl; + auto loaders = vector<Loader*>(); + for(auto it : parser.getFiles()) { + cout << "LOADING " << it << endl; + auto l = new LoaderRaw(it); + l->load(); + loaders.push_back(l); + } + //TODO: To be fixed. This prior should be set in here, but now it is set externally. + // setPrior(Eigen::Vector3s::Zero(), 0.1*Eigen::Matrix3s::Identity(), TimeStamp(), Scalar(0.1)); + auto sensorMap = map<string, SensorBasePtr>(); + auto procesorMap = map<string, ProcessorBasePtr>(); + for(auto s : server.getSensors()){ + cout << s._name << " " << s._type << endl; + sensorMap.insert(pair<string, SensorBasePtr>(s._name,p->installSensor(s._type, s._name, server))); + } + for(auto s : server.getProcessors()){ + cout << s._name << " " << s._type << " " << s._name_assoc_sensor << endl; + procesorMap.insert(pair<string, ProcessorBasePtr>(s._name,p->installProcessor(s._type, s._name, s._name_assoc_sensor, server))); + } + return p; +} Problem::~Problem() {