text: import pickle
  import copy
  import utiltools.thirdparty.o3dhelper as o3dh
  import utiltools.robotmath as rm
  import utiltools.thirdparty.p3dhelper as p3dh
  import environment.collisionmodel as cm
  import numpy as np
  import copy
  from panda3d.core import NodePath
  
  class Pattern(object):
  
      def __init__(self, elearray=np.zeros((5,10)), root=".."):
          self.tubestandcm = cm.CollisionModel(root+"/objects/tubestand_light.stl")
          self.tubestandcm.setColor(0,.5,.7,1)
          self.tubebigcm = cm.CollisionModel(root+"/objects/tubebig_capped.stl")
          self.tubebigcm.setColor(.57,0,0,.7)
          self.tubesmall1cm = cm.CollisionModel(root+"/objects/tubena.stl")
          # self.tubesmall1cm.setColor(0,.57,0,.7)
          self.tubesmall1cm.setColor(0,0,.57,.7)
          self.tubesmall2cm = cm.CollisionModel(root+"/objects/tubeblue.stl")
          self.tubesmall2cm.setColor(0,.57,0,.7)
  
          self.pattern = elearray
  
          tubeholecenters = []
          for x in [-38,-19,0,19,38]:
              tubeholecenters.append([])
              for y in [-81, -63, -45, -27, -9, 9, 27, 45, 63, 81]:
                  tubeholecenters[-1].append([x,y])
          self.tubeholecenters = np.array(tubeholecenters)
          self.tubeholesize = np.array([15, 16])
  
      def setpattern(self, elearray):
          self.pattern = elearray
  
      def gendumbell(self, homomat, elearray=None):
          if elearray is None:
              elearray = self.pattern
          resultnp = NodePath("patterndbnp")
          tempstand = copy.deepcopy(self.tubestandcm)
          tempstand.sethomomat(homomat)
          tempstand.reparentTo(resultnp)
          tubecmlist = self.gentubes(homomat, elearray, type="dumbbell")
          for tbcm in tubecmlist:
              tbcm.reparentTo(resultnp)
          return resultnp
  
      def gencad(self, homomat, elearray=None):
          if elearray is None:
              elearray = self.pattern
          resultnp = NodePath("patterncadnp")
          tempstand = copy.deepcopy(self.tubestandcm)
          tempstand.sethomomat(homomat)
          tempstand.reparentTo(resultnp)
          tubecmlist = self.gentubes(homomat, elearray, type="cad")
          for tbcm in tubecmlist:
              tbcm.reparentTo(resultnp)
          return resultnp
  
      def gentubes(self, homomat, elearray=None, type="dumbbell"):
          """
  
          :param elearray:
          :param tubestand_homomat:
          :param eleconfidencearray: None by default
          :param alpha: only works when eleconfidencearray is None, it renders the array transparently
          :return:
  
          author: weiwei
          date: 20191229osaka
          """
  
          if elearray is None:
              elearray = self.pattern
          tubecmlist = []
          for i in range(elearray.shape[0]):
              for j in range(elearray.shape[1]):
                  if elearray[i,j] == 1:
                      if type is "dumbbell":
                          tubecm = cm.CollisionModel(p3dh.gendumbbell(spos=np.array([0,0,0]), epos = np.array([0, 0, 100])))
                          tubecm.setColor(.5,0,0,1)
                      elif type is "cad":
                          tubecm = self.tubebigcm
                  elif elearray[i,j] == 2:
                      if type is "dumbbell":
                          tubecm = cm.CollisionModel(p3dh.gendumbbell(spos=np.array([0,0,0]), epos = np.array([0, 0, 80])))
                          tubecm.setColor(0,.5,0,1)
                      elif type is "cad":
                          tubecm = self.tubesmall1cm
                  elif elearray[i,j] == 3:
                      if type is "dumbbell":
                          tubecm = cm.CollisionModel(p3dh.gendumbbell(spos=np.array([0,0,0]), epos = np.array([0, 0, 70])))
                          tubecm.setColor(0,0,.5,1)
                      elif type is "cad":
                          tubecm = self.tubesmall2cm
                  elif elearray[i,j] == -1:
                      tubecm = cm.CollisionModel(p3dh.gendumbbell(spos=np.array([0,0,0]), epos = np.array([0, 0, 70])))
                      tubecm.setColor(1,1,1,1)
                  elif elearray[i,j] == -2:
                      tubecm = cm.CollisionModel(p3dh.gendumbbell(spos=np.array([0,0,0]), epos = np.array([0, 0, 70])))
                      tubecm.setColor(0,0,0,1)
                  else:
                      continue
                  newtubecm = copy.deepcopy(tubecm)
                  tubemat = copy.deepcopy(homomat)
                  tubepos_normalized = np.array([self.tubeholecenters[i,j][0], self.tubeholecenters[i,j][1], 5])
                  tubepos  = rm.homotransformpoint(homomat, tubepos_normalized)
                  tubemat[:3, 3] = tubepos
                  newtubecm.sethomomat(tubemat)
                  tubecmlist.append(newtubecm)
  
          return tubecmlist
  
  if __name__ == '__main__':
      from pandaplotutils import pandactrl
      import environment.suitayuminotop as yumisetting
      import scipy.signal as ss
  
      # base = pandactrl.World(camp=[500, 200, 500], lookat_pos=[500, 0, 0])
      base = pandactrl.World(camp=[380, -190, 2000], lookatpos=[380, -190, 0], lenstype = "orthographic", autocamrotate=False)
      env = yumisetting.Env()
      obscmlist = env.getstationaryobslist()
      for obscm in obscmlist:
          obscm.reparentTo(base.render)
      pt = Pattern()
      elearray = np.array([[1,0,1,0,2,0,2,0,2,0],
                           [0,1,0,1,0,2,0,2,0,2],
                           [1,0,1,0,2,0,2,0,2,0],
                           [0,1,0,1,0,2,0,2,0,2],
                           [1,0,1,0,2,0,2,0,2,0]])
      # elearray = np.array([[1,1,1,1,0,0,2,2,2,2],
      #                      [1,1,1,1,0,0,2,2,2,2],
      #                      [1,1,1,1,0,0,2,2,2,2],
      #                      [1,1,1,1,0,0,2,2,2,2],
      #                      [1,1,1,1,0,0,2,2,2,2]])
      elearrayorigin = np.array([[0,0,1,1,0,0,2,0,0,0],
                           [0,1,0,0,1,1,0,0,0,0],
                           [0,0,0,1,0,2,0,0,1,0],
                           [0,0,0,0,0,2,2,0,1,0],
                           [0,0,0,0,0,0,0,0,0,0]])
      mask_ucbc = np.array([[0,1,0],[0,0,0],[0,1,0]])
      mask_crcl = np.array([[0,0,0],[1,0,1],[0,0,0]])
      mask_ul = np.array([[1,1,1], [1,0,0], [1,0,0]])
      mask_ur = np.array([[1,1,1], [0,0,1], [0,0,1]])
      mask_bl = np.array([[1,0,0], [1,0,0], [1,1,1]])
      mask_br = np.array([[0,0,1], [0,0,1], [1,1,1]])
      cg_ucbc = ss.correlate2d(elearrayorigin, mask_ucbc)[1:-1,1:-1]
      cg_crcl = ss.correlate2d(elearrayorigin, mask_crcl)[1:-1,1:-1]
      cg_ul = ss.correlate2d(elearrayorigin, mask_ul)[1:-1,1:-1]
      cg_ur = ss.correlate2d(elearrayorigin, mask_ur)[1:-1,1:-1]
      cg_bl = ss.correlate2d(elearrayorigin, mask_bl)[1:-1,1:-1]
      cg_br = ss.correlate2d(elearrayorigin, mask_br)[1:-1,1:-1]
      cg_ucbc[elearrayorigin==0]=-1
      cg_crcl[elearrayorigin==0]=-1
      cg_ul[elearrayorigin==0]=-1
      cg_ur[elearrayorigin==0]=-1
      cg_bl[elearrayorigin==0]=-1
      cg_br[elearrayorigin==0]=-1
      binaryelearray = (cg_ucbc==0)+(cg_crcl==0)+(cg_ul==0)+(cg_ur==0)+(cg_bl==0)+(cg_br==0)
      # binaryelearray = ((cg_ucbc==0)+(cg_crcl==0)+(cg_ul==0)+(cg_ur==0)+(cg_bl==0)+(cg_br==0))*(elearrayorigin==0)
      print(binaryelearray)
      elearray = np.zeros((5,10))
      elearray[binaryelearray]=-1
      elearray[binaryelearray==False] = elearray[binaryelearray==False]+elearrayorigin[binaryelearray==False]
      print(elearray)
      # elearray = np.array([[1,0,1,1,0,0,2,2,2,0],
      #                      [0,1,0,0,1,1,0,0,0,0],
      #                      [0,0,0,1,0,0,0,0,1,0],
      #                      [0,0,0,0,0,2,0,0,0,0],
      #                      [0,0,0,0,0,0,0,0,0,0]])
      # newelearray[elearray==1]
      # elearray = np.array([[0,0,-1,-1,0,0,-1,0,0,0],
      #                      [0,-1,0,0,-1,1,0,0,0,0],
      #                      [0,0,0,-1,0,-1,0,0,0,0],
      #                      [0,0,0,0,0,2,-1,0,-1,0],
      #                      [0,0,0,0,0,0,0,0,-1,0]])
      # elearray = np.array([[-2,0,1,1,0,0,2,-2,-2,-2],
      #                      [-2,1,0,0,1,1,0,-2,-2,-2],
      #                      [-2,-2,-2,1,0,2,0,-2,-2,-2],
      #                      [-2,-2,-2,-2,-2,2,2,0,1,-2],
      #                      [-2,-2,-2,-2,-2,-2,-2,-2,1,-2]])
      # elearray = np.zeros((5,10))
      # example plan
      # # first path
      # elearray = np.array([[0.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # second path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # # third path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # # fourth path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # # fifth path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # # sixth path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,0.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,2.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # # seventh path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,0.0],
      #                      [0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,2.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # eighth path
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
      #                      [1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
      #                      [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
  
      # # research
      elearray = np.array([[1.0,0.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      # # step 2
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      elearray = np.array([[1.0,1.0,1.0,1.0,0.0,0.0,2.0,2.0,2.0,2.0],
                           [1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                           [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]])
      pt.setpattern(elearray)
      tubehm = np.eye(4)
      tubehm[:3, 3] = np.array([380,-190,0])
      # pt.gendumbell(homomat=tubehm).reparentTo(base.render)
      pt.gencad(homomat=tubehm).reparentTo(base.render)
      base.run()