Skip to content
Snippets Groups Projects
Commit 532e9935 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Split parser_yaml.hpp -> {.h, .cpp}

parent 311517e8
No related branches found
No related tags found
No related merge requests found
...@@ -287,7 +287,7 @@ SET(HDRS_SOLVER ...@@ -287,7 +287,7 @@ SET(HDRS_SOLVER
) )
SET(HDRS_YAML SET(HDRS_YAML
include/core/yaml/parser_yaml.hpp include/core/yaml/parser_yaml.h
include/core/yaml/yaml_conversion.h include/core/yaml/yaml_conversion.h
) )
#SOURCES #SOURCES
...@@ -369,6 +369,7 @@ SET(SRCS_SOLVER ...@@ -369,6 +369,7 @@ SET(SRCS_SOLVER
src/solver/solver_manager.cpp src/solver/solver_manager.cpp
) )
SET(SRCS_YAML SET(SRCS_YAML
src/yaml/parser_yaml.cpp
src/yaml/processor_odom_3d_yaml.cpp src/yaml/processor_odom_3d_yaml.cpp
src/yaml/sensor_odom_2d_yaml.cpp src/yaml/sensor_odom_2d_yaml.cpp
src/yaml/sensor_odom_3d_yaml.cpp src/yaml/sensor_odom_3d_yaml.cpp
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// wolf core includes // wolf core includes
#include "core/common/wolf.h" #include "core/common/wolf.h"
#include "core/capture/capture_odom_2d.h" #include "core/capture/capture_odom_2d.h"
#include "core/yaml/parser_yaml.hpp" #include "core/yaml/parser_yaml.h"
#include "core/ceres_wrapper/ceres_manager.h" #include "core/ceres_wrapper/ceres_manager.h"
// hello wolf local includes // hello wolf local includes
......
#ifndef PARSER_YAML_H
#define PARSER_YAML_H
#include "core/utils/converter.h"
#include "core/common/wolf.h"
#include "yaml-cpp/yaml.h"
namespace wolf
{
class ParserYAML {
struct ParamsInitSensor{
std::string type_;
std::string name_;
std::string plugin_;
YAML::Node n_;
};
struct ParamsInitProcessor{
std::string type_;
std::string name_;
std::string name_assoc_sensor_;
std::string plugin_;
YAML::Node n_;
};
struct SubscriberManager{
std::string package_;
std::string subscriber_;
std::string topic_;
std::string sensor_name_;
YAML::Node n_;
};
struct PublisherManager{
std::string subscriber_;
std::string topic_;
std::string period_;
YAML::Node n_;
};
std::map<std::string, std::string> params_;
std::string active_name_;
std::vector<ParamsInitSensor> paramsSens_;
std::vector<ParamsInitProcessor> paramsProc_;
std::stack<std::string> parsing_file_;
std::string file_;
std::string path_root_;
std::vector<SubscriberManager> subscriber_managers_;
std::vector<PublisherManager> publisher_managers_;
YAML::Node problem;
std::string generatePath(std::string);
YAML::Node loadYAML(std::string);
void insert_register(std::string, std::string);
public:
ParserYAML(std::string _file, std::string _path_root = "",
bool _freely_parse = false);
~ParserYAML()
{
//
}
void parse_freely();
std::map<std::string, std::string> getParams();
private:
void walkTree(std::string _file);
void walkTree(std::string _file, std::vector<std::string>& _tags);
void walkTree(std::string _file, std::vector<std::string>& _tags, std::string _hdr);
/** @Brief Recursively walks the YAML tree while filling a map with the values parsed from the file
* @param YAML node to be parsed
* @param tags represents the path from the root of the YAML tree to the current node
* @param hdr is the name of the current YAML node
*/
void walkTreeR(YAML::Node _n, std::vector<std::string>& _tags, std::string _hdr);
void updateActiveName(std::string _tag);
/** @Brief Parse the sensors, processors, callbacks and files elements of the YAML file. We assume that these elements
are defined at the top level of the YAML file.
* @param file is the path to the YAML file */
void parseFirstLevel(std::string _file);
std::string tagsToString(std::vector<std::string>& _tags);
void parse();
};
}
#endif
This diff is collapsed.
This diff is collapsed.
#include "core/utils/utils_gtest.h" #include "core/utils/utils_gtest.h"
#include "core/utils/converter.h" #include "core/utils/converter.h"
#include "core/common/wolf.h" #include "core/common/wolf.h"
#include "core/yaml/parser_yaml.hpp" #include "core/yaml/parser_yaml.h"
#include "core/utils/params_server.hpp" #include "core/utils/params_server.hpp"
using namespace std; using namespace std;
......
#include "core/utils/utils_gtest.h" #include "core/utils/utils_gtest.h"
#include "core/utils/converter.h" #include "core/utils/converter.h"
#include "core/common/wolf.h" #include "core/common/wolf.h"
#include "core/yaml/parser_yaml.hpp" #include "core/yaml/parser_yaml.h"
using namespace std; using namespace std;
using namespace wolf; using namespace wolf;
......
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