-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace NoiseModelFactor1
in with NoiseModelFactorN
in pre-made factors
#1344
Conversation
I was wondering for a second why am I suddenly getting so many deprecation warnings. 😅 |
Can we land this quickly please? Debugging is hard with the crazy amount of deprecation messages... |
Yeah, I screwed up, did not see the other PR was targeting #947 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will approve so we can land to suppress the warnings, but I did not see
“solution 2” implemented anywhere. Is it no longer needed?
I will let @gchenfc merge - maybe solution 2 is still in the works, although I would also support doing this in a different PR. |
Sounds good, yes solution 2 can be a separate PR. Might not be able to get to it until tomorrow night, but this PR can stand on its own before solution 2. Merging now. |
This is a follow-up to #947 which applies this "new style"
NoiseModelFactorN
to existing factors in GTSAM (e.g.PriorFactor
,BetweenFactor
, ...) which, after #947 is merged, they will be using deprecated versions ofNoiseModelFactor123456
.I decided to separate this into a separate PR to keep file changes cleaner and because I think it might warrant more discussion (*sigh) and I don't want to drag out the other one if it doesn't have to.
Hiccup
In the process, I realized that this will introduce some backward compatibility issues. Specifically:
NoiseModelFactor2
(deprecated) toNoiseModelFactorN
, users will lose access to thekey2()
functions and the::X2
type aliases (inherited fromNoiseModelFactor2
) since the new usage is nowkey<2>()
and::ValueType<2>
.So, for example (I will use this example for the rest of this description, but all pre-made factors in GTSAM have similar issues):
Proposed Solutions
Allowing backward compatible access to
key2()
is not too ugly, so I just moved those intoNoiseModelFactorN
and deprecated them (fully backward compatible, but deprecated).But allowing backward compatible access to
::X2
is quite ugly (see here and below), so I just left these out (implemented inNoiseModelFactor2
, but not accessible fromBetweenFactor
anymore). I see 3 most reasonable options:BetweenFactor::X2
, they should change toBetweenFactor::ValueType<2>
. Use of::X2
seems pretty uncommon and didn't appear ever inside gtsam codebase including examples & tests (all unit tests pass).X1
andX2
insideBetweenFactor
(and for every pre-made factor in GTSAM). This is fine, but will just take a while and might add a lot of clutter.NoiseModelFactorN
(see below).gtsam/gtsam/nonlinear/NonlinearFactor.h
Lines 401 to 411 in 84e873e
Changes / notes:
NoiseModelFactor123456
->NoiseModelFactorN
X2
is nowValueType<2>
. e.g. any instances ofBetweenFactor<Pose3>::X2
need to be changed toBetweenFactor::ValueType<2>
. This applies to all pre-made factors in GTSAM.key1()
functions fromNoiseModelFactor1
toNoiseModelFactorN
. Although we had previously discussed that it would be cleaner to be inNoiseModelFactor1
, this will avoid breaking backward compatibility when changing pre-made factors to inherit fromNoiseModelFactorN
.NoiseModelFactorN
, some calls (inside the class only) get ugly due to dependent types. e.g.template
keyword is required here:gtsam/gtsam/slam/BetweenFactor.h
Lines 91 to 92 in a3e314f
This only affects calls inside the class and is similar to why we need to sometimes use
typename
. More details here. I know this is standard template syntax, but I do remember a couple years ago the first time I saw this syntax reading code I was really confused because it looks so weird, so I would like to minimize its use if possible to avoid confusing people.