commit
26a4f70b38
|
@ -134,10 +134,12 @@ void HybridNonlinearFactor::print(const std::string& s,
|
||||||
std::cout << (s.empty() ? "" : s + " ");
|
std::cout << (s.empty() ? "" : s + " ");
|
||||||
Base::print("", keyFormatter);
|
Base::print("", keyFormatter);
|
||||||
std::cout << "\nHybridNonlinearFactor\n";
|
std::cout << "\nHybridNonlinearFactor\n";
|
||||||
auto valueFormatter = [](const std::pair<sharedFactor, double>& v) {
|
auto valueFormatter = [&keyFormatter](const std::pair<sharedFactor, double>& v) {
|
||||||
auto [factor, val] = v;
|
auto [factor, val] = v;
|
||||||
if (factor) {
|
if (factor) {
|
||||||
return "Nonlinear factor on " + std::to_string(factor->size()) + " keys";
|
RedirectCout rd;
|
||||||
|
factor->print("", keyFormatter);
|
||||||
|
return rd.str();
|
||||||
} else {
|
} else {
|
||||||
return std::string("nullptr");
|
return std::string("nullptr");
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ HybridSmoother::addConditionals(const HybridGaussianFactorGraph &newFactors,
|
||||||
HybridBayesNet updatedHybridBayesNet(hybridBayesNet);
|
HybridBayesNet updatedHybridBayesNet(hybridBayesNet);
|
||||||
|
|
||||||
KeySet involvedKeys = newFactors.keys();
|
KeySet involvedKeys = newFactors.keys();
|
||||||
auto involved = [&involvedKeys](const Key &key) {
|
auto involved = [](const KeySet &involvedKeys, const Key &key) {
|
||||||
return involvedKeys.find(key) != involvedKeys.end();
|
return involvedKeys.find(key) != involvedKeys.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ HybridSmoother::addConditionals(const HybridGaussianFactorGraph &newFactors,
|
||||||
auto conditional = hybridBayesNet.at(i);
|
auto conditional = hybridBayesNet.at(i);
|
||||||
|
|
||||||
for (auto &key : conditional->frontals()) {
|
for (auto &key : conditional->frontals()) {
|
||||||
if (involved(key)) {
|
if (involved(involvedKeys, key)) {
|
||||||
// Add the conditional parents to involvedKeys
|
// Add the conditional parents to involvedKeys
|
||||||
// so we add those conditionals too.
|
// so we add those conditionals too.
|
||||||
for (auto &&parentKey : conditional->parents()) {
|
for (auto &&parentKey : conditional->parents()) {
|
||||||
|
@ -214,7 +214,7 @@ HybridSmoother::addConditionals(const HybridGaussianFactorGraph &newFactors,
|
||||||
auto conditional = hybridBayesNet.at(i);
|
auto conditional = hybridBayesNet.at(i);
|
||||||
|
|
||||||
for (auto &key : conditional->frontals()) {
|
for (auto &key : conditional->frontals()) {
|
||||||
if (involved(key)) {
|
if (involved(involvedKeys, key)) {
|
||||||
newConditionals.push_back(conditional);
|
newConditionals.push_back(conditional);
|
||||||
|
|
||||||
// Remove the conditional from the updated Bayes net
|
// Remove the conditional from the updated Bayes net
|
||||||
|
|
|
@ -81,8 +81,14 @@ TEST(HybridNonlinearFactor, Printing) {
|
||||||
R"(Hybrid [x1 x2; 1]
|
R"(Hybrid [x1 x2; 1]
|
||||||
HybridNonlinearFactor
|
HybridNonlinearFactor
|
||||||
Choice(1)
|
Choice(1)
|
||||||
0 Leaf Nonlinear factor on 2 keys
|
0 Leaf BetweenFactor(x1,x2)
|
||||||
1 Leaf Nonlinear factor on 2 keys
|
measured: 0
|
||||||
|
noise model: diagonal sigmas [1];
|
||||||
|
|
||||||
|
1 Leaf BetweenFactor(x1,x2)
|
||||||
|
measured: 1
|
||||||
|
noise model: diagonal sigmas [1];
|
||||||
|
|
||||||
)";
|
)";
|
||||||
EXPECT(assert_print_equal(expected, hybridFactor));
|
EXPECT(assert_print_equal(expected, hybridFactor));
|
||||||
}
|
}
|
||||||
|
|
|
@ -535,6 +535,9 @@ TEST(HybridNonlinearFactorGraph, Printing) {
|
||||||
const auto [hybridBayesNet, remainingFactorGraph] =
|
const auto [hybridBayesNet, remainingFactorGraph] =
|
||||||
linearizedFactorGraph.eliminatePartialSequential(ordering);
|
linearizedFactorGraph.eliminatePartialSequential(ordering);
|
||||||
|
|
||||||
|
// Set precision so we are consistent on all platforms
|
||||||
|
std::cout << std::setprecision(6);
|
||||||
|
|
||||||
#ifdef GTSAM_DT_MERGING
|
#ifdef GTSAM_DT_MERGING
|
||||||
string expected_hybridFactorGraph = R"(
|
string expected_hybridFactorGraph = R"(
|
||||||
size: 7
|
size: 7
|
||||||
|
|
Loading…
Reference in New Issue