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

WIP: Fix clone and restore for invalid non colliding cache #1455

Open
wants to merge 49 commits into
base: production
Choose a base branch
from

Conversation

snozawa
Copy link
Collaborator

@snozawa snozawa commented Oct 24, 2024

summary

Issue

  • When _isListNonCollidingLinksValid is false, and Clone or kinbodysaver's restoring is called, Grabbed's internal savers are inconsistent.
  • For example, the original Grabbed has _pGrabbedSaver and _pGrabberSaver at the configuration A. Later, set the configuration to B. Then, call Clone or KinBodyStateSaver::Restore(pbody). In such case, the new Grabbed instance is created for the cloned/restored body. But, the newly created Grabbed has _pGrabbedSaver and _pGrabberSaver with the configuration B. Therefore, the derived listNonCollidingLinks are different between the original one and the new one.

Resolution

  • Add the special constructor for Grabbed to copy the saver's states from other Grabbed.
  • To do so, add the special constructor for KinBodyStateSaver, and RobotStateSaver to copy the states from other savers.
  • The usual user should use the existing constructor. The newly added one is introduced for very specific use case.
  • The new constructor does not support all Saver options. It only supports the copy-able states. If the state is pointer, the copying of it might not be always expected.

Shunichi Nozawa added 29 commits September 25, 2024 11:58
- 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.
…CollidingGrabbedGrabberLinkPairsWhenGrabbed in CheckSelfCollisionChecking
…nkCollisions==false. also share the utilities for CollisioReport update and printing.
- Issue
  - Previously, KinBody remembers the order when the grabbed bodies are grabbed.
  - However, it's broken since we introduced unordered_map. Especially, listNonCollidingLinksWhenGrabbed computation becomes less deterministic along with its lazy computatoin.
- Resolution
  - Since unordered_map is introduced to improve the performance, not good idea to revive std::vector as its representation.
  - Instead, introduce the unique id to remember the order when grabbed.
… 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.
- Issue
  - When the new Grabbed instance is created in saver or Clone, the _pGrabbedSaver and _pGrabberSaver of the new Grabbed are different from those of the original Grabbed.
  - Thus, if isListNonCollidingLinksValid=false, wrong state was used in ComputeListNonCollidingLinks.
- Resolution
  - Copy the consistent states from the original Grabbed to the new Grabbed.
  - To do so, introduce the constructor of Grabbed to copy the saver states from the original Grabbed. In addition, introduce the constructor of StateSavers to copy the states from the original savers.
  - If the states are not copy-able, throw exception. Also, this API is very advanced and not expected to be used from the usual users. Thus, make such functionality as the constructor.
Shunichi Nozawa added 20 commits October 25, 2024 17:41
…vBodyIndex should be always smaller than the second envBodyIndex to simplify the searching.
…deterministic grabbed self collision checking.
…GrabberSaver of Grabbed instances when cloning or restoring, to avoid incorrect computation of the non colliding list cache.
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.

1 participant