Skip to content

Commit 6592581

Browse files
committed
[bug-fix] Remove unused keys from marginalizable keys in the IncrementalFixedLagSmoother
1 parent d82f6a7 commit 6592581

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gtsam/nonlinear/IncrementalFixedLagSmoother.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ FixedLagSmoother::Result IncrementalFixedLagSmoother::update(
107107
// database
108108
eraseKeyTimestampMap(KeyVector{isamResult_.unusedKeys.begin(),
109109
isamResult_.unusedKeys.end()});
110+
111+
if (marginalizableKeys.size() > 0) {
112+
// Remove keys that became unused after update from the marginalizable
113+
// keys to avoid marginalizing keys that have been removed from ISAM2.
114+
marginalizableKeys.erase(
115+
std::remove_if(marginalizableKeys.begin(), marginalizableKeys.end(),
116+
[&](const auto& key) {
117+
return isamResult_.unusedKeys.find(key) !=
118+
isamResult_.unusedKeys.end();
119+
}),
120+
marginalizableKeys.end());
121+
}
110122
}
111123

112124
if (debug) {

0 commit comments

Comments
 (0)