Closed roger- closed 2 years ago
I had the same problem recently, and I ended up with this work around:
to_remove = set()
to_remove.add(factor)
indices_to_remove = [i for i in range(graph.size()) if curr_graph.at(i) in to_remove]
isam.update(gtsam.NonlinearFactorGraph(), gtsam.Values(), indices_to_remove)
I am not 100% sure that this is a valid solution though.
That's good idea, thanks! Seems like I'll have to keep track of the entire graph instead of just handing it off to ISAM2, but should work for now.
Seems like it would be easier if factors had keys, like variables do. Wonder why indices are used?
I accessed the factors using isam.getFactorsUnsafe()
, so there should be no reason to make a full graph yourself.
As in, above there should be a line that says:
graph = isam.getFactorsUnsafe()
Ah, missed that method. Thanks!
PR #1146 should add the desired method as getNewFactorsIndices()
.
I'm trying to remove some factors from ISAM2 (similar to #1119), and it seems that I need to track their indices using
gtsame.ISAM2Result.newFactorsIndices
.Unfortunately this seems to be missing in Python:
Is there a workaround or am I doing something wrong?
Setup: gtsam 4.1.1 / Ubuntu 20.04.4 / Python 3.8