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

Skip grab saver for unjointed bodies #1484

Merged
merged 9 commits into from
Jan 31, 2025

Conversation

rschlaikjer
Copy link
Collaborator

  • When grabbing a body with a body that has no joints, we can skip saving the current state of the body since all links are effectively rigid, and so would be excluded from the results of ComputeListNonCollidingLinks (all links are rigidly attached to the grabbing link)
  • It doesn't look like we need to save velocities at all for the ComputeListNonCollidingLinks savers (has no impact on collision?)
  • Convert a couple of shared pointer copies to shared pointer references in ComputeInternalInformation

@rdiankov
Copy link
Owner

@snozawa Can you approve this? Thanks

_listNonCollidingIsValid = false;
const bool bDisableRestoreOnDestructor = true; // This is very important! These saver are used only in ComputeListNonCollidingLinks and we don't want to restore on destructor.
static const int saverOptions = KinBody::Save_LinkTransformation | KinBody::Save_LinkEnable | KinBody::Save_JointLimits | KinBody::Save_ConnectedBodies;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdiankov cc @rschlaikjer While checking this code, I noticed that KinBody::ComputeInverseDynamics doesn't seem to care about grabbed. Is it intentional that ComputeInverseDynamics doesn't consider grabbed?

_CreateSaverForGrabbedAndGrabber(_pGrabbedSaver,
pGrabbedBody,
KinBody::Save_LinkTransformation|KinBody::Save_LinkEnable|KinBody::Save_JointLimits,
saverOptions,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone tries to set velocity of a currently grabbed kinbody, should we reject it because its velocity is determined by the grabbing link? If such guarantee exists that body's velocity doesn't get modified while being grabbed, it is fine to not save at the time of grabbing and restore at the time of releasing. @rdiankov @rschlaikjer

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be okay if velocity is not saved..

_listNonCollidingIsValid = false;
const bool bDisableRestoreOnDestructor = true; // This is very important! These saver are used only in ComputeListNonCollidingLinks and we don't want to restore on destructor.
static const int saverOptions = KinBody::Save_LinkTransformation | KinBody::Save_LinkEnable | KinBody::Save_JointLimits | KinBody::Save_ConnectedBodies;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @rschlaikjer !

Apart from Save_LinkVelocities, why you added Save_ConnectedBodies?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Save_LinkVelocities are removed from constructor, but still in ComputeListNonCollidingLinks.

Is this just in case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure where that came from - might have been an intermediate change. Since it gets added in _CreateSaverForGrabbedAndGrabber for robots shouldn't be needed as you say, removed.

For velocities, I think you're right - if we don't save/restore it using the grab saver, it should be fine to not save/restore it in ComputeListNonColliding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal tests re-run and pass using controllercommon MR 1185 pipeline 1072255

@rdiankov rdiankov merged commit 83f0af7 into production Jan 31, 2025
1 check passed
@rdiankov rdiankov deleted the rs-skip-grab-saver-for-unjointed-bodies branch January 31, 2025 17:09
@rdiankov
Copy link
Owner

thanks~

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.

5 participants