Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/libopenrave/kinbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,15 +2193,16 @@ void KinBody::SetDOFValues(const std::vector<dReal>& vJointValues, const Transfo
if( _veclinks.size() == 0 ) {
return;
}
Transform baseLinkTransform = bodyTransform * _baseLinkInBodyTransform;
Transform tbase = baseLinkTransform*_veclinks.at(0)->GetTransform().inverse();
_veclinks.at(0)->SetTransform(baseLinkTransform);

// apply the relative transformation to all links!! (needed for passive joints)
for(size_t i = 1; i < _veclinks.size(); ++i) {
_veclinks[i]->SetTransform(tbase*_veclinks[i]->GetTransform());
}
SetDOFValues(vJointValues,checklimits);
// Reuse the SetTransform loop instead of setting link[0] directly and propagating a relative
// transform to link[i>0]. The direct set lets the floating-point error in
// baseLinkTransform * link[0].GetTransform().inverse() be the same on every call, so the
// non-root link transforms drift by that same epsilon each call and accumulate. Applying
// tapply to every link (including link[0]) lets link[0] absorb the same epsilon, so the next
// call's tapply is approximately (identity - epsilon) and the drift cancels rather than
// compounds. For DOF>0 bodies the subsequent SetDOFValues recomputes link transforms via FK
// and overwrites this loop's output, so the change only affects 0-DOF multi-link bodies.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

// For DOF>0 bodies the subsequent SetDOFValues recomputes link transforms via FK and overwrites this loop's output, so the change only affects 0-DOF multi-link bodies.

I think "the change" may make sense in the PR context where we are seeing old and new code side-by-side. However, once merged into production, this comment may not be clear what "the cahnge" refers to. Can you rephrase to something which makes sense without knowing the old code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for checking. I updated the comment.

_SetTransformNoPostProcess(bodyTransform);
SetDOFValues(vJointValues, checklimits);
}

void KinBody::SetDOFValues(const std::vector<dReal>& vJointValues, uint32_t checklimits, const std::vector<int>& dofindices)
Expand Down
Loading