-
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
Simpler HybridGaussianFoo constructors #1848
Conversation
dellaert
commented
Sep 26, 2024
- Remove superfluous arguments
- Add helper structs and private constructor to ensure proper initialization
- Added input checking on factors and conditional keys but removed it since
- expensive
- it was not checked before
- simplified all call sites -> no code is the best code
Updating to also fix HybridNonlinearFactor |
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.
Partial review. Will do more later tonight.
const DiscreteKey &discreteKey, | ||
const std::vector<GaussianFactor::shared_ptr> &factors) | ||
: discreteKeys({discreteKey}) { | ||
// Extract continuous keys from the first non-null factor |
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'll do a full review in a bit, but I am wondering about the extra compute happening here when we could have just given the keys directly.
Currently I am struggling with the hybrid state estimator being far too slow and having too many hypotheses. Pruning is working but the blow up is still immense, hence my concerns here.
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.
Ironically, it's a bit faster.
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.
Esp, GaussianConditional, which did two tree traversals, now only does one.
That's fine, I'm moving some more stuff to cpp files now rather than cluttering the headers. |
OK, done, and cleaned up some missing python test changes. |
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.
Some things I noticed while looking over PR
const ConstructorHelper &helper) | ||
: BaseFactor(discreteParents, helper.pairs), | ||
BaseConditional(helper.frontals.size()), | ||
conditionals_(conditionals), |
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.
These things are here twice! Once in BaseFactor, and once in conditionals_.
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.
Yeah I thought about that too. There was a reason I couldn't get rid of conditionals_
, which I think was to do with negLogConstant
. I'll think about this again so we can remove it.
value = c->negLogConstant(); | ||
negLogConstant = std::min(negLogConstant, value); | ||
} | ||
return {std::dynamic_pointer_cast<GaussianFactor>(c), value}; |
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.
Because we store the value, we should never have to call negLogConstant in this file again!
And that’s why we currently need to keep conditionals :-( at least until the hiding is removed.
@varunagrawal whats up with windows CI? |
I think the boost download link is invalid. It's affecting multiple PRs. |
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
The whole ConstructorHelper
code seems a bit too convoluted, and not specifying continuous keys feels a bit strange but that may be my not being used to it.
Good thing we have a slew of unit tests. :)
const ConstructorHelper &helper) | ||
: BaseFactor(discreteParents, helper.pairs), | ||
BaseConditional(helper.frontals.size()), | ||
conditionals_(conditionals), |
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.
Yeah I thought about that too. There was a reason I couldn't get rid of conditionals_
, which I think was to do with negLogConstant
. I'll think about this again so we can remove it.
const std::vector<GaussianFactorValuePair> &factorPairs) | ||
: HybridGaussianFactor(ConstructorHelper(discreteKey, factorPairs)) {} | ||
|
||
HybridGaussianFactor::HybridGaussianFactor(const DiscreteKeys &discreteKeys, |
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.
All three of the above constructors need the divider
/* *******************************************************************************/
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.
This is more for me when I add it.