Open johnwlambert opened 3 years ago
Unfortunately, @johnwlambert, I think this assumption goes deeper than just this piece of code, which just checks the assumption. Several other functions that construct matrices related to the convergence certificate also use the fact that the graph is connected and keys are 0..N-1
. There are about 10 places where nrUnknowns is used to dimension a sparse or dense matrix. I'm not saying it can't be solved, but it's not a quick fix, rather a major philosophical overhaul.
Yeah this is what I was discovering also as I looked through the other Shonan code in Shonan.cpp.
@dellaert I don't see a way to do this without a re-mapping of keys to zero-indexed consecutive variables (e.g. relating to matrix rows/cols) either on the GTSAM end, or on the GTSFM end, to remove this assumption.
I assume we are doing that elsewhere in GTSAM for arbitrarily-named keys in the factor graph, when forming a sparse system. Is there something we could take from there?
Suppose 4 images are captured by a camera rig at 4 separate poses,
wTi0, wTi1, wTi2, wTi3
.Suppose relative rotations are estimated between poses (1,2), (2,3), (1,3), but pose 0 is orphaned. If keys are not ordered consecutively, from 0,...,N-1, then Shonan will throw the following error:
However, I think arbitrary ordering should be allowed, in keeping with how keys can be arbitrary numbers throughout GTSAM:
Here is a minimal example to reproduce it:
This is because of the following logic in ShonanAveraging.cpp, which loops over each BinaryMeasurement, and accumulates
The problem is that keys.size() = N = 3, but maxKey is also 3, and maxKey != N - 1.