Skip to content

Commit

Permalink
Fix descriptor values loading from a .yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
boxanm committed Nov 21, 2023
1 parent c4fa9ff commit feb7c2b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/data/add_descriptor_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- AddDescriptorDataPointsFilter:
descriptorName: deviation
descriptorDimension: 9
descriptorValues: [0.0009, 0, 0, 0, 0.0009, 0, 0, 0, 0.0009]
17 changes: 15 additions & 2 deletions pointmatcher/Registrar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ namespace PointMatcherSupport
for(YAML::const_iterator paramIt = mapIt->second.begin(); paramIt != mapIt->second.end(); ++paramIt)
{
std::string key = paramIt->first.as<std::string>();
std::string value = paramIt->second.as<std::string>();
params[key] = value;
if (paramIt->second.IsSequence())
{
std::ostringstream oss;
oss << "[";
for(int i = 0; i < paramIt->second.size()-1; ++i)
{
oss << paramIt->second[i] << ", ";
}
oss << paramIt->second[paramIt->second.size()-1] << "]";
params[key] = oss.str();
}
else
{
params[key] = paramIt->second.as<std::string>();
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions utest/ui/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ TEST(IOTest, loadYaml)

std::ifstream ifs3((dataPath + "unit_tests/badIcpConfig_InvalidModuleType.yaml").c_str());
EXPECT_THROW(icp.loadFromYaml(ifs3), PointMatcherSupport::InvalidModuleType);

std::ifstream ifs4((dataPath + "add_descriptor_config.yaml").c_str());
EXPECT_NO_THROW(PM::DataPointsFilters filters(ifs4));
}

TEST(IOTest, loadCSV)
Expand Down

0 comments on commit feb7c2b

Please sign in to comment.