コード例 #1
0
    def test_save_simulation(self):
        db = MVBBLoader(abspath+'/data/test_db', 19, 15)
        k = db.db.keys()[0]
        p = db.db[k][0]
        self.assertFalse(db.has_simulation(k,p))
        nan = float('nan')
        db.save_simulation(k, p, np.eye(4), [nan]*19, [nan]*3*15, [nan]*6*15)
        self.assertTrue(db.has_simulation(k, p))

        print "Reloading..."
        db2 = MVBBLoader(abspath+'/data/test_db', 19, 15)
        self.assertTrue(db2.has_simulation(k, p))
コード例 #2
0
    ##  module,
    # box_db,
    #links_to_check)

    # vis.setPlugin(None)
    #vis.setPlugin(program)
    #program.reshape(800, 600)

    # vis.show()
    # this code manually updates the visualization
    # while vis.shown():
    # time.sleep(0.1)
    return


if __name__ == '__main__':
    box_db = None
    try:
        import os.path
        filename = os.path.splitext(sys.argv[1])[0]
    except:
        filename = 'box_db'
    if not os.path.isfile(filename + '.csv'):
        print "Error: file", filename, "doesn't exist"
        exit()

    # palm, index (proximal, middle, distal), little, middle, ring, thumb
    links_to_check = np.array(soft_hand.links_to_check) + 6
    box_db = MVBBLoader(filename, soft_hand.numJoints, len(links_to_check))
    launch_test_mvbb_grasps("soft_hand", box_db, links_to_check)
コード例 #3
0
def grasp_boxes(filename):
    subprocess.call(['python', './grasp_boxes_batch.py', filename])


if __name__ == '__main__':
    try:
        import os.path
        filename = os.path.splitext(sys.argv[1])[0]
    except:
        filename = 'box_db'

    if not os.path.isfile(filename + '.csv'):
        print "Error: file", filename, "doesn't exist"
        exit()

    try:
        n_dofs = int(sys.argv[2])
        n_l = int(sys.argv[3])
    except:
        n_dofs = soft_hand.numJoints
        n_l = len(soft_hand.links_to_check)

    # for SoftHand
    box_db = MVBBLoader(filename, n_dofs, n_l)
    filenames = box_db.split_db()

    p = Pool(multiprocessing.cpu_count())
    p.map(grasp_boxes, filenames)

    box_db.join_results(filenames)
コード例 #4
0
 def test_split_join(self):
     db = MVBBLoader(abspath+'/data/test_db', 19, 15)
     filenames = db.split_db()
     self.assertEqual(len(filenames), 6)
     for fname in filenames:
         db_i = MVBBLoader(fname, 19, 15)
         for k, ps in db_i.db.items():
             for p in ps:
                 nan = float('nan')
                 db_i.save_simulation(k, p, np.eye(4), [nan]*19, [nan]*3*15, [nan]*6*15)
     db.join_results(filenames)
     poses = db.get_all_simulated_poses()
     pose_count = 0
     for i in poses.keys():
         pose_count+=len(poses[i])
     self.assertEqual(6,len(db.get_all_simulated_poses()))
     self.assertEqual(12,pose_count)
コード例 #5
0
        filename = os.path.splitext(sys.argv[1])[0]
    except:
        filename = 'box_db'

    if not os.path.isfile(filename + '.csv'):
        print "Error: file", filename, "doesn't exist"
        exit()

    try:
        n_dofs = int(sys.argv[2])
        n_l = int(sys.argv[3])
    except:
        n_dofs = 19
        n_l = 16

    box_db = MVBBLoader(filename, n_dofs, n_l)
    fout = filename + '_filtered'
    copyfile(filename + '.csv', fout + '.csv')
    box_db_filtered = MVBBLoader(fout, n_dofs, n_l)

    poses = box_db.db_simulated
    suc_pose_count = 0
    pose_count = 0
    for k in poses.keys():
        pose_count += len(poses[k])
        for pose in poses[k]:
            if not math.isnan(pose['q'][0]):
                box_db_filtered.save_simulation(k, pose['T'], pose['h_T_o'],
                                                pose['q'], pose['c_p'],
                                                pose['c_f'])
                suc_pose_count += 1