diff --git a/hello_wolf/sensor_range_bearing.h b/hello_wolf/sensor_range_bearing.h index 2e9bcf214d0ea586a6cf3466846ed41ef50f3096..7f39233a521c760402e576ae51e9259d74e2b1d6 100644 --- a/hello_wolf/sensor_range_bearing.h +++ b/hello_wolf/sensor_range_bearing.h @@ -26,8 +26,8 @@ struct IntrinsicsRangeBearing : public IntrinsicsBase IntrinsicsRangeBearing(std::string _unique_name, const ParamsServer& _server): IntrinsicsBase(_unique_name, _server) { - noise_range_metres_std = _server.getParam<Scalar>(_unique_name + "/noise_range_metres_std"); - noise_bearing_degrees_std = _server.getParam<Scalar>(_unique_name + "/noise_bearing_degrees_std"); + noise_range_metres_std = _server.getParam<Scalar>(prefix + _unique_name + "/noise_range_metres_std"); + noise_bearing_degrees_std = _server.getParam<Scalar>(prefix + _unique_name + "/noise_bearing_degrees_std"); } std::string print() const { diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 3e7ecea8b12b5a32e55403d50445c60a9bd687d6..7273ad18f63f89ce071f2473fb956c9fb8722af2 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -204,13 +204,14 @@ class BufferCapture : public Buffer<CaptureBasePtr> {}; */ struct ProcessorParamsBase : public ParamsBase { + std::string prefix = "processor/"; ProcessorParamsBase() = default; ProcessorParamsBase(std::string _unique_name, const ParamsServer& _server): ParamsBase(_unique_name, _server) { - time_tolerance = _server.getParam<Scalar>(_unique_name + "/time_tolerance"); - voting_active = _server.getParam<bool>(_unique_name + "/keyframe_vote/voting_active"); - voting_aux_active = _server.getParam<bool>(_unique_name + "/keyframe_vote/voting_aux_active"); + time_tolerance = _server.getParam<Scalar>(prefix + _unique_name + "/time_tolerance"); + voting_active = _server.getParam<bool>(prefix + _unique_name + "/keyframe_vote/voting_active"); + voting_aux_active = _server.getParam<bool>(prefix + _unique_name + "/keyframe_vote/voting_aux_active"); } virtual ~ProcessorParamsBase() = default; diff --git a/include/core/processor/processor_motion.h b/include/core/processor/processor_motion.h index 467f0c6a7970823699c907fb64afc80f654366a7..a1aa0a3d388c3a916682cbb012f2bc0049703c61 100644 --- a/include/core/processor/processor_motion.h +++ b/include/core/processor/processor_motion.h @@ -34,11 +34,11 @@ struct ProcessorParamsMotion : public ProcessorParamsBase ProcessorParamsMotion(std::string _unique_name, const ParamsServer& _server): ProcessorParamsBase(_unique_name, _server) { - max_time_span = _server.getParam<Scalar>(_unique_name + "/keyframe_vote/max_time_span"); - max_buff_length = _server.getParam<unsigned int>(_unique_name + "/keyframe_vote/max_buff_length"); - dist_traveled = _server.getParam<Scalar>(_unique_name + "/keyframe_vote/dist_traveled"); - angle_turned = _server.getParam<Scalar>(_unique_name + "/keyframe_vote/angle_turned"); - unmeasured_perturbation_std = _server.getParam<Scalar>(_unique_name + "/unmeasured_perturbation_std"); + max_time_span = _server.getParam<Scalar>(prefix + _unique_name + "/keyframe_vote/max_time_span"); + max_buff_length = _server.getParam<unsigned int>(prefix + _unique_name + "/keyframe_vote/max_buff_length"); + dist_traveled = _server.getParam<Scalar>(prefix + _unique_name + "/keyframe_vote/dist_traveled"); + angle_turned = _server.getParam<Scalar>(prefix + _unique_name + "/keyframe_vote/angle_turned"); + unmeasured_perturbation_std = _server.getParam<Scalar>(prefix + _unique_name + "/unmeasured_perturbation_std"); } std::string print() const { diff --git a/include/core/processor/processor_odom_2D.h b/include/core/processor/processor_odom_2D.h index 3de67b9a26f89976b6ef109c880516add6af27f5..f4c16e020a823a0dfcc25b4e202a393816316e00 100644 --- a/include/core/processor/processor_odom_2D.h +++ b/include/core/processor/processor_odom_2D.h @@ -27,7 +27,7 @@ struct ProcessorParamsOdom2D : public ProcessorParamsMotion ProcessorParamsOdom2D(std::string _unique_name, const wolf::ParamsServer & _server) : ProcessorParamsMotion(_unique_name, _server) { - cov_det = _server.getParam<Scalar>(_unique_name + "/keyframe_vote/cov_det"); + cov_det = _server.getParam<Scalar>(prefix + _unique_name + "/keyframe_vote/cov_det"); } std::string print() const diff --git a/include/core/processor/processor_tracker.h b/include/core/processor/processor_tracker.h index 8ad0a75bfeb983c0bb0b463281219a08cca9f5b2..b3adee2498da0324cffa332d73066d2a7d1fca3b 100644 --- a/include/core/processor/processor_tracker.h +++ b/include/core/processor/processor_tracker.h @@ -24,8 +24,8 @@ struct ProcessorParamsTracker : public ProcessorParamsBase ProcessorParamsTracker(std::string _unique_name, const wolf::ParamsServer & _server): ProcessorParamsBase(_unique_name, _server) { - min_features_for_keyframe = _server.getParam<unsigned int>(_unique_name + "/min_features_for_keyframe"); - max_new_features = _server.getParam<int>(_unique_name + "/max_new_features"); + min_features_for_keyframe = _server.getParam<unsigned int>(prefix + _unique_name + "/min_features_for_keyframe"); + max_new_features = _server.getParam<int>(prefix + _unique_name + "/max_new_features"); } std::string print() const { @@ -103,6 +103,7 @@ class ProcessorTracker : public ProcessorBase CaptureBasePtr incoming_ptr_; ///< Pointer to the incoming capture being processed. FeatureBasePtrList new_features_last_; ///< List of new features in \b last for landmark initialization and new key-frame creation. FeatureBasePtrList new_features_incoming_; ///< list of the new features of \b last successfully tracked in \b incoming + FeatureBasePtrList known_features_incoming_; ///< list of the known features in \b last successfully tracked in \b incoming public: ProcessorTracker(const std::string& _type, diff --git a/include/core/processor/processor_tracker_feature.h b/include/core/processor/processor_tracker_feature.h index 32da47d13e3fc0393fb7b8b95098d4f6db0751f0..f05fb89762d6efef528c100502523b41a869af9f 100644 --- a/include/core/processor/processor_tracker_feature.h +++ b/include/core/processor/processor_tracker_feature.h @@ -92,7 +92,6 @@ class ProcessorTrackerFeature : public ProcessorTracker ProcessorParamsTrackerFeaturePtr params_tracker_feature_; TrackMatrix track_matrix_; - FeatureBasePtrList known_features_incoming_; FeatureMatchMap matches_last_from_incoming_; /** \brief Process known Features diff --git a/include/core/sensor/sensor_base.h b/include/core/sensor/sensor_base.h index 9e39b4c290b6c4d0bf9461bf34cd0a7b723a6452..6393a71aa3c9a83facec9d9166a48f04ebf01b0e 100644 --- a/include/core/sensor/sensor_base.h +++ b/include/core/sensor/sensor_base.h @@ -36,7 +36,7 @@ namespace wolf { static \ SensorBasePtr create(const std::string& _unique_name, const ParamsServer& _server) \ { \ - Eigen::VectorXs extrinsics = _server.template getParam<Eigen::VectorXs>(_unique_name + "/extrinsic/pose"); \ + Eigen::VectorXs extrinsics = _server.template getParam<Eigen::VectorXs>("sensor/" + _unique_name + "/extrinsic/pose"); \ \ assert(extrinsics.size() == ExtrinsicsSize && "Bad extrinsics vector length."); \ \ @@ -72,6 +72,7 @@ SensorBasePtr create(const std::string& _unique_name, const Eigen::VectorXs& _ex */ struct IntrinsicsBase: public ParamsBase { + std::string prefix = "sensor/"; virtual ~IntrinsicsBase() = default; using ParamsBase::ParamsBase; std::string print() const diff --git a/include/core/sensor/sensor_diff_drive.h b/include/core/sensor/sensor_diff_drive.h index 47b0b7886ee9a123e39a5b8cb90576d8a2562ea6..9bb434a33ad11283b4fe31ae60330e23cf809749 100644 --- a/include/core/sensor/sensor_diff_drive.h +++ b/include/core/sensor/sensor_diff_drive.h @@ -27,10 +27,10 @@ struct IntrinsicsDiffDrive : public IntrinsicsBase IntrinsicsDiffDrive(std::string _unique_name, const wolf::ParamsServer & _server) : IntrinsicsBase(_unique_name, _server) { - radius_left = _server.getParam<Scalar>(_unique_name + "/radius_left"); - radius_right = _server.getParam<Scalar>(_unique_name + "/radius_right"); - wheel_separation = _server.getParam<Scalar>(_unique_name + "/wheel_separation"); - ticks_per_wheel_revolution = _server.getParam<Scalar>(_unique_name + "/ticks_per_wheel_revolution"); + radius_left = _server.getParam<Scalar>(prefix + _unique_name + "/radius_left"); + radius_right = _server.getParam<Scalar>(prefix + _unique_name + "/radius_right"); + wheel_separation = _server.getParam<Scalar>(prefix + _unique_name + "/wheel_separation"); + ticks_per_wheel_revolution = _server.getParam<Scalar>(prefix + _unique_name + "/ticks_per_wheel_revolution"); } std::string print() const { diff --git a/include/core/sensor/sensor_odom_2D.h b/include/core/sensor/sensor_odom_2D.h index 463a9c3d95053f3753c3b59b2769cfb669b9a0e7..9d7c51985cadd8acba19308546f9a7bc05ddb40e 100644 --- a/include/core/sensor/sensor_odom_2D.h +++ b/include/core/sensor/sensor_odom_2D.h @@ -22,8 +22,8 @@ struct IntrinsicsOdom2D : public IntrinsicsBase IntrinsicsOdom2D(std::string _unique_name, const ParamsServer& _server): IntrinsicsBase(_unique_name, _server) { - k_disp_to_disp = _server.getParam<Scalar>(_unique_name + "/k_disp_to_disp"); - k_rot_to_rot = _server.getParam<Scalar>(_unique_name + "/k_rot_to_rot"); + k_disp_to_disp = _server.getParam<Scalar>(prefix + _unique_name + "/k_disp_to_disp"); + k_rot_to_rot = _server.getParam<Scalar>(prefix + _unique_name + "/k_rot_to_rot"); } std::string print() const { diff --git a/include/core/sensor/sensor_odom_3D.h b/include/core/sensor/sensor_odom_3D.h index 3e141b93916455d280990d2aed3d27d54d156835..65e89d672f086633423ebfeafefe856272123fd6 100644 --- a/include/core/sensor/sensor_odom_3D.h +++ b/include/core/sensor/sensor_odom_3D.h @@ -30,11 +30,11 @@ struct IntrinsicsOdom3D : public IntrinsicsBase IntrinsicsOdom3D(std::string _unique_name, const ParamsServer& _server): IntrinsicsBase(_unique_name, _server) { - k_disp_to_disp = _server.getParam<Scalar>(_unique_name + "/k_disp_to_disp"); - k_disp_to_rot = _server.getParam<Scalar>(_unique_name + "/k_disp_to_rot"); - k_rot_to_rot = _server.getParam<Scalar>(_unique_name + "/k_rot_to_rot"); - min_disp_var = _server.getParam<Scalar>(_unique_name + "/min_disp_var"); - min_rot_var = _server.getParam<Scalar>(_unique_name + "/min_rot_var"); + k_disp_to_disp = _server.getParam<Scalar>(prefix + _unique_name + "/k_disp_to_disp"); + k_disp_to_rot = _server.getParam<Scalar>(prefix + _unique_name + "/k_disp_to_rot"); + k_rot_to_rot = _server.getParam<Scalar>(prefix + _unique_name + "/k_rot_to_rot"); + min_disp_var = _server.getParam<Scalar>(prefix + _unique_name + "/min_disp_var"); + min_rot_var = _server.getParam<Scalar>(prefix + _unique_name + "/min_rot_var"); } std::string print() const { diff --git a/include/core/yaml/parser_yaml.hpp b/include/core/yaml/parser_yaml.hpp index 643d5d1fdbdc25246001d3c041aa3f49c06b8d2c..c661e078a8306acf63b98425f642460ec522dc77 100644 --- a/include/core/yaml/parser_yaml.hpp +++ b/include/core/yaml/parser_yaml.hpp @@ -189,6 +189,7 @@ class ParserYAML { YAML::Node problem; std::string generatePath(std::string); YAML::Node loadYAML(std::string); + void insert_register(std::string, std::string); public: ParserYAML(){ _params = std::map<std::string, std::string>(); @@ -310,13 +311,15 @@ void ParserYAML::walkTreeR(YAML::Node n, std::vector<std::string>& tags, std::st std::string str = n.Scalar(); walkTree(str.substr(1,str.size() - 1), tags, hdr); }else{ - _params.insert(std::pair<std::string,std::string>(hdr, n.Scalar())); + insert_register(hdr, n.Scalar()); + // _params.insert(std::pair<std::string,std::string>); } break; } case YAML::NodeType::Sequence : { if(isAtomic("", n)){ - _params.insert(std::pair<std::string,std::string>(hdr, parseAtomicNode(n))); + insert_register(hdr, parseAtomicNode(n)); + // _params.insert(std::pair<std::string,std::string>); }else{ for(const auto& kv : n){ walkTreeR(kv, tags, hdr); @@ -330,7 +333,8 @@ void ParserYAML::walkTreeR(YAML::Node n, std::vector<std::string>& tags, std::st std::string key = kv.first.as<std::string>(); //WOLF_DEBUG("KEY IN MAP ATOMIC ", hdr + "/" + key); key = key.substr(1,key.size() - 1); - _params.insert(std::pair<std::string,std::string>(hdr + "/" + key, parseAtomicNode(kv.second))); + insert_register(hdr + "/" + key, parseAtomicNode(kv.second)); + // _params.insert(std::pair<std::string,std::string>); }else{ /* If key=="follow" then the parser will assume that the value is a path and will parse @@ -413,7 +417,8 @@ void ParserYAML::parseFirstLevel(std::string file){ for(const auto& kv : n_files){ _files.push_back(kv.Scalar()); } - _params.insert(std::pair<std::string,std::string>("files", wolf::converter<std::string>::convert(_files))); + insert_register("files", wolf::converter<std::string>::convert(_files)); + // _params.insert(std::pair<std::string,std::string>); } std::vector<std::array<std::string, 2>> ParserYAML::sensorsSerialization(){ std::vector<std::array<std::string, 2>> aux = std::vector<std::array<std::string, 2>>(); @@ -450,11 +455,13 @@ void ParserYAML::parse(){ } for(auto it : _paramsSens){ std::vector<std::string> tags = std::vector<std::string>(); - this->walkTreeR(it.n , tags , it._name); + tags.push_back("sensor"); + this->walkTreeR(it.n , tags , "sensor/" + it._name); } for(auto it : _paramsProc){ std::vector<std::string> tags = std::vector<std::string>(); - this->walkTreeR(it.n , tags , it._name); + tags.push_back("processor"); + this->walkTreeR(it.n , tags , "processor/" + it._name); } this->_parsing_file.pop(); } @@ -464,4 +471,9 @@ void ParserYAML::parse_freely(){ this->walkTreeR(loadYAML(this->_file), tags, ""); this->_parsing_file.pop(); } +void ParserYAML::insert_register(std::string key, std::string value){ + // _params.insert(std::pair<std::string,std::string>); + auto inserted_it = _params.insert(std::pair<std::string, std::string>(key, value)); + if(not inserted_it.second) WOLF_WARN("Skipping key '", key, "' with value '", value, "'. There already exists the register: (", inserted_it.first->first, ",", inserted_it.first->second, ")"); +} #endif diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 364808ae965963ca2e9d547f55bbab8113dda235..687a1565cd331827268c2cbd5eeb683944363a3b 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -199,7 +199,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // { SensorBasePtr sen_ptr = getSensor(_corresponding_sensor_name); if (sen_ptr == nullptr) - throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, in must match in sensor and processor!"); + throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); if (_params_filename == "") return installProcessor(_prc_type, _unique_processor_name, sen_ptr, nullptr); else @@ -217,7 +217,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // { SensorBasePtr sen_ptr = getSensor(_corresponding_sensor_name); if (sen_ptr == nullptr) - throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, in must match in sensor and processor!"); + throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); ProcessorBasePtr prc_ptr = AutoConfProcessorFactory::get().create(uppercase(_prc_type), _unique_processor_name, _server); prc_ptr->configure(sen_ptr); diff --git a/src/processor/processor_tracker_feature.cpp b/src/processor/processor_tracker_feature.cpp index 0dd6f17498447836bf86a0f264c262db04dff739..d6ce9c065e8c0611f6e1190acf1fe4555d83cdf6 100644 --- a/src/processor/processor_tracker_feature.cpp +++ b/src/processor/processor_tracker_feature.cpp @@ -36,18 +36,23 @@ unsigned int ProcessorTrackerFeature::processNew(const int& _max_new_features) matches_last_from_incoming_.clear(); // Populate the last Capture with new Features. The result is in new_features_last_. - unsigned int n = detectNewFeatures(_max_new_features, last_ptr_, new_features_last_); + unsigned int n = detectNewFeatures(_max_new_features, + last_ptr_, + new_features_last_); // check all features have been emplaced assert(std::all_of(new_features_last_.begin(), new_features_last_.end(), [](FeatureBasePtr f){return f->getCapture() != nullptr;}) && - "any not linked feature returned by detectNewFeatures()"); + "some features not linked after returning from detectNewFeatures()"); // fill the track matrix for (auto ftr : new_features_last_) track_matrix_.newTrack(ftr); // Track new features from last to incoming. This will append new correspondences to matches_last_incoming - trackFeatures(new_features_last_, incoming_ptr_, new_features_incoming_, matches_last_from_incoming_); + trackFeatures(new_features_last_, + incoming_ptr_, + new_features_incoming_, + matches_last_from_incoming_); // check all features have been emplaced assert(std::all_of(new_features_incoming_.begin(), new_features_incoming_.end(), [](FeatureBasePtr f){return f->getCapture() != nullptr;}) && @@ -68,15 +73,14 @@ unsigned int ProcessorTrackerFeature::processKnown() { assert(incoming_ptr_->getFeatureList().size() == 0 && "In ProcessorTrackerFeature::processKnown(): incoming_ptr_ feature list must be empty before processKnown()"); - assert(matches_last_from_incoming_.size() == 0 - && "In ProcessorTrackerFeature::processKnown(): match list from last to incoming must be empty before processKnown()"); // clear list of known features + matches_last_from_incoming_.clear(); known_features_incoming_.clear(); if (!last_ptr_ || last_ptr_->getFeatureList().empty()) { - WOLF_DEBUG("empty last feature list, returning..."); + WOLF_TRACE("Empty last feature list, returning..."); return 0; } @@ -109,10 +113,10 @@ unsigned int ProcessorTrackerFeature::processKnown() if (!correctFeatureDrift(feature_in_origin, feature_in_last, (*ftr_inc_it))) { // Remove this feature from many places: - assert(matches_last_from_incoming_.count(*ftr_inc_it)); + assert(matches_last_from_incoming_ .count(*ftr_inc_it)); matches_last_from_incoming_ .erase (*ftr_inc_it); // remove match track_matrix_ .remove(*ftr_inc_it); // remove from track matrix - (*ftr_inc_it)-> remove(); // remove from wolf tree + (*ftr_inc_it) ->remove(); // remove from wolf tree ftr_inc_it = known_features_incoming_.erase(ftr_inc_it); // remove from known features list } else diff --git a/src/processor/processor_tracker_landmark.cpp b/src/processor/processor_tracker_landmark.cpp index 0d7c50c2a9e6ac8a3e91009a1ed361251a4104aa..76514fb7dc00451036013373a6aa26f5f6a4b93f 100644 --- a/src/processor/processor_tracker_landmark.cpp +++ b/src/processor/processor_tracker_landmark.cpp @@ -48,17 +48,17 @@ void ProcessorTrackerLandmark::resetDerived() unsigned int ProcessorTrackerLandmark::processKnown() { - assert(matches_landmark_from_incoming_.empty()); + matches_landmark_from_incoming_.clear(); + known_features_incoming_.clear(); // Find landmarks in incoming_ptr_ - FeatureBasePtrList known_features_list_incoming; unsigned int n = findLandmarks(getProblem()->getMap()->getLandmarkList(), incoming_ptr_, - known_features_list_incoming, + known_features_incoming_, matches_landmark_from_incoming_); // check all features have been emplaced - assert(std::all_of(known_features_list_incoming.begin(), known_features_list_incoming.end(), [](FeatureBasePtr f){return f->getCapture() != nullptr;}) && + assert(std::all_of(known_features_incoming_.begin(), known_features_incoming_.end(), [](FeatureBasePtr f){return f->getCapture() != nullptr;}) && "any not linked feature returned by findLandmarks()"); return n; @@ -100,7 +100,7 @@ unsigned int ProcessorTrackerLandmark::processNew(const int& _max_features) // check all features have been emplaced assert(std::all_of(new_features_incoming_.begin(), new_features_incoming_.end(), [](FeatureBasePtr f){return f->getCapture() != nullptr;}) && - "any not linked feature returned by findLandmarks()"); + "some features not linked after returning from detectNewFeatures()"); } // return the number of new features detected in \b last diff --git a/test/dummy/processor_tracker_feature_dummy.h b/test/dummy/processor_tracker_feature_dummy.h index 0590d45758707561cfc86b879b1943011e77ed73..b4fdb44a79f6d5053e258379e1eadc8811cbfae7 100644 --- a/test/dummy/processor_tracker_feature_dummy.h +++ b/test/dummy/processor_tracker_feature_dummy.h @@ -25,7 +25,7 @@ struct ProcessorParamsTrackerFeatureDummy : public ProcessorParamsTrackerFeature ProcessorParamsTrackerFeatureDummy(std::string _unique_name, const wolf::ParamsServer & _server): ProcessorParamsTrackerFeature(_unique_name, _server) { - n_tracks_lost = _server.getParam<unsigned int>(_unique_name + "/n_tracks_lost"); + n_tracks_lost = _server.getParam<unsigned int>(prefix + _unique_name + "/n_tracks_lost"); } }; diff --git a/test/dummy/processor_tracker_landmark_dummy.h b/test/dummy/processor_tracker_landmark_dummy.h index 106f9ba2a1ea683eb763fc76e7f334e2bf8509b3..a9531c8db7a0372636c1d0cb605c21c38aec8446 100644 --- a/test/dummy/processor_tracker_landmark_dummy.h +++ b/test/dummy/processor_tracker_landmark_dummy.h @@ -23,7 +23,7 @@ struct ProcessorParamsTrackerLandmarkDummy : public ProcessorParamsTrackerLandma ProcessorParamsTrackerLandmarkDummy(std::string _unique_name, const wolf::ParamsServer & _server): ProcessorParamsTrackerLandmark(_unique_name, _server) { - n_landmarks_lost = _server.getParam<unsigned int>(_unique_name + "/n_landmarks_lost"); + n_landmarks_lost = _server.getParam<unsigned int>(prefix + _unique_name + "/n_landmarks_lost"); } }; diff --git a/test/gtest_parser_yaml.cpp b/test/gtest_parser_yaml.cpp index 7d155a86f70e66ae8d6f869f54eadc9b63fb68bf..aea2db7da463b6076179b7b8bbcd18e2a3dd2046 100644 --- a/test/gtest_parser_yaml.cpp +++ b/test/gtest_parser_yaml.cpp @@ -7,6 +7,8 @@ using namespace std; using namespace wolf; std::string wolf_root = _WOLF_ROOT_DIR; +std::string sensor_prefix = "sensor/"; +std::string processor_prefix = "processor/"; ParserYAML parse(string _file, string _path_root) { @@ -21,8 +23,8 @@ TEST(ParserYAML, RegularParse) auto params = parser.getParams(); // for(auto it : params) // cout << it.first << " %% " << it.second << endl; - EXPECT_EQ(params["odom/intrinsic/k_rot_to_rot"], "0.1"); - EXPECT_EQ(params["processor1/sensor_name"], "odom"); + EXPECT_EQ(params[sensor_prefix + "odom/intrinsic/k_rot_to_rot"], "0.1"); + EXPECT_EQ(params[processor_prefix + "processor1/sensor_name"], "odom"); } TEST(ParserYAML, ParseMap) { @@ -30,29 +32,29 @@ TEST(ParserYAML, ParseMap) auto params = parser.getParams(); // for(auto it : params) // cout << it.first << " %% " << it.second << endl; - EXPECT_EQ(params["processor1/mymap"], "[{k1:v1},{k2:v2},{k3:[v3,v4,v5]}]"); + EXPECT_EQ(params[processor_prefix + "processor1/mymap"], "[{k1:v1},{k2:v2},{k3:[v3,v4,v5]}]"); // EXPECT_EQ(params["processor1/$mymap/k1"], "v1"); } TEST(ParserYAML, FollowFile) { auto parser = parse("test/yaml/params1.yaml", wolf_root); auto params = parser.getParams(); - EXPECT_EQ(params["my_proc_test/max_buff_length"], "100"); - EXPECT_EQ(params["my_proc_test/voting_active"], "false"); + EXPECT_EQ(params[processor_prefix + "my_proc_test/max_buff_length"], "100"); + EXPECT_EQ(params[processor_prefix + "my_proc_test/voting_active"], "false"); } TEST(ParserYAML, FollowOdom3D) { auto parser = parse("test/yaml/params1.yaml", wolf_root); auto params = parser.getParams(); - EXPECT_EQ(params["my_proc_odom3d/keyframe_vote/max_buff_length"], "10"); - EXPECT_EQ(params["my_proc_odom3d/keyframe_vote/max_time_span"], "0.2"); + EXPECT_EQ(params[processor_prefix + "my_proc_odom3d/keyframe_vote/max_buff_length"], "10"); + EXPECT_EQ(params[processor_prefix + "my_proc_odom3d/keyframe_vote/max_time_span"], "0.2"); } TEST(ParserYAML, JumpFile) { auto parser = parse("test/yaml/params3.yaml", wolf_root); auto params = parser.getParams(); - EXPECT_EQ(params["my_proc_test/extern_params/max_buff_length"], "100"); - EXPECT_EQ(params["my_proc_test/extern_params/voting_active"], "false"); + EXPECT_EQ(params[processor_prefix + "my_proc_test/extern_params/max_buff_length"], "100"); + EXPECT_EQ(params[processor_prefix + "my_proc_test/extern_params/voting_active"], "false"); } TEST(ParserYAML, ProblemConfig) {