-
Notifications
You must be signed in to change notification settings - Fork 15
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
Trilinear and bary-linear interpolations #127
Conversation
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
I believe this is very similar to what the hybrid bary-linear algorithm in this PR does, in This way, we offer 2 alternative interpolation algorithms, so that when the data is in a rectangular grid, they get a result from a stricter interpolation method. I haven't compared empirically whether it is better, but right now we have two alternatives in the code that can be tested when we have more data. It is easy to bypass one of them later if we find that it's unnecessary to have two. It's much harder to add the trilinear back, given how much time it's already taken to implement it. |
Signed-off-by: Tully Foote <tfoote@osrfoundation.org>
Sorry I accidentially pushed the CreateDepthSlice commit to this branch instead of my other one where I'm rebasing #142 https://github.com/osrf/lrauv/compare/tfoote/interpolation_review_rebase_127?expand=1 |
This reverts commit 100f368.
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
…nto mabelzhang/trilinear_interp
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
…(previously only in 3D fn). Fix test for 2D case. Add test for 1D and 3D cases. Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Some Christmas lights before the holidays.
Builds on top of #83
This PR adds trilinear interpolation and a "bary-linear" interpolation when points don't satisfy the requirements of trilinear interpolation.
TrilinearInterpolate()
first does a long series of checks to make sure the 8 points are indeed vertices of a prism. Then, it implements the trilinear interoplation on WikipediaBaryLinearInterpolate()
is a custom hybrid approach combining barycentric and linear interpolation that I hope works well. It reuses the functions written for barycenric and trilinear interpolations.It is called when
TrilinearInterpolate()
detects the 8 points are not vertices of a prism, which happens when the robot is on the boundaries.In this case, the 4 points on each z slice are treated as a degenerated tetrahedra, and the 2D overloaded version of
BarycentricInterpolate()
is called. The result is (x, y, z1), (x, y, z2), where (x, y, z) is the query point, and z1 and z2 are positions of the two z slices.Then, these two intermediate points are linearly interpolated (along z) to get the data value at (x, y, z).
With the latter, I can finally test simple data reasonably without running into "the algorithm doesn't even finish because the data doesn't satisfy the requirements."
Bookkeeping of the indices of the sub-cloud and sub-sub-cloud and mapping back to the original cloud is a bit crazy tedious. I think I shook out all the bugs.
Test case 1 (easy)
"Normal" use case where the robot's 8 interpolation neighbors are on the vertices of a prism, i.e. satisfies trilinear interpolation requirement.
Robot is exactly on a z slice.
interpolation_prism.csv
:Robot at
Turn on
DEBUG_INTERPOLATE = true
to see the result printouts.Interpolation result is 300, value of all the points on the top z slice robot is on:
Test case 2
More data points.
Robot is in a prism and between two z slices.
interpolation_test.csv
:Robot at
Interpolation result is 200, midpoint of 100 and 300:
Test case 3 (hard)
interpolation_test.csv
still.Robot is on the boundary, its nearest neighbors not a prism
Hybrid barylinaer interpolation is activated.
Interpolation result is 250:
Test case 4 (real data)
Real data
Because real data is ugly, it's hard to tell whether things work by reading numbers.
The standard in this test case is: It doesn't crash, and the interpolation result doesn't look bonkers from the data it's interpolating from.
(For functionality, use test cases 1-3 and the simple test files.)
Robot on boundary (not in prism). Activates hybrid bary-linear.
Future work
It would really help visual debugging to publish Markers marking where the found neighbors are, and a marker at the robot colored by the interpolation result. Currently we have to look at the numbers and think about it in our head, which doesn't scale when the numbers aren't nice.