-
Notifications
You must be signed in to change notification settings - Fork 344
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 bugs for grabbed self col checking due to asymmetricity and unordered-ness. #1438
Conversation
- Issue - This commit tries to improve the reported issue1, issue2, and issue3 : #1436 - Previously, _listNonCollidingLinksWhenGrabbed is asymmetric : the results obtained from grabbedBody1 is not same as the results obtained from grabbedBody2. - However, many codes in CheckSelfCollision assumes it's symmetric. The assumption was broken. In addition, such breakage was amplified after #1421. - Resolution - Instead of store the target link like the previous _listNonCollidingLinksWhenGrabbed_, store the information about the link pairs. This is more accurate and the same methodologies as non-adjacent-links in self colision checking. - Separate grabbed-grabber link pair and inter-grabbed link pair. - grabbed-grabber link pair, e.g. object-robot link pair, still exists in the Grabbed class as before. - inter-grabbed link pair now exists in the KinBody class, since if it's held in Grabbed, it becomes inconsistent and asymmetric. - Following the same methodologies in #1421, inter-grabbed link pairs are stored as unordered_map, and its key is combined env body indices of two grabbed bodies.
…ating the vector.
…CollidingGrabbedGrabberLinkPairsWhenGrabbed in CheckSelfCollisionChecking
…nkCollisions==false. also share the utilities for CollisioReport update and printing.
97ce218
to
d7b510e
Compare
…fixGrabbedSelfColCheckAsym
…fixGrabbedSelfColCheckAsym
…fixGrabbedSelfColCheckAsym
…fixGrabbedSelfColCheckAsym
…fixGrabbedSelfColCheckAsym
…inbodystatesaver.cpp.
…vBodyIndex should be always smaller than the second envBodyIndex to simplify the searching.
@Puttichai can you review? Thanks |
Looks good to me. |
@snozawa I have one concern regarding the conventions of ordering of elements of From the codes, there are two cases:
Functions like I think there are no problems with the current codes. But I wonder what we can do to make sure that in the future, people don't mistakenly use How do you think? |
/// \brief Compute environment body indices pair. pack the two bodies' envBodyIndices (32bit int) into one environment body indices pair (uint64_t). | ||
/// Here, environment body indices pair is uint64_t, which higher 32bits are for body2 envBodyIndex, and which lower 32bits are for body1 envBodyIndex. | ||
/// Note that index1 < index2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// \brief Compute environment body indices pair. pack the two bodies' envBodyIndices (32bit int) into one environment body indices pair (uint64_t). | |
/// Here, environment body indices pair is uint64_t, which higher 32bits are for body2 envBodyIndex, and which lower 32bits are for body1 envBodyIndex. | |
/// Note that index1 < index2. | |
/// \brief Returns a uint64_t that encodes the two given environment body indices. Body1's envBodyIndex is the lower | |
/// 32 bits. Body2's envBodyIndex is the higher 32 bits. This function is used to produce a key to | |
/// _mapListNonCollidingInterGrabbedLinkPairsWhenGrabbed, which is used for managing non-colliding link pairs | |
/// information between two grabbed bodies. | |
/// | |
/// The inputs must be such that index1 < index2. Raises an exception if index1 < index2 is not satisfied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snozawa Are there any particular reasons why you chose to force the caller to give correct ordering of indices instead of letting the function _ComputeEnvironmentBodyIndicesPair
take care of ordering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
this is because:
- some of the code path can assume always
index1 < index2
, and no need of reordering in that function. - The user code of this function is not just computing the indices pair. It most likely needs to compute the link pairs as well. in such case, such computation also requires correct ordering, so automatic reordering in
_ComputeEnvironmentBodyIndicesPair
might not help that much. c.f.KinBody::Clone
.
…grabbed-grabber link pairs. : #1438 (comment)
Thanks for your commet! Totally agree with it! |
Co-authored-by: Puttichai Lertkultanon <[email protected]>
Co-authored-by: Puttichai Lertkultanon <[email protected]>
Co-authored-by: Puttichai Lertkultanon <[email protected]>
…rabbed Co-authored-by: Puttichai Lertkultanon <[email protected]>
…gelog.rst, CMakeLists.txt
thanks~ |
Summary
CheckSelfCollision
about grabbed bodies, which is caused by asymmetricity of internal information, and thus, amplified after Optimize IsGrabbing / ResetGrabbed #1421.Issue1, Issue2, and Issue3
in Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436Issue
Asymmetricity of the data
CheckSelfCollision
assumes that the internal data like_listNonCollidingLinksWhenGrabbed
is kind of symmetric. Let's say, there are two grabbed bodiesA
andB
. If we check collision by usingA->_listNonCollidingLinksWhenGrabbed
,CheckSelfCollision
assumes that it should be same asB->_listNonCollidingLinksWhenGrabbe
. But, actually, it's not symmetric. In addition, such assumption is more broken after we lose the order of grabbed bodies due tounordered_map
.Resolution 1
We need to make data symmetric. To do so, instead of storing the target link like
_listNonColidingLinksWhenGrabbed
, this PR introduces the list of link pairs.There might be several ways for the link pairs.
ComputeListNonCollidingLinks
is called, the red is considered as colliding. the blue is considered as not colliding.A
andB
are both two-linked grabbed bodies. In the following explanation, we discuss the case when we computeComputeListNonCollindngLinks
forGrabbed
forA
.policy1
is the one inproduction
branch now.B
's links are checked with the wholeA
. It cannot be symmetric, so we need link pairs as data.policy2
andpolicy3
.policy2
ignores the whole links inB
if at least one link is colliding withA
. SinceA2
andB2
are collided, any link pairs betweenA
andB
are ignored inCheckSelfCollision
.policy3
ignores the only link pair which collides. The link pair(A2, B2)
is only ignored, and other pairs are still checked inCheckSelfCollision
.policy2
andpolicy3
, this PR goes for thepolicy3
, because:policy2
is too optimistic, and it might ignore dangerous physical collision.policy3
is actually same methodologies with non-adjacent-link pairs. so, it should be fine.CheckSelfCollision
consists of complex nestedfor
loop. in addition, it caused unnecessary iteration and checking if the pairs are already checked or not. By introducing the link pairs, i hopeCheckSelfCollision
code is more readable, predictable, and reducing the overhead.Resolution 2
Resolution 1
, it's bit odd thatGrabbed
class holds such information. Actually,Grabbed
forA
andGrabbed
forB
need to hold it.grabbed
andgrabber (e.g. robot)
: still inGrabbed::_listNonCollidingGrabbedGrabberLinkPairsWhenGrabbed
.grabbed
and anothergrabbed
: now inKinBody::_mapListNonCollidingInterGrabbedLinkPairsWhenGrabbed
.unordered_map
for the data. Note that this PR computes thekey
of theunordered_map
by combining two environment body indices into oneuint64_t
.CheckSelfCollision
for
loop simpler.