Skip to content

Is there an error in the minimum-maximum frustum distance? #164

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

Closed
facontidavide opened this issue Apr 6, 2020 · 8 comments
Closed

Is there an error in the minimum-maximum frustum distance? #164

facontidavide opened this issue Apr 6, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@facontidavide
Copy link

Hi,

when I was inspecting the code, I found something quite suspicious.

https://github.com/SteveMacenski/spatio_temporal_voxel_layer/blob/eloquent-devel/src/frustum_models/depth_camera_frustum.cpp#L97-L98

According to this mathematical formula, min and max distance refer to the distance between the origin and the eight corners of the frustum.

But I think this is NOT what you wanted.

If I don't mistake, _min_d and _max_d should refer to the distance of the planes parallel to the XY plane and perpendicular to the Z one.

@facontidavide
Copy link
Author

Right now I am super busy, so I don't have time to prepare a proper pull request, but I refactored from the ground up the depth camera frustum and the code is much easier to read.

Feel free to use this if you want:

https://bitbucket.org/snippets/df-bor/9nM868/frustum-calculation-fast-and-simple

@SteveMacenski SteveMacenski added the bug Something isn't working label Apr 6, 2020
@SteveMacenski
Copy link
Owner

SteveMacenski commented Apr 6, 2020

I think you are correct, it should be max (or min) * cos(phi/2) by that math, but it is a little convoluted. The ranges are wrong then by ~15% for some depth cameras.

Curious - what are you up to with this refactored code?

@facontidavide
Copy link
Author

facontidavide commented Apr 6, 2020

I wanted to use your frustum code to filter more efficiently a point cloud, when I realized the very same math could be written in a more simple way 😅

@SteveMacenski
Copy link
Owner

I wanted to use your frustum code, when I realized the very same math could be written in a more simple way

Yeah. I wasn't too concerned with the complexity on this since it is cached on startup. Once it worked, it worked, and I moved on. I was also trying to use the openVDB tools since I was learning that at the same time. It could be simplified for sure.

@facontidavide
Copy link
Author

I love this library, you did a great job... And you game me an excuse to learn OpenVDB 🤗

@SteveMacenski
Copy link
Owner

SteveMacenski commented Apr 6, 2020

I barely touched the surface of what its really good at. If you actually set it up as a signed distance field, you can get all the raycasting speeds ups too. However, I really never figured out a way to do that reliably with "real" data from "real" sensors since the surface of obstacles with noisy sensors isnt going to be consistent. Maybe it doesn't matter if I guestimate the surface but the overall the raycasting without the signed distance speed ups weren't enough for my needs. I needed something to drop CPU a bunch so I could process 8+ depth cameras.

If I were to start from scratch again, I'd probably take another crack at it. Then have frustum and raycasting based clearing. But still using it as a sparse volumetric grid anyhow is very useful and very fast random access.

@facontidavide
Copy link
Author

Yeah. I wasn't too concerned with the complexity on this since it is cached on startup.

Of course it is not about CPU, it is just for readability purposes. If the code is readable, it is easier to find bugs or fault in the reasoning... like min/max distance !

facontidavide added a commit to facontidavide/spatio_temporal_voxel_layer that referenced this issue Apr 7, 2020
In thoery, this modification is just about readability. It should give
EXACTLY the same result, but...

In practice, we fixed also a problem about mini/max distance, as
reported in SteveMacenski#164
@SteveMacenski
Copy link
Owner

Resolving here shortly for Noetic and Foxy + newer in ROS2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants