Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 """
00016 To execute on 8 cores of the current localhost, first store roscore and then run:
00017
00018 .. code-block:: bash
00019
00020 roscd openrave_database; rosrun parallel_util workmanagerlauncher.py --module=grasping_ros --launchservice='8*localhost'
00021
00022 For more options run:
00023
00024 .. code-block:: bash
00025
00026 rosrun parallel_util workmanagerlauncher.py --help
00027
00028 """
00029
00030 from __future__ import with_statement
00031
00032 PKG = 'openrave_database'
00033 import roslib; roslib.load_manifest(PKG)
00034
00035 from numpy import *
00036 import numpy
00037 import sys, time
00038 from optparse import OptionParser
00039 from openravepy import *
00040 from openravepy.databases import grasping
00041
00042 model = producer = consumer = gatherer = produceriter = None
00043 producercount = 0
00044 def start(args=None):
00045 global model, producer, consumer, gatherer
00046 try:
00047 options,model = grasping.GraspingModel.InitializeFromParser(args=args)
00048 producer, consumer, gatherer, num = model.generatepcg(*model.autogenerateparams(options))
00049 except Exception, e:
00050 print e
00051 print 'faile with args: ',args
00052 print 'total jobs: ',num
00053
00054 def service_start(args):
00055 start(args)
00056
00057 def service_processrequest(*args):
00058 global consumer
00059 return consumer(*args)
00060
00061 def server_processresponse(*args):
00062 global gatherer
00063 if len(args) > 0:
00064 gatherer(*args)
00065
00066 def server_requestwork():
00067 global producer, produceriter,producercount
00068 try:
00069 print 'grasping ',producercount
00070 producercount += 1
00071 if produceriter is None:
00072 produceriter=producer()
00073 return produceriter.next()
00074 except:
00075 return None
00076
00077 def server_start(args):
00078 global producercount
00079 start(args)
00080 producercount = 0
00081
00082 def server_end():
00083 global model, gatherer
00084 gatherer()
00085 model.save()
00086
00087 def launcher_start(args):
00088 start(args)
00089 return ''