-
Notifications
You must be signed in to change notification settings - Fork 466
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
get3DPoint() of SelectionManager returns inconsistent results #1486
Comments
I solved my problem for now by using a ray/triangle intersection method. It can be rather slow though when a big mesh is loaded, so I'm still interested if there is a solution using the camera projection method. |
Could you please provide the source to your new tool to facilitate the reproduction of the issue? |
Here is the header and source file. Nothing complicated, it tries to get a 3D Point while moving the mouse and if found, shows a sphere at that position. On left mouse button click the sphere is placed down. The sphere itself is a simple STL that I created but I don't know how to attach it. (For anyone wondering: Yes, this doesn't actually select anything yet, it's just the first step) mesh_selection_tool.h
mesh_selection_tool.cpp
|
The just code computes the 3d coordinates of a 2d image patch (or a single pixel) and looks reasonable. I suspect simple rounding errors. rviz/src/rviz/selection/selection_manager.cpp Lines 244 to 314 in 51af282
|
@rhaschke And since the error changes depending on camera position and angle, maybe there is a way to reduce the error by changing the FOV? I'm just guessing here, since I have no experience in this area. |
I wrote a simple rviz tool for selecting points on a mesh by using this tutorial as an template. Instead of flags, it spawns in a simple sphere by clicking on the surface of a object/mesh. I retrieve the spawn position with the help of the
rviz::SelectionManager::get3DPoint()
function.I noticed that the returned position is rather inconsistent. When selecting various points on the top surface of a 1x1x1 cube marker, the Z-position can vary between 0.5013 and 0.4999 (total: 0.0014). With a 0.1x0.1x0.1 cube the Z-position varies between 0.05168 and 0.04893 (total: 0.00275). The effect is stronger on non perfectly flat surfaces like those of a mesh.
I noticed on my meshes, which have a relatively flat top surface, that my selected point would sometimes be above or even below the surface. The expected Z-position should be somewhere around 0.065 but in the following example the actual position is 0.068 which messes up my whole concept for selecting points on meshes. Most of the time I get the correct position but that changes depending on the camera angle and distance.
Sadly, I'm not allowed to upload the mesh, the most I can do is show the wireframe of the top surface:
My current understanding is, that the selection happens by some kind of flattening/projecting of the 3D scene to the 2D view and then corresponding the mouse position to the 3D pixel underneath it. My guess is, that the results of the
rviz::SelectionManager::get3DPoint()
function are influenced by the camera settings.Is there a way to solve this problem or at least mitigate it? Should I choose different camera settings for different mesh sizes?
My environment
The text was updated successfully, but these errors were encountered: