norlab-ulaval / libpointmatcher

An Iterative Closest Point (ICP) library for 2D and 3D mapping in Robotics
BSD 3-Clause "New" or "Revised" License
1.61k stars 544 forks source link

Bug fix in `SurfaceNormalOutlierFilter` #457

Closed cjamin closed 3 years ago

cjamin commented 3 years ago

This call to anyabs should not be here.

Here is an example: if maxAngle = 0.2, an angle of 3.1 radians should obviously be reject. But with the current code, eps = cos (0.2) ~= 0.98, and abs(cos(3.1) ~= 0.999, so it is accepted. With this fix, cos(3.1 ~= -0.999, it is rejected.

ethzasl-jenkins commented 3 years ago

Can one of the admins verify this patch?

pomerlef commented 3 years ago

ok to test

pomerlef commented 3 years ago

@simonpierredeschenes could you have a look?

simonpierredeschenes commented 3 years ago

I don't think this is the wanted behavior, the call to anyabs is there to allow normals of opposite directions, thus from parallel surfaces. If we remove it, users will need to call the OrientNormalsDataPointsFilter filter to orient all normals in the same direction. This filter acts almost randomly for points far from the robot, so they would likely be discarded by the outlier filter.

cjamin commented 3 years ago

Then the name and this documentation are misleading: "Maximum authorised angle between the 2 surface normals (in radian) - min: 0.0 - max: 3.1416". If it was meant to work like you say, the max would be PI/2, not PI.

I use this filter to prevent matching points that are on two different faces of a wall, so this is really useful.

A solution could be to add a parameter to choose between both behaviors.

simonpierredeschenes commented 3 years ago

@cjamin I discussed with my colleagues and it appears I was mistaken, the filter is meant to avoid matching different faces of a wall, as you said. The fix you did solves the issue. Could you please add a small sentence to the documentation that says that the filter must be used in combination with the OrientNormalsDataPointsFilter to get the expected behavior, to avoid some confusion for the users? Then the PR would be ready to merge. Thanks!

cjamin commented 3 years ago

All right, thanks.

The "official" documentation only mention this filter in this page, without any explanation. This documentation (this link I gave earlier) seems unofficial. So, if I'm not mistaken, I can't change it here in the repository.

simonpierredeschenes commented 3 years ago

Oh, I meant in the outlier filter description (here). This code is used to auto-generate this documentation. This documentation also comes from us, we will link it in the tutorials in the future.

pomerlef commented 3 years ago

The utest are not passing:

Error Message
/home/jenkins/workspace/pointmatcher/label/ubuntu-xenial/utest/utest.cpp:158
Expected: (rel_err) < (0.03), actual: 0.0650631 vs 0.03
This error was caused by the test file:
   ../examples/data/icp_data/force4DOFForPointToPlaneMinimizer.yaml
cjamin commented 3 years ago

I updated the documentation.

Regarding the test, I can only guess that the test used to pass for bad reasons... FYI, I've been testing this patch for a few month on a project now, and it works like a charm.

pomerlef commented 3 years ago

I've updated the test results on your branch. I'll merge as soon as the CI is letting me. Thanks for the patch!

cjamin commented 3 years ago

Thanks for integration!