Skip to content
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

Fix the computation of shadow points #22

Merged
merged 1 commit into from
Aug 13, 2020

Conversation

chris20623
Copy link
Contributor

Issue

I think the computation of shadow points does not work correctly in some cases. Shadow points may be missed and classified as outside points instead.

Analysis

For each robot body, the points of intersection with the ray to the considered point are computed. These points of intersection are appended to the intersections vector. Then, the sign of a dot product involving the first point of intersection is checked.

However, the intersections vector is not cleared before the next body is checked. So, if the first intersecting body yields a negative dot product, positive dot products resulting from subsequent bodies will be ignored.

Solution

Move the definition of the intersections vector into the scope of the loop body so that the vector is reset before each intersectsRay() call and intersections[0] subsequently corresponds to the j-th robot body.

Successfully tested on melodic and noetic.

@v4hn
Copy link
Member

v4hn commented Aug 12, 2020

I'm a bit surprised this is still used, because robot_body_filter provides a pr2-independent generalization. :-)

@peci1 could you review this patch please? Looks reasonable to me with the explanation.

@chris20623
Copy link
Contributor Author

Thanks for the prompt reply.

I'm a bit surprised this is still used, because robot_body_filter provides a pr2-independent generalization. :-)

We have been using robot_self_filter (with own modifications) for quite a long time, but didn't need the shadow computation feature until recently. I see that this issue has already been fixed in robot_body_filter (by calling intersections.clear() in line 221 of src/RayCastingShapeMask.cpp, which should eventually have the same effect).

Perhaps it would be helpful if someone could add a reference to robot_body_filter on the ROS wiki page http://wiki.ros.org/robot_self_filter. Right now, it is quite difficult to see which of all those forks is the most up-to-date one.

@v4hn
Copy link
Member

v4hn commented Aug 13, 2020

Thanks for the prompt reply.

You were just lucky. ;)

I see that this issue has already been fixed in robot_body_filter (by calling intersections.clear() in line 221 of src/RayCastingShapeMask.cpp, which should eventually have the same effect).

Thanks for looking through the code, I only had a glimpse and did not immediately find the corresponding code path.
clearing the vector should indeed be preferred to avoid additional allocations in each iteration.
Could you update the patch to do so?

The state of the robot_self_filter/robot_body_filter is somewhat sad. The PR2 repository is not actively worked on and thus people forked quite a lot. I referenced @peci1's fork because I know he actively works on quite a number of issues of this code, contributing great improvements. He should have asked to take over maintenance of this repository when he forked 😎

@peci1 can we/should we make more prominent advertisement for your fork/rewrite here?

@peci1
Copy link

peci1 commented Aug 13, 2020

Hi, the solution proposed by @v4hn would be preferred.

@v4hn Feel free to advertise robot_body_filter ;) If you feel the need for a larger discussion about robot_self_filter vs robot_body_filter, open an issue and invite me in for the discussion.

Clear the intersections vector before each intersectsRay() call so that intersections[0] subsequently corresponds to the j-th body.
Previously, only the dot product resulting from the first body intersecting the ray has been considered, ignoring all further intersections which have been appended to the intersections vector.
@chris20623 chris20623 force-pushed the fix_shadow_computation branch from 16085e5 to 376b9d3 Compare August 13, 2020 11:30
@v4hn
Copy link
Member

v4hn commented Aug 13, 2020

If you feel the need for a larger discussion about robot_self_filter vs robot_body_filter, open an issue and invite me in for the discussion.

See #23 .

@chris20623 I'll merge your patch if CI passes.

@chris20623
Copy link
Contributor Author

The PR has been updated by using the solution chosen in robot_body_filter (including the comments, which are very helpful to understand what the code is doing).

@v4hn v4hn merged commit b24715a into PR2:indigo-devel Aug 13, 2020
@chris20623
Copy link
Contributor Author

Thanks a lot for reviewing and merging this so fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants