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=kinematicreachability_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 kinematicreachability
00041
00042 model = producer = consumer = gatherer = produceriter = None
00043 producercount = 0
00044 def start(args=None):
00045 global model, producer, consumer, gatherer
00046 options,model = kinematicreachability.ReachabilityModel.InitializeFromParser(args=args)
00047 producer, consumer, gatherer, num = model.generatepcg(*model.autogenerateparams(options))
00048 print 'total jobs: ',num
00049
00050 def service_start(args):
00051 start(args)
00052
00053 def service_processrequest(*args):
00054 global consumer
00055 return consumer(*args)
00056
00057 def server_processresponse(*args):
00058 global gatherer
00059 if len(args) > 0:
00060 gatherer(*args)
00061
00062 def server_requestwork():
00063 global producer, produceriter,producercount
00064 try:
00065 if mod(producercount,1000) == 0:
00066 print 'work ',producercount
00067 producercount += 1
00068 if produceriter is None:
00069 produceriter=producer()
00070 return produceriter.next()
00071 except:
00072 return None
00073
00074 def server_start(args):
00075 global producercount
00076 start(args)
00077 producercount = 0
00078
00079 def server_end():
00080 global model, gatherer
00081 gatherer()
00082 model.save()
00083
00084 def launcher_start(args):
00085 start(args)
00086 return ''