parameters: (self,world,ignore=[])
docstring: Args:
              world (WorldModel): the world to use
              ignore (list, optional): a list of items to pass to ignoreCollision
docstring_summary: Args:
              world (WorldModel): the world to use
              ignore (list, optional): a list of items to pass to ignoreCollision
docstring_tokens: Args : world ( WorldModel ) : the world to use ignore ( list optional ) : a list of items to pass to ignoreCollision
function: def __init__(self,world,ignore=[]):
          """Args:
              world (WorldModel): the world to use
              ignore (list, optional): a list of items to pass to ignoreCollision
          """
  
          world.enableInitCollisions(True)
          self.world = world
          #a list of (object,geom) pairs
          self.geomList = []
          #self collision mask (2-D array)
          self.mask = []
          #indexing lists
          self.terrains = []
          self.rigidObjects = []
          self.robots = []
          
          for i in xrange(world.numTerrains()):
              t = world.terrain(i)
              g = t.geometry()
              if g != None and g.type()!="":
                  self.terrains.append(len(self.geomList))
                  self.geomList.append((t,g))
              else:
                  self.terrains.append(-1)
          for i in xrange(world.numRigidObjects()):
              o = world.rigidObject(i)
              g = o.geometry()
              if g != None and g.type()!="":
                  self.rigidObjects.append(len(self.geomList))
                  self.geomList.append((o,g))
              else:
                  self.rigidObjects.append(-1)
          for i in xrange(world.numRobots()):
              r = world.robot(i)
              self.robots.append([])
              for j in xrange(r.numLinks()):
                  l = r.link(j)
                  g = l.geometry()
                  if g != None and g.type()!="":
                      self.robots[-1].append(len(self.geomList))
                      self.geomList.append((l,g))
                  else:
                      self.robots[-1].append(-1)
  
          #construct the collision mask
          for i in xrange(len(self.geomList)):
              self.mask.append(set())
          for t in self.terrains:
              if t < 0: continue
              for o in self.rigidObjects:
                  if o < 0: continue
                  self.mask[t].add(o)
                  self.mask[o].add(t)
              for r in self.robots:
                  for l in r:
                      if l < 0: continue
                      #test for fixed links
                      if self.geomList[l][0].getParent() >= 0:
                          self.mask[l].add(t)
                          self.mask[t].add(l)
                      else:
                          #print "Ignoring fixed link..."
                          pass
          for o in self.rigidObjects:
              if o < 0: continue
              for o2 in self.rigidObjects[:o]:
                  if o2 < 0: continue
                  self.mask[o].add(o2)
                  self.mask[o2].add(o)
              for r in self.robots:
                  for l in r:
                      if l < 0: continue
                      self.mask[l].add(o)
                      self.mask[o].add(l)
          for i,r in enumerate(self.robots):
              #robot - robot collision
              for r2 in self.robots[0:i]:
                  for l1 in r:
                      for l2 in r2:
                          if l < 0 or l2 < 0: continue
                          self.mask[l1].add(l2)
                          self.mask[l2].add(l1)
              #robot self-collision
              rob = self.geomList[r[0]][0].robot()
              nl = rob.numLinks()
              for i in xrange(nl):
                  for j in xrange(i):
                      if rob.selfCollisionEnabled(i,j):
                          self.mask[r[i]].add(r[j])
                          self.mask[r[j]].add(r[i])
                          
          for i in ignore:
              self.ignoreCollision(i)
function_tokens: def __init__ ( self , world , ignore = [ ] ) : world . enableInitCollisions ( True ) self . world = world #a list of (object,geom) pairs self . geomList = [ ] #self collision mask (2-D array) self . mask = [ ] #indexing lists self . terrains = [ ] self . rigidObjects = [ ] self . robots = [ ] for i in xrange ( world . numTerrains ( ) ) : t = world . terrain ( i ) g = t . geometry ( ) if g != None and g . type ( ) != "" : self . terrains . append ( len ( self . geomList ) ) self . geomList . append ( ( t , g ) ) else : self . terrains . append ( - 1 ) for i in xrange ( world . numRigidObjects ( ) ) : o = world . rigidObject ( i ) g = o . geometry ( ) if g != None and g . type ( ) != "" : self . rigidObjects . append ( len ( self . geomList ) ) self . geomList . append ( ( o , g ) ) else : self . rigidObjects . append ( - 1 ) for i in xrange ( world . numRobots ( ) ) : r = world . robot ( i ) self . robots . append ( [ ] ) for j in xrange ( r . numLinks ( ) ) : l = r . link ( j ) g = l . geometry ( ) if g != None and g . type ( ) != "" : self . robots [ - 1 ] . append ( len ( self . geomList ) ) self . geomList . append ( ( l , g ) ) else : self . robots [ - 1 ] . append ( - 1 ) #construct the collision mask for i in xrange ( len ( self . geomList ) ) : self . mask . append ( set ( ) ) for t in self . terrains : if t < 0 : continue for o in self . rigidObjects : if o < 0 : continue self . mask [ t ] . add ( o ) self . mask [ o ] . add ( t ) for r in self . robots : for l in r : if l < 0 : continue #test for fixed links if self . geomList [ l ] [ 0 ] . getParent ( ) >= 0 : self . mask [ l ] . add ( t ) self . mask [ t ] . add ( l ) else : #print "Ignoring fixed link..." pass for o in self . rigidObjects : if o < 0 : continue for o2 in self . rigidObjects [ : o ] : if o2 < 0 : continue self . mask [ o ] . add ( o2 ) self . mask [ o2 ] . add ( o ) for r in self . robots : for l in r : if l < 0 : continue self . mask [ l ] . add ( o ) self . mask [ o ] . add ( l ) for i , r in enumerate ( self . robots ) : #robot - robot collision for r2 in self . robots [ 0 : i ] : for l1 in r : for l2 in r2 : if l < 0 or l2 < 0 : continue self . mask [ l1 ] . add ( l2 ) self . mask [ l2 ] . add ( l1 ) #robot self-collision rob = self . geomList [ r [ 0 ] ] [ 0 ] . robot ( ) nl = rob . numLinks ( ) for i in xrange ( nl ) : for j in xrange ( i ) : if rob . selfCollisionEnabled ( i , j ) : self . mask [ r [ i ] ] . add ( r [ j ] ) self . mask [ r [ j ] ] . add ( r [ i ] ) for i in ignore : self . ignoreCollision ( i )