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

Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436

Open
snozawa opened this issue Sep 20, 2024 · 1 comment
Open

Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436

snozawa opened this issue Sep 20, 2024 · 1 comment
Assignees

Comments

@snozawa
Copy link
Collaborator

snozawa commented Sep 20, 2024

Summary

  • Grabbed and CheckSelfCollision originally had a problem, but it's quite amplified when we introduced unordered_set for grabbed bodies in Optimize IsGrabbing / ResetGrabbed #1421.
  • Before Optimize IsGrabbing / ResetGrabbed #1421, the order of grabbed bodies are guaranteed, but after that, the order is not guaranteed, and breaks many assumptions and amplifies the existed issues.
  • Now I'm making the branch to fix these problems in my local, and plan to create the PR later on.

Issue1

  • Example : How to run Issue2 test in Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436 (comment)
  • Background
    • Let's say, the robot is grabbing two bodies, grabbedBody1 and grabbedBody2. These are grabbed by different links, e.g. the robot needs to care about the self collision between these two.
    • Many codes in CheckSelfCollision assumes that the collision checking is symmetric, e.g. order of grabbedBody1 and grabbedBody2 does not matter. Also, the code is optimized by utilizing this assumption, for example:
      • Optimization of nested for loop :
        // Since collision checking is commutative (i.e. CheckCollision(link1, link2) == CheckCollision(link2, link1)), checking it once per pair is sufficient.
        for( size_t indexGrabbed2 = indexGrabbed1 + 1; indexGrabbed2 < numGrabbed; ++indexGrabbed2 ) {
      • Skip the pairs based on checking of _listNonCollidingLinksWhenGrabbed :
        if( std::find(nonCollidingLinks1.begin(), nonCollidingLinks1.end(), pGrabbedBody2Link) != nonCollidingLinks1.end() ) {
        ,
        if( std::find(nonCollidingLinks2.begin(), nonCollidingLinks2.end(), pGrabbedBody1Link) != nonCollidingLinks2.end() ) {
  • Issue
    • However, we had slight asymmetricity before Optimize IsGrabbing / ResetGrabbed #1421, and it's amplified after that PR.
    • In detail, in some case, Grabbed for grabbedBody1 might contain grabbedBody2 in _listNonCollidingLinksWhenGrabbed. But, Grabbed for grabbedBody2 mignt not contain grabbedBody1. So, the internal data are asymmetric.
    • This breaks assumptions in theoretical collision checking, and its computatoinal codes.
      • False positive issue : For example of this code, it assumes that nonCollidingLinks1 and nonCollidingLinks2 are symmetric. But, if it's not symmetric, like nonCollidingLinks1=[] and nonCollidingLinks2=[grabbedBody1], the code does not enter continue, and thus, it check collision between grabbedBody1 and grabbedBody2. But in the next iteration here, it started checking about grabbedBody2, and since it contains grabbedBody1 in the list, it checks the collision between grabbedBody1 and grabbedBody2 again. I confirmed that same collision paris are checked twice from print message.
      • False negative issue : I havne't seen the exact case of false negative case yet, e.g. necessary pairs are skipped. but it might happen and if so, it's scary.
    • In the above, I use the words like in some case and might, since the whole situation is governed by the ordering by unordered_set. Thus, the overall behavior looks quite undeterministic, and checking result might be flaky according to the situation.
  • Possible resolutions
    • First, I'm trying to keep the unordered_set for grabbed bodies as it is, and fix the problems in other part, like the followings:
      1. Add more codes to handle this asymmetricity in CheckSelfCollision.
      2. Make the information about _listNonCollidingLinksWhenGrabbed symmetric.
    • I think 1 looks harder since needs more complicated code in CheckSelfCollision, and it might increase the computation. Instead, I guess 2 might be reasonable and now I'm trying 2.

Issue2

  • Example : How to run Issue1 test in Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436 (comment)
  • Background
    • The grabbed bodies with multiple links are not correctly handled in the current production branch.
    • Actually, maybe we don't have the use cases with multiple grabbed bodies with multiple links yet. But, this issue is potentially have problems, and if we'd like to resolve the Issue 1 and its clearning-up, this issue becomes big bottle neck.
    • Let's say, the robot is grabbing two bodies A and B. Both of them are grabbed by differetn links, and both of them has two links (A1, A2 and B1, B2). Also, initially A2 and B2 are colliding.
    • whengrabbed
  • Issue
    • Case 1 : A's ComputeListNonCollidingLinks is called first:
      • A's _listNonCollidingLinksWhenGrabbed becomes [] related to the asymmetricity in Issue1.
      • B's _listNonCollidingLinksWhenGrabbed contains [A1], since A1 is only collision free link.
      • In CheckSelfCollision, in B's iteration, it iterates with B1 and B2. So, the considered pairs are (A1, B1) and (A1, B2). A's iteration does not check anything sice _listNonCollidingLinksWhenGrabbed is empty.
    • Case 2 : B's ComputeListNonCollidingLinks is called first:
      • B's _listNonCollidingLinksWhenGrabbed becomes [] related to the asymmetricity in Issue1.
      • A's _listNonCollidingLinksWhenGrabbed contains [B1], since B1 is only collision free link.
      • In CheckSelfCollision, in A's iteration, it iterates with A1 and A2. So, the considered pairs are (A1, B1) and (A2, B1). B's iteration does not check anything sice _listNonCollidingLinksWhenGrabbed is empty.
    • By comparing these two cases:
      • The checked pairs are different due to the ordering. Also, it looks undeterministic from outside of CheckSelfCollision.
      • There seems the chance to skip the necessary pairs. In the latter case for example, (A1, B2) is skipped.
        • aftergrabbed
      • Internally, the same collision paris are compued twise, like Issue1.
  • Cause
    • One of the cause of this issue is ordering by unordered_set.
    • Another issue is, when we compute the _listNonCollidingLinksWhenGrabbed, we compute link vs body collision, instead of link vs link collision. Thus, the information about the pairs are not preserved. This also causes another kind of asymmetricity.
      • The current implementation policy seems not consistent. If either of the folowing when we compute _listNonCollidingLinksWhenGrabbed, it's reasonable.
        • Policy 1 (agressive policy)
          • If A and B have collision, these are not added to _listNonCollidingLinksWhenGrabbed. Thus, both A's _listNonCollidingLinksWhenGrabbed and B's _listNonCollidingLinksWhenGrabbed are empty. I think this case is consistent.
          • Pros : faster to compute.
          • Cons : physically agressive, e.g. might cause the collision in the real world. In addition, this does not make sense for robot-arm vs grabbed-body collision.
        • Policy 2 (accurate policy)
          • We check collision status for all link pairs of A and B. _listNonCollidingLinksWhenGrabbed stores the pair of LinkConstPtr in some way. The result of the picture is, _listNonCollidingLinksWhenGrabbed=[(1, B1), (A1, B2), (A2, B1)] and we can make it symmetric between A and B.
          • Pros : physically accurate, e.g. close the the real world colliding. Applicable for robot-arm vs grabbed-body collision.
          • Cons : needs more memory for _listNonCollidingLinksWhenGrabbed. Might take time to compute in ComputeListNonCollidingLinks.
  • Resolution
    • possible resolution might be Policy 2 and make it symmetric somehow.
    • That way, it's not affected by the ordering of grabbed bodies.

Issue3

Issue4

  • Example : How to run Issue4 test in Grabbed, CheckSelfCollision, and unordered grabbed bodies issues. #1436 (comment)
  • Background
    • Lazy computation of _ListNonCollidingLinksWhenGrabbed is introduced in Lazy Computation of List Non-Colliding Links #1038
    • Before that, when Grabbed is constructed, list is computed. After that, Grabbed constructor do nothing, and when we call CheckSelfCollision at the first time, list is computed, by ComputeListNonCollidingLinks.
    • Since it's lazy computation, the result should not change depending on the timing when ComputeListNOnCollidingLinks. However, it's changing.
  • Issue
    • When the robot grabs grabbedBody1, and then grabbedBody2, Grabbed for grabbedBody1 should not know about the grabbedBody2, since it was not there when grabbedBody1 is grabbed. However, when we postpone the computation, grabbedBody1 might consider the collision checking with grabbedBody2.
    • Also, this issue is amplified unordered_map.
  • Resolution
    • need to define the policy.
    • Need to remember the order of grabbed bodies.

cc @Puttichai @rschlaikjer @yoshikikanemoto @kanbouchou @rdiankov

@snozawa snozawa self-assigned this Sep 20, 2024
@snozawa
Copy link
Collaborator Author

snozawa commented Sep 23, 2024

Reproduction for Issues

  • Add debug print
# In openrave directory
git checkout -b tmptestgrabissues 8b196c7e6b0ff0bd7fdb0efc01f37a8c0c8cbe9a
# Put the attached patch and patch it.
patch src/libopenrave/kinbodycollision.cpp < colcheckdebug.patch

testgrabissues.zip

How to run Issue1 test

  • run
openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue1(env, robot)
  • Result
Setup done.
CheckSelfCollision
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,]
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,grabbedBody2/link0,]
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/finger1
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBody1/link0 vs grabbedBody2/link0
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/finger2
2024-09-23 10:19:12,151 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs grabbedBody2/link0
  • According to the printed message, the same collision pair grabbedBody1/link0 vs grabbedBody2/link0 is checked twice.

How to run Issue2 test

  • Run
openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue2(env, robot)
  • Results
Setup done.
CheckSelfCollision
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBodyB; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,]
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBodyA; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,grabbedBodyB/link0,]
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/finger1
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/finger1
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBodyA/link0 vs grabbedBodyB/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBodyA/link1 vs grabbedBodyB/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/finger2
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/finger2
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs grabbedBodyB/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs grabbedBodyB/link0
CheckSelfCollision after RegrabAll
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBodyA; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,]
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBodyB; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,grabbedBodyA/link0,]
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link0 vs testgrabrobot/finger2
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyA/link1 vs testgrabrobot/finger2
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBodyB/link0 vs grabbedBodyA/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBodyB/link1 vs grabbedBodyA/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/base
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/Link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/flange
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs testgrabrobot/finger1
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs testgrabrobot/finger1
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link0 vs grabbedBodyA/link0
2024-09-23 10:24:26,259 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBodyB/link1 vs grabbedBodyA/link0
  • In the former case, the pairs (A0, B0) and (A1, B0) are checked. But, (A0, B1) are not checked.
  • In the latter case, the pairs (A0, B0) and (A0, B1) are checked. But, (A1, B0) are not checked.

How to run Issue3 test

  • Run
openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue3(env, robot)
  • Results
Setup done.
First CheckSelfCollision
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:90 KinBody::CheckSelfCollision] ComputeListNonCollidingLinks for grabbedBody2
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,grabbedBody1/link0,]
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:90 KinBody::CheckSelfCollision] ComputeListNonCollidingLinks for grabbedBody1
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,grabbedBody2/link0,]
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 10:20:28,164 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/finger1
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBody1/link0 vs grabbedBody2/link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/finger2
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs grabbedBody2/link0
Second CheckSelfCollision
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,]
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,grabbedBody2/link0,]
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/finger1
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBody1/link0 vs grabbedBody2/link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/finger2
2024-09-23 10:20:28,165 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs grabbedBody2/link0
  • In the First CheckSelfCollision message, grabbedBody2 contains grabbedBody1 in _listNonCollidingLinksWhenGrabbed. But, it's changed in the Second CheckSelfCollision.

How to run Issue4 test

  • Run case0
openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue4_0(env, robot, callCheckSelfCollisionInbetween = False)

openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue4_0(env, robot, callCheckSelfCollisionInbetween = True)
  • Results (callCheckSelfCollisionInbetween = False)
Setup done.
Call CheckSelfCollision after Grab2.
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,]
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,]
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/finger1
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 13:57:16,371 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
  • Result (callCheckSelfCollisionInbetween = True)
Setup done.
Call CheckSelfCollision right after Grab1
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:90 KinBody::CheckSelfCollision] ComputeListNonCollidingLinks is called for grabbedBody1
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,]
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
Call CheckSelfCollision after Grab2.
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,]
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger1,grabbedBody1/link0,]
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBody2/link0 vs grabbedBody1/link0
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/finger1
2024-09-23 13:57:40,514 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs grabbedBody1/link0
  • Run case1
openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue4_1(env, robot, callCheckSelfCollisionInbetween = False)

openrave.py -i testgrabscene.mujin.json
import testgrabissues; testgrabissues.TestIssue4_1(env, robot, callCheckSelfCollisionInbetween = True)
  • Results (callCheckSelfCollisionInbetween = False)
Setup done.
Call CheckSelfCollision after Grab2.
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,]
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,grabbedBody2/link0,]
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/base
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/Link0
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody2/link0 vs testgrabrobot/flange
2024-09-23 13:58:32,094 openrave [WARN] [kinbodycollision.cpp:195 KinBody::CheckSelfCollision]   colcheck2 : grabbedBody1/link0 vs grabbedBody2/link0
  • Results (callCheckSelfCollisionInbetween = False)
Setup done.
Call CheckSelfCollision right after Grab1
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:90 KinBody::CheckSelfCollision] ComputeListNonCollidingLinks is called for grabbedBody1
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,]
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 13:58:46,773 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/finger2
Call CheckSelfCollision after Grab2.
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody1; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,testgrabrobot/finger2,]
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:97 KinBody::CheckSelfCollision] _listNonCollidingLinksWhenGrabbed for grabbedBody2; [testgrabrobot/base,testgrabrobot/Link0,testgrabrobot/flange,]
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/base
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/Link0
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/flange
2024-09-23 13:58:46,774 openrave [WARN] [kinbodycollision.cpp:130 KinBody::CheckSelfCollision]   colcheck1 : grabbedBody1/link0 vs testgrabrobot/finger2
  • According to the printed results, the results of _listNonCollidingLinksWhenGrabbed of grabbedBody2 are different depending on the timing when ComputeListNonCollidingLinks is called. Especially, the case callCheckSelfCollisionInbetween = False lacks the collision checking between grabbedBody1 and grabbedBody2.
  • case0 might be resolved if the symmericity of grabbed information is properly implemented. However, case1 seems need to remember the order of grabbed bodies.

snozawa pushed a commit that referenced this issue Sep 24, 2024
snozawa pushed a commit that referenced this issue Sep 25, 2024
- 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.
snozawa pushed a commit that referenced this issue Oct 19, 2024
… it means pOtherGrabbed is grabbed later than 'this'. Thus, pOtherGrabbed did not exist when 'this' was grabbed.

The results of lazy computation should be same as the result of non-lazy computation. Therefore, we should not compute the inter-grabbed collision checking with pOtherGrabbed.
This resolves Issue4 in #1436.
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

No branches or pull requests

1 participant