-
Notifications
You must be signed in to change notification settings - Fork 779
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
Add deprecated aliases for X1 = ValueType<1>
, ...
#1350
Conversation
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.
LGTM, but Windows CI fails.
@gchenfc lets fix windows CI and merge? |
MSVC only supports deprecated typedefs, not deprecated `using`.
So, BTW, I’m re-evaluating whether we should deprecate the old classes. Thoughts? Pros/cons? |
My short answer is that, yes, I think this makes sense. And then I think we might revert #1344. New factors can use the new However, I'm actually going to propose something slightly different:
|
I do like that solution. But would |
There's a weird edge-case backward compatibility issue where TL;DR - normally you can do this: class MyFactor : public NoiseModelFactor2<Pose3, Point3> {
using This = NoiseModelFactor2;
}; and it will deduce the template arguments. But if you do something like template <typename T1, typename T2>
using NoiseModelFactor2 = NoiseModelFactorN<T1, T2>; then the previous code block will no longer be able to deduce the template arguments and will throw a compile-time error. I have a prototype almost ready - I'll create a separate PR since it's getting to be quite different than this PR, and if we like that we can close this PR. |
Recap
Following up on / recapping #1344,
NoiseModelFactorN
instead ofNoiseModelFactor1-6
, the aliasesX1
,X2
, ... were no longer available in pre-existing factor classes. Therefore,NoiseModelFactor1
in withNoiseModelFactorN
in pre-made factors #1344 presented 3 options to maintain backward compatibility, of which @dellaert liked the 2nd option the best:NoiseModelFactorN
now has the deprecated aliases defined in its class.Summary
I created a macro
ADD_NOISE_MODEL_FACTOR_N_DEPRECATED_TYPEDEFS(classname, number_of_types)
inNonlinearFactor.h
to add all theusing X2 = ...
aliases since I figured this might be cleaner, but I can change it to just manually defining them all (without the macro) if that's more readable.Then in every class that I changed to inherit from
NoiseModelFactorN
, I added theADD_NOISE_MODEL_FACTOR_N_DEPRECATED_TYPEDEFS
macro at the beginning.Sanity Check
As a quick sanity check that all the files changed in #1344 have been addressed, #1344 has 64 .h files while this only has 54. The missing ones are:
Testable.h
,types.h
,graph-inl.h
- none of these define factors and the changes were things like updating commentsTransformBtwRobotsUnaryFactor.h
- just a comment updatesimulated2D.h
,simulated2Doriented.h
,simulated3D.h
,smallExample.h
- since these are unit tests, they don't need these backward compatible alias definitions.BoundingConstraint.h
- this file already typedef'dX
andX1
andX2
so I didn't need to typedef them again.MultiProjectionFactor.h
- I don't even know how this factor compiled before I changedkey1()
andkey2()
since it inherits fromNoiseModelFactor
which doesn't have akey1()
orkey2()
function (didn't raise compile error until you calledevaluateError
in cpp file?!), but in any case, this file doesn't need the aliased definitions.And that makes all 10!