-
Notifications
You must be signed in to change notification settings - Fork 773
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
Expose some iSAM2/FixedLagSmoothing functionality for the bindings #1053
Conversation
Cool. Will run CI after #1054 is merged. Could you maybe add a unit test in python/gtsam_unstable/tests ? You could do this using a paired down version of Finally, @varunagrawal and @ProfFan : can't we now just access fields in a struct? This would have to work in matlab and python, of course. |
@@ -567,6 +567,10 @@ virtual class FixedLagSmoother { | |||
double smootherLag() const; | |||
|
|||
gtsam::FixedLagSmootherResult update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta, const gtsam::FixedLagSmootherKeyTimestampMap& timestamps); | |||
gtsam::FixedLagSmootherResult update(const gtsam::NonlinearFactorGraph &newFactors, |
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.
You can just update the above update
by adding the extra parameter and specifying a default parameter.
Yes! Accessing member variables in classes and structs is supported. |
And when I say supported, I mean across all languages. 🙂 |
Cool, so, could you comment on how @senselessDev would change the PR; the c++ stubs would no longer be needed I guess. |
Ahh, nice to know. I am more or less familiar with pybind and I presume you are talking about this: https://pybind11.readthedocs.io/en/stable/classes.html#instance-and-static-fields I have found it in the generated binding code only a few times, but I think for example it is being generate by Lines 217 to 219 in 0638727
Right? |
Just tried it out in bcbd26c, is working for me:
|
Cool! But please run |
@varunagrawal Hence, on importing gtsam_unstable it is failing with
One idea is to include |
|
|
@@ -300,50 +300,24 @@ struct GTSAM_EXPORT ISAM2Params { | |||
RelinearizationThreshold getRelinearizeThreshold() const { | |||
return relinearizeThreshold; | |||
} | |||
int getRelinearizeSkip() const { return relinearizeSkip; } |
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.
Why are we removing all these methods? Isn't this API breaking and tangential to the point of this PR?
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.
Why are we removing all these methods? Isn't this API breaking and tangential to the point of this PR?
It'll help if you read my review comments as well....
void setEnableDetailedResults(bool enableDetailedResults); | ||
bool isEnablePartialRelinearizationCheck() const; | ||
void setEnablePartialRelinearizationCheck( | ||
bool enablePartialRelinearizationCheck); |
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.
Again, you don't need to remove these methods to add the variable access. This would break the API for other users.
Did a quick run through while eating lunch: I am not sure I agree with the methods being removed. Sometimes, you just want to pass functionals to other methods/functionals thus the point of setters and getters in a hybrid functional programming paradigm (which is what we have). Also, please please please add some python unit tests for the changes you have made. That way I can help you figure out exactly what you need since if the tests reflect your desired behavior, my suggestions will align with your end goal. :) |
Agree with unit test comment. But the comment about "Sometimes,..." seems a bit arcane. I'd opt for KISS. These methods were in actuality only added for the wrapper. I'd as soon remove them. Less code to maintain. |
Also: "This is an API change, which I am generally OK with in a new minor version release if the code is rarely used". I think this is the case here. And more is coming down the pipe. |
If we're all on the same page about API changes then I am happy :) Also regarding the import error, adding |
Okay nvm my last comment. You can go back to having two versions of wrapped |
I thought this was already supported. I definitely added, say, DiscreteKeys to a preamble so it behaves just like a dict in python... |
Yes but FactorIndices is weird, it is an alias of |
This is primarily because FactorIndices is a typedef while DiscreteKeys is a subclass. |
So, to summarize, we want to get rid of all those setters/getters when an equivalent direct member access is possible. And I need to change that in all the tests/examples which use it. Right? Regarding subclassing and typedef, I am not too sure. I played around with the
I have not tried it yet with defining them in both. BTW, I think I have discovered an issue that the specialization header of gtsam_unstable does not reflect changes properly. It is copied into the build directories only once but not every time when the file in the source directory changes. This costed me a lot of time until discovered. I had no motivation left to see how to trigger that via CMake. Maybe that does help. Maybe it was only a very weird problem on my machine. Just in case you are wondering, maybe that's an explanation. |
Yes, feel free get rid of setters/getters in the one class (let's keep this PR specific) except the ones that examine a string argument. If you do so, then indeed tests and examples have to be fixed or CI will not pass. cmake issue: I know, I have been frustrated by this before. @varunagrawal or @ProfFan might be able to look at this after the RSS deadline. |
Can you comment on whether make check and make python-test work? Then I'll trigger CI and we can merge. |
Sorry, I had no time to implement all changes we discussed. Hopefully sometime during this weekend.. |
* FactorIndices default argument is currently not easily available in binding code * see borglab#1053 (comment)
Pushed now the adapted examples with direct member access. Tested with What I did not do (and can not) is matlab testing. |
@mattking-smith is this something you can test before we merge? |
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 looks good to me! But I prefer to wait with merging until we know about the MATLAB implication. @varunagrawal , should it work, in theory? @mattking-smith does it work, in practice?
I can run the Matlab tests in a bit and give you a definite answer. :) |
I am happy to report that all Matlab tests pass. 🙂 I'll go ahead and merge this. |
Thanks @senselessDev !!!! |
@mattking-smith FYI |
I was not able to use the
findUnusedFactorSlots
parameter from Python (compare with #150).Also a new overloaded
update
method for theFixedLagSmoother
allows to give factors that shall be removed.And last but not least,
IncrementalFixedLagSmoother
exposes the internal factor graph.