def parseAndCreateThreadedUser(options,userfn,createenv=openravepy_int.Environment,returnviewer=True,**kwargs): """Parse all options and create the global Environment. The left over arguments are passed to the parse functions. If a viewer is requested, it is created in this thread, and another thread is executed with the user function. This is required for OSes that require viewer thread to be in main thread (Mac OSX) :param userfn: Call with userfn(env,options) :return: nothing """ openravepy_int.RaveInitialize(True) for plugin in options._loadplugins: openravepy_int.RaveLoadPlugin(plugin) OpenRAVEGlobalArguments.parseGlobal(options,**kwargs) if createenv is None: raise openravepy_ext.openrave_exception('failed to create environment') env = createenv() viewername = OpenRAVEGlobalArguments.parseEnvironment(options,env,returnviewer=True,**kwargs) SetViewerUserThread(env,viewername,lambda: userfn(env,options))
def parseAndCreate(options,createenv=openravepy_int.Environment,returnviewer=False,**kwargs): """Parse all options and create the global Environment. The left over arguments are passed to the parse functions. If returnviewer is False, the viewer is created in a separate thread, so this method will not work for MacOSX if this is the main executing thread. """ openravepy_int.RaveInitialize(True) for plugin in options._loadplugins: openravepy_int.RaveLoadPlugin(plugin) OpenRAVEGlobalArguments.parseGlobal(options,**kwargs) if createenv is None: return None env = createenv() viewername = OpenRAVEGlobalArguments.parseEnvironment(options,env,returnviewer=returnviewer,**kwargs) if returnviewer: return env,viewername else: return env