def __init__(self, bodyA, bodyB): Joint.__init__(self, bodyA, bodyB) self.Xj = sv.Xrot(np.matrix([[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]))*sv.Xtrans([0.0,0.0,0.0]) self.S = np.matrix([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]).transpose()
def load_model(config): """ :param config: config :return: nn model """ print("********************************************************") model = Joint(config) if config.use_cuda is True: model = model.cuda() return model
def hang(): j1 = Joint(x=-6, y=4, mutatable_x=False, mutatable_y=False) j2 = Joint(x=-2, y=4, mutatable_x=False, mutatable_y=False) j3 = Joint(x= 2, y=4, mutatable_x=False, mutatable_y=False) j4 = Joint(x= 6, y=4, mutatable_x=False, mutatable_y=False) j5 = Joint(x= 0, y=-4, mutatable_x=False, mutatable_y=False, movable_x=True, movable_y=True, force_y=1) mat = steels[4] elems = [ Element(joint1=j1, joint2=j5, material=mat), Element(joint1=j2, joint2=j5, material=mat), Element(joint1=j3, joint2=j5, material=mat), Element(joint1=j4, joint2=j5, material=mat), ] return Construction(joints=[j1,j2,j3,j4,j5], elements=elems, available_element_materials=steels, element_deleted_material=air, force_magnitude=10000., width=14, height=10)
def __init__(self, transform, a, b, qe = None, qr = None): Joint.__init__(self, transform, a, b) self.qe = qe self.qr = qr if qe is None: theta = 0.0 ux = 0.0 uy = 0.0 uz = 0.0 p0 = np.cos(theta/2) p1 = np.sin(theta/2)*ux p2 = np.sin(theta/2)*uy p3 = np.sin(theta/2)*uz self.qe = np.matrix([p0, p1, p2, p3]).transpose() if qr is None: self.qr = np.matrix([0.0,0.0,0.0]).transpose() self.qe_norm = normalize(self.qe) self.qd = np.resize(0.0, (6,1)) self.qdd = np.resize(0.0, (6,1)) self.describe(" 6DoF Joint") self.update(self.qe, self.qr)
def bridge2(): # j6--j7--j8 # / |\/| \/| \ # / |/\| /\| \ #j1--j2-j3--j4--j5 j1 = Joint(x=-6, y=0, movable_x=False, movable_y=False, mutatable_x=False, mutatable_y=False) j2 = Joint(x=-3, y=0, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=False, force_y=-1) j3 = Joint(x=0, y=0, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=False, force_y=-1) j4 = Joint(x=3, y=0, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=False, force_y=-1) j5 = Joint(x=6, y=0, movable_x=False, movable_y=False, mutatable_x=False, mutatable_y=False) j6 = Joint(x=-4, y=3, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=True) j7 = Joint(x=0, y=3, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=True) j8 = Joint(x=4, y=3, movable_x=True, movable_y=True, mutatable_x=True, mutatable_y=True) mat = steels[2] elems = [ Element(joint1=j1, joint2=j6, material=mat), Element(joint1=j1, joint2=j2, material=mat), Element(joint1=j2, joint2=j6, material=mat), Element(joint1=j2, joint2=j3, material=mat), Element(joint1=j2, joint2=j7, material=mat), Element(joint1=j3, joint2=j6, material=mat), Element(joint1=j3, joint2=j4, material=mat), Element(joint1=j3, joint2=j7, material=mat), Element(joint1=j3, joint2=j8, material=mat), Element(joint1=j4, joint2=j7, material=mat), Element(joint1=j4, joint2=j8, material=mat), Element(joint1=j4, joint2=j5, material=mat), Element(joint1=j5, joint2=j8, material=mat), Element(joint1=j6, joint2=j7, material=mat), Element(joint1=j7, joint2=j8, material=mat), ] return Construction(joints=[j1,j2,j3,j4,j5,j6,j7,j8], elements=elems, force_magnitude=10000.)
# ev=Eval('../model/ner/four.testb.hdf5','../model/ner/four.testb.hdf5.data') _dict = load_data_from_h5('../model/ner/chinese.train.hdf5') # new if args.corpus == 'new': ev = Eval(args.test_h5, args.test_pkl) _dict = load_data_from_h5(args.train_h5) samples = np.array(_dict['sentences_ix']) sample_amount = samples.shape[0] sample_shape = samples.shape[1] if args.algorithm == 'LSTMCRF': model = LSTMCRF(args) if args.algorithm == 'Joint': model = Joint(args) init = tf.global_variables_initializer() configs = tf.ConfigProto(allow_soft_placement=True, log_device_placement=False) configs.gpu_options.allow_growth = True sess = tf.Session(config=configs) sess.run(init) if args.mode == 'restore': saver = tf.train.Saver(max_to_keep=None) saver.restore(sess, args.model_path) elif args.mode == 'train': saver = tf.train.Saver(max_to_keep=None) elif args.mode == 'tune': pass
def __init__(self, bodyA, bodyB, q, d): Joint.__init__(self, bodyA, bodyB) self.update(q, d)