-
Notifications
You must be signed in to change notification settings - Fork 162
IMU Preintegration #160
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
IMU Preintegration #160
Conversation
symforce/codegen/codegen_util.py
Outdated
| formatted_symbols = [] | ||
| for j in range(value.shape[1]): | ||
| for i in range(value.shape[0]): | ||
| formatted_symbols.append(sm.Symbol(f"{key}[{i}, {j}]")) |
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.
@aaron-skydio @bradley-solliday-skydio I think there's a bug here that we should discuss and work out
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 may have addressed it here: dc80387
I'm not sure if this breaks anything with Python codegen yet. There's a decision in play here whether 1D geo vectors get generated as lists, 1D numpy arrays, or 2D numpy arrays.
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 cc @nathan-skydio too, I don't think we want to generate them as lists but could see either 1d or 2d numpy arrays
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.
Maybe generating 2D arrays makes the most sense given that a geo.Matrix always has the number of rows/cols defined, so I'm not sure a 1D geo.Matrix really exists (i.e. I think geo.V3.shape is (3,1), so we might want my_generated_numpy_vec3.shape to be (3,1) instead of (3,)). I don't feel super strongly one way or the other though
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 think I agree with that. However, in javascript it will be more awkward because it'll be an Array of Arrays or something like that, where if you really just wanted scalars and vectors it adds unnecessary complexity
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.
With dc80387 we can do this easily per language though right? I think it makes sense for python to use all-2d numpy arrays, since that's easy, but for JS to use 1D arrays for column vectors
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.
Yes we can do 2D numpy arrays for python and use 1D arrays in JS. Just slightly odd to have different apis like that
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.
Personally I lean towards just making things 2d everywhere if we want uniformity
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'm a bit torn on the uniformity vs idiomatic use. I wonder if we might just want to introduce a dependency like https://github.com/nicolaspanel/numjs
| accel_cov: | ||
| gyro_cov: | ||
| accel_bias: | ||
| gyro_bias: |
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.
populate
| import gtsam | ||
| except ImportError: | ||
| logger.info("Skipping test, GTSAM not installed.") | ||
| return |
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.
@aaron-skydio curious on thoughts 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.
Yeah I think this makes sense to skip if gtsam isn't installed, should make sure this runs in CI (where we install gtsam so we can build the benchmarks, cc @bradley-solliday-skydio ). Should probably also use unittest.skip like we do here for numba
|
Another thing to discuss @aaron-skydio is that this puts the python generated code into |
|
I think it seems reasonable to put the generated python factors into |
| from sym.factors.imu_preintegration_update import imu_preintegration_update | ||
|
|
||
|
|
||
| class PreintegratedImu: |
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 have 2 quick questions if I may:
- Can we keep the same naming convention as GTSAM? That should make porting code over to symforce much easier.
- I've made a bunch of improvements to the ImuFactor, CombinedImuFactor and other parts related to these classes. I was wondering if you're using GTSAM as a code reference or reimplementing this directly from the math? Goes without saying that I am more than happy to provide reviews/help to land this feature. I am considering moving all my PhD work to using Symforce for the long term. :)
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.
@varunagrawal have the updates you mention landed in gtsam develop?
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.
Yes they have!
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.
@varunagrawal Oh great. I am nose down on getting this port going and comparing with current gtsam develop. Perhaps I can ping you with a question or two. =)
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.
Absolutely! More than happy to help and see this feature landed in Symforce.
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.
Glad y'all are interested :)
We're also currently pushing on getting this usable as a factor in the optimizer and getting it merged, it might be worth coordinating and sharing the work (@bradley-solliday-skydio is working on this right now)
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.
@bradley-solliday-skydio i would love to discuss. I am working through unit testing the tangent pre-integration piece against gtsam, and finding some differences. Lmk.
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.
@varunagrawal I pinged you on LinkedIn
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.
any update on this feature?
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.
Hey Hans! @bradley-solliday-skydio is actively working on finishing this up and we should be able to merge it soon
96d9c95 to
f02ba16
Compare
f02ba16 to
6efbfb6
Compare
8972fd4 to
aaabed1
Compare
Add a symforce.slam.imu_preintegration module that provides a symbolic implementation of tangent preintegration, and generates Python and C++ runtime functions for the main update function. Also adds a lightweight Python wrapper class to maintain state and tests against GTSAM. GitOrigin-RevId: 320a1690e2bef50bff14001408552976bfe2ee5c
aaabed1 to
d87f7b1
Compare
|
This was moved to #279, which is now merged - further work on this should be new PR(s) |
Add a
symforce.slam.imu_preintegrationmodule that provides a symbolic implementation of tangent preintegration, and generates Python and C++ runtime functions for the main update function. Also adds a lightweight Python wrapper class to maintain state and tests against GTSAM.