def setup(self): """Called internally by the MotionPlan class to set up planning hooks.""" assert self.cspace == None self.cspace = motionplanning.CSpaceInterface() if hasattr(self, 'feasible'): self.cspace.setFeasibility(getattr(self, 'feasible')) else: raise 'Need feasible method' if hasattr(self, 'visible'): self.cspace.setVisibility(getattr(self, 'visible')) else: self.cspace.setVisibilityEpsilon(self.eps) if hasattr(self, 'sample'): self.cspace.setSampler(getattr(self, 'sample')) else: raise 'Need sample method' if hasattr(self, 'sampleneighborhood'): self.cspace.setNeighborhoodSampler( getattr(self, 'sampleneighborhood')) if hasattr(self, 'distance'): self.cspace.setDistance(getattr(self, 'distance')) if hasattr(self, 'interpolate'): self.cspace.setInterpolate(getattr(self, 'interpolate')) for (k, v) in self.properties: if isinstance(v, (list, tuple)): self.cspace.setPropety(k, " ".join([str(item) for item in v])) else: self.cspace.setProperty(k, str(v))
def setup(self,reinit = False): """Called internally by the MotionPlan class to set up planning hooks. If reinit is not set to True, and the setup() method has been called before, a warning message will be printed. Set it to True to suppress this message.""" if self.cspace is not None: if not reinit: print "CSpace.setup(): Performance warning, called twice, destroying previous CSpaceInterface object" self.cspace.destroy() self.cspace = motionplanning.CSpaceInterface() if self.feasibilityTests is not None: for n,f in zip(self.feasibilityTestNames,self.feasibilityTests): self.cspace.addFeasibilityTest(n,f) self.cspace.enableAdaptiveQueries() for (n,d) in self.feasibilityTestDependencies: self.cspace.setFeasibilityDependency(n,d) else: if hasattr(self,'feasible'): self.cspace.setFeasibility(getattr(self,'feasible')) else: raise 'Need feasible method or addFeasibilityTests' if hasattr(self,'visible'): self.cspace.setVisibility(getattr(self,'visible')) else: self.cspace.setVisibilityEpsilon(self.eps) if hasattr(self,'sample'): self.cspace.setSampler(getattr(self,'sample')) else: raise 'Need sample method' if hasattr(self,'sampleneighborhood'): self.cspace.setNeighborhoodSampler(getattr(self,'sampleneighborhood')) if hasattr(self,'distance'): self.cspace.setDistance(getattr(self,'distance')) if hasattr(self,'interpolate'): self.cspace.setInterpolate(getattr(self,'interpolate')) for (k,v) in self.properties.iteritems(): if isinstance(v,(list,tuple)): self.cspace.setProperty(k," ".join([str(item) for item in v])) else: self.cspace.setProperty(k,str(v))