rdiankov / openrave

Open Robotics Automation Virtual Environment: An environment for testing, developing, and deploying robotics motion planning algorithms.
http://www.openrave.org
Other
684 stars 339 forks source link

optimize usages of _setGrabberLinkIndicesToIgnore #1389

Closed yoshikikanemoto closed 1 month ago

yoshikikanemoto commented 1 month ago

Found that Environment::UpdatePublishedBodies was spending long time in GetGrabbedInfo because of the inefficient usage of _setGrabberLinkIndicesToIgnore.

before:

for link in links:
     if link.GetIndex() in _setGrabberLinkIndicesToIgnore:
         # do something to ignored link

after:

for linkIndex in _setGrabberLinkIndicesToIgnore:
     if linkIndex < len(links):
         link = links[linkIndex]
         # do something to ignored link
    else:
        log.warning('something is wrong!')
rdiankov commented 1 month ago

Thanks~ To tell you the truth, I'd like to get rid of all our usages of std::set...