-
Notifications
You must be signed in to change notification settings - Fork 162
[ImuFactor] Unit test the on manifold ImuFactor #280
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
Conversation
|
6b96170 to
cbff03c
Compare
cb930c9 to
c75ca92
Compare
c66a156 to
e0dc194
Compare
e0dc194 to
8b12cfb
Compare
6a10ac0 to
d1c3e65
Compare
eaac176 to
b99759f
Compare
b99759f to
fa0d4f8
Compare
d7d5a05 to
6e00ec4
Compare
588dc03 to
ac8a863
Compare
6e00ec4 to
a74eae6
Compare
abc44f7 to
bce1cc6
Compare
0fe0e7e to
e311bc4
Compare
bce1cc6 to
0bcdc34
Compare
e311bc4 to
7970c6f
Compare
0bcdc34 to
6dc39ab
Compare
7970c6f to
63a4d23
Compare
9c6f3d9 to
b75e14b
Compare
628c136 to
9e3c1fd
Compare
b75e14b to
50a2f1d
Compare
9e3c1fd to
25e592a
Compare
| const int sample_count = 1 << 18; | ||
|
|
||
| // Multithreading | ||
| const int thread_count = 16; |
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 should not be 16 by default, it should really be 1
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 this for now, but is there really that much of an overhead of spawning threads when only a single core is available? Especially if we're only spawning a fixed number and the process is kind of long.
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.
For this test probably not really, since CPU is the only resource that scales with number of threads here, and not memory. In general though the test runner (ctest, bazel, etc) should have control over test parallelism and will run tests with whatever parallelism is requested there, and individual tests trying to parallelize themselves makes that less effective
50a2f1d to
a83f377
Compare
2e9523a to
11ea000
Compare
a83f377 to
111652d
Compare
11ea000 to
8282170
Compare
111652d to
615a9a3
Compare
8282170 to
df7fd0c
Compare
|
|
||
| MultiVarNormalDist dist(covar); | ||
|
|
||
| const Eigen::MatrixXd samples = dist.Sample(gen, 1 << 23); |
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.
Do we really need 8 million samples for this? How long does this one take? Could we just use a smaller matrix?
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.
It takes 4 seconds. I wanted to use a 9x9 matrix because that's the size of the covariance that we use in the next unit test (and this unit test more or less checks that the test infra-structure is right).
| Eigen::Matrix3d new_Dp_D_accel_bias_auto; | ||
| Eigen::Matrix3d new_Dp_D_gyro_bias_auto; | ||
|
|
||
| sym::ImuManifoldPreintegrationUpdate<double>( |
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 function is the non-auto one :)
Explains why they're so close, I was a bit surprised
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.
Thanks for catching this. We discussed this in person, but it turns out the test would have been failing (severely) had I called the other function correctly. Specifically, it turned out that the hand-written symbolic implementation of right_jacobian added a term it should have been subtracting, causing the problems. With that fixed, the difference between the two (using the frobenius norm) was on the order of 10-8.
Adds three tests meant to jointly test the `ImuManifoldPreintegrationUpdate` function. The calculated covariance is tested by sampling the values it is a covariance of and comparing it to the numircally calculated covariance from the samples. Warning, there is a tradeoff between time (number of samples) and accuracy for the calculated covariance. To speed things up, the sampling process is multi-threaded. Note, with my current parameters, it takes about 2^23 samples to be pretty robust to changes in the random seed. But that takes a minute to run on my desktop with 16 cores. So in the interest of testing time, I've cut the sample size by a bit. Of course, this means if you change the seed, the test might end up failing. To know if it's really a problem, bump up the sample size and see if it persists. The derivatives wrt to bias are calculated by perturbing the input in each direction to numerically calculate the columns of the derivative. The actual change in state (DR, Dv, Dp) isn't tested in a very intelligent manner. They didn't have any simple and obvious properties that could be easily tested. Still, their implementations are pretty simple, so I figured comparing to a C++ implementation would at the very least protect against someone accidentally deleting a line in the symbolic code or whatever. Topic: on_manifold_imu_factor_test Relative: on_manifold_imu_factor
615a9a3 to
deda3fc
Compare
df7fd0c to
3be09c4
Compare
Adds three tests meant to jointly test the
ImuManifoldPreintegrationUpdatefunction.The calculated covariance is tested by sampling the values it is a
covariance of and comparing it to the numircally calculated covariance
from the samples. Warning, there is a tradeoff between time (number of
samples) and accuracy for the calculated covariance. To speed things up,
the sampling process is multi-threaded. Note, with my current parameters,
it takes about 2^23 samples to be pretty robust to changes in the random
seed. But that takes a minute to run on my desktop with 16 cores. So in
the interest of testing time, I've cut the sample size by a bit. Of
course, this means if you change the seed, the test might end up
failing. To know if it's really a problem, bump up the sample size and
see if it persists.
The derivatives wrt to bias are calculated by perturbing the input in
each direction to numerically calculate the columns of the derivative.
The actual change in state (DR, Dv, Dp) isn't tested in a very
intelligent manner. They didn't have any simple and obvious properties
that could be easily tested. Still, their implementations are pretty
simple, so I figured comparing to a C++ implementation would at the very
least protect against someone accidentally deleting a line in the
symbolic code or whatever.
Topic: on_manifold_imu_factor_test
Relative: on_manifold_imu_factor