roboticslab-uc3m / openrave-yarp-plugins

OpenRAVE plugins to interface OpenRAVE with YARP.
https://robots.uc3m.es/openrave-yarp-plugins/
GNU Lesser General Public License v2.1
3 stars 1 forks source link

Collision model (convex decomposition) must be re-generated each run #83

Closed jgvictores closed 6 years ago

jgvictores commented 6 years ago

Collision model must be re-generated each run, namely these lines.

Possible hint at runtime:

No handlers could be found for logger "openravepy.databases.convexdecomposition"
RaulFdzbis commented 6 years ago

This is an already known behaviour with convexdecomposition, the problem is that when the convex decomposition model (cdmdel) is generated, this cdmodel is saved in the openrave database as a function of it's geometry. If some padding is done in the cdmodel, the geometry changes and therefore its hash. Since the "load" function always tries to load the not padded cdmodel, this will result in the program generating a new convexdecomposition model each time.

This behaviour has also been reported in the openrave forum.

Until its not fixed, a possible solution is to manually rename the padded model (robot_padding.pp) to have the same name as the not padded one (robot.pp).

jgvictores commented 6 years ago

Or at least slow... Some pointers:

jgvictores commented 6 years ago

More refs, freshly moved into this repo: #84

jgvictores commented 6 years ago

From what was commented at https://github.com/roboticslab-uc3m/openrave-yarp-plugins/issues/83#issuecomment-372999608 and with @RaulFdzbis in person, should be a very simple issue related to path names. Possibly due to https://github.com/rdiankov/openrave/issues/118, OpenRAVE does not look for the padded version.

jgvictores commented 6 years ago

No handlers could be found for logger "openravepy.databases.convexdecomposition"

For the record, this happens upon cdmodel.load() returning False.

jgvictores commented 6 years ago

For the record, cdmodel.generate(padding=0.02) takes about 2 minutes, and uses 2 of a 4 core machine (1 constant, switching the other).

jgvictores commented 6 years ago

cdmodel.save() takes 5 s, generates the 60 MB model robot.29d30d6ed41a0d1254635867fcebcd97/convexdecomposition_0.020.pp (note the same hash, this is good).

jgvictores commented 6 years ago

cdmodel.setrobot() takes another 10-15 s.

jgvictores commented 6 years ago

cdmodel.show() possibly stuck in while True.

jgvictores commented 6 years ago

...but can be interrupted in a python console via ctrl-c. :-)

^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/openravepy/_openravepy_/databases/convexdecomposition.py", line 563, in show
    time.sleep(0.5)
KeyboardInterrupt
jgvictores commented 6 years ago

Fixed at 756a3a3d57bc4e781e6dc13814ace3abca44d776. The most important change was to specify the padding in the constructor, before load(), as here. Minimal working example (see how paddings must match):

import openravepy
from openravepy import *
RaveInitialize()

env=Environment()
env.SetViewer('qtcoin')
env.Load('/usr/local/share/teo-openrave-models/contexts/openrave/teo/teo.robot.xml')

# Convex Decomposition
teo_robot = env.GetRobots()[0]
cdmodel = databases.convexdecomposition.ConvexDecompositionModel(teo_robot, padding=0.02)  # Else defaults to zero padding

if not cdmodel.load(): 
    # If not already in the database. Generate:
    print 'ConvexDecomposition not found, generating...'
    cdmodel.generate(padding=0.02)  # Else defaults to 0.005 padding
    print 'ConvexDecomposition generated, saving...'
    cdmodel.save()
    print 'Finished saving'

print 'Setting robot...'
cdmodel.setrobot()
print 'Finish setrobot'

print 'Starting visualization of the convexdecomposition model'
cdmodel.show()   # blocking for now

Note how padding must be the same (and defaults are different).

jgvictores commented 6 years ago

Times are reduced from 2:25 to 0:25.

jgvictores commented 6 years ago

Merged into develop at 94a8b29b7ab38dfd469ee0567ee1640fec3143fe.

jgvictores commented 6 years ago

Working script for TEO model at https://github.com/roboticslab-uc3m/teo-openrave-models/blob/6cd40916d8637043d1c2ff587f6322a8cab3ffdf/scripts/python/generateConvexDecomposition.py