Skip to content

Commit

Permalink
Merge branch 'rs-update-publish-bodies-opt' into rs-test-perf-combo
Browse files Browse the repository at this point in the history
  • Loading branch information
rschlaikjer committed Mar 13, 2024
2 parents ec61b64 + 6d518ca commit 955d937
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 0.141.2
===============

- Cache the absence of collision bodies for a kinbody in the FCL collision manager, improving collision checking performance
- Instead of unconditionally resetting BodyState in _UpdatePublishedBodies, first test whether the state has already been initialized from the given body / update stamp. If it has, skip re-extracting all data. Since bodies are in a relatively stable order, this significantly improves average-case performance.

Version 0.141.1
===============
Expand Down
44 changes: 26 additions & 18 deletions src/libopenrave-core/environment-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2813,27 +2813,35 @@ class Environment : public EnvironmentBase
}

KinBody::BodyState& state = _vPublishedBodies.at(iwritten);
state.Reset();
state.pbody = pbody;
pbody->GetLinkTransformations(state.vectrans, vdoflastsetvalues);
pbody->GetLinkEnableStates(state.vLinkEnableStates);
pbody->GetDOFValues(state.jointvalues);
pbody->GetGrabbedInfo(state.vGrabbedInfos);
state.strname =pbody->GetName();
state.uri = pbody->GetURI();
state.updatestamp = pbody->GetUpdateStamp();
state.environmentid = pbody->GetEnvironmentBodyIndex();
if( pbody->IsRobot() ) {
RobotBasePtr probot = RaveInterfaceCast<RobotBase>(pbody);
if( !!probot ) {
RobotBase::ManipulatorPtr pmanip = probot->GetActiveManipulator();
if( !!pmanip ) {
state.activeManipulatorName = pmanip->GetName();
state.activeManipulatorTransform = pmanip->GetTransform();

// If this state was already inititalized from this body, we might be able to skip updating it if the body itself hasn't changed.
const bool canSkipUpdate = state.pbody == pbody && state.updatestamp == pbody->GetUpdateStamp();

// Only if the body is mismatched with the state do we need to do a full update
if (!canSkipUpdate) {
state.Reset();
state.pbody = pbody;
pbody->GetLinkTransformations(state.vectrans, vdoflastsetvalues);
pbody->GetLinkEnableStates(state.vLinkEnableStates);
pbody->GetDOFValues(state.jointvalues);
pbody->GetGrabbedInfo(state.vGrabbedInfos);
state.strname = pbody->GetName();
state.uri = pbody->GetURI();
state.updatestamp = pbody->GetUpdateStamp();
state.environmentid = pbody->GetEnvironmentBodyIndex();
if (pbody->IsRobot()) {
RobotBasePtr probot = RaveInterfaceCast<RobotBase>(pbody);
if (!!probot) {
RobotBase::ManipulatorPtr pmanip = probot->GetActiveManipulator();
if (!!pmanip) {
state.activeManipulatorName = pmanip->GetName();
state.activeManipulatorTransform = pmanip->GetTransform();
}
probot->GetConnectedBodyActiveStates(state.vConnectedBodyActiveStates);
}
probot->GetConnectedBodyActiveStates(state.vConnectedBodyActiveStates);
}
}

++iwritten;
}

Expand Down

0 comments on commit 955d937

Please sign in to comment.