def test_mutate(hand_id):
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    hand = interface.load_hand(hand_id)
    
    hand2 = eigenhand_genetic_algorithm.GA_mutate(hand, .5)
    
    return hand2
Пример #2
0
def start_experiment(num_ga_iters=50,
                     num_atr_iters=5,
                     trials_per_task=5,
                     experiment_name='eigenhand_ate_threshold_3_object'):
    interface = eigenhand_db_interface.EGHandDBaseInterface()

    task_prototype = eigenhand_db_objects.Task(task_type_id=4, task_time=60)
    em = experiment_manager.ExperimentManager(num_ga_iters,
                                              num_atr_iters,
                                              task_models.small_model_dict,
                                              task_prototype,
                                              trials_per_task,
                                              ate.weighted_threshold_ATE_hand,
                                              interface,
                                              experiment_name=experiment_name)

    print 'clearing old database'
    try:
        interface.prepare_gen_0()
    except:
        em.kill_existing()
        interface.prepare_gen_0()
    print 'starting experiment'
    em.run_experiment()
    em.restore_to_new_dbase()
    output_results(em)

    return em
def test_legal_mutate(hand_id, times  = 1000):
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    hand = interface.load_hand(hand_id)
    hand_list = []
    for i in range(1000):
        hand2 = eigenhand_genetic_algorithm.GA_mutate(hand, .5)
        if hand2:
            hand_list.append(hand2)
    print test_starting_set(hand_list)
Пример #4
0
def test_split_phalange(hand = None):
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    hands = interface.load_hands_for_generation(0)
    if(hand is None):
    	test_hand = hands[0]
    else:
    	test_hand = hand
    new_finger = eigenhand_genetic_algorithm.split_phalange(test_hand.fingers[0], 1)
    new_hand = copy.deepcopy(test_hand)
    new_hand.fingers[0] = new_finger
    return new_hand
Пример #5
0
def restore_experiment(num_ga_iters=50,
                       num_atr_iters=5,
                       trials_per_task=5,
                       experiment_name='eigenhand_ate_threshold'):
    interface = eigenhand_db_interface.EGHandDBaseInterface()

    task_prototype = eigenhand_db_objects.Task(task_type_id=4, task_time=60)
    em = experiment_manager.ExperimentManager(num_ga_iters,
                                              num_atr_iters,
                                              task_models.small_model_dict,
                                              task_prototype,
                                              trials_per_task,
                                              ate.weighted_threshold_ATE_hand,
                                              interface,
                                              experiment_name=experiment_name)
    em.restore_to_new_dbase()
def quick_test(in_hand=None):
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    if (in_hand == None):
        hands = interface.load_hands_for_generation(0)
        hand = hands[0]
    else:
        hand = in_hand
    finger = hand.fingers[0]
    finger.link_length_list = [
        finger.link_length_list[0], finger.link_length_list[1], 1.0, .25, 1.0,
        .25, 1.0, .25
    ]
    finger.joint_range_list = finger.joint_range_list[0:2] * len(
        finger.link_length_list)
    finger.joint_default_speed_list = [finger.joint_default_speed_list[0]
                                       ] * len(finger.link_length_list)
    hand.fingers[0] = finger
    load_up_robot(hand, interface)
    return interface
Пример #7
0
def DB_test_split_phalange(hand = None, test_load = True):
	interface = eigenhand_db_interface.EGHandDBaseInterface()
	hands = interface.load_hands_for_generation(0)
	if hand is None:
		test_hand = hands[0]
	else:
		test_hand = hand
	new_finger = eigenhand_genetic_algorithm.split_phalange(test_hand.fingers[0], 1)
	new_hand = copy.deepcopy(test_hand)
	new_hand.fingers[0] = new_finger
	hand_list = [new_hand]
	hand_list = eigenhand_db_tools.insert_unique_hand_list(hand_list, interface)
        if test_load:
            s = socket.socket()
            s.connect(('localhost', 4765))
            s.send('loadEigenhand %i \n'%(hand_list[0].hand_id))
            output = s.recv(2048)
            if int(output.split(" ")[0]) == 0:
                raise ValueError("could not load hand")
	return new_hand
def test_finger_permutes():
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    hands = interface.load_hands_for_generation(0)
    hand = hands[0]
    hand.fingers = [hand.fingers[0]]
    count = 1
    for x in [.25 + i * .125 for i in range(7)]:
        for y in [.25 + i * .125 for i in range(7)]:
            for z in [
                    .25 + i * .125 for i in range(-1, 7)
            ]:  #value of .125 means skip the third and fourth phalange
                for w in [.25 + i * .125 for i in range(-1, 7)
                          ]:  #value of .125 means skip the fourth phalange
                    finger = hand.fingers[0]
                    if (z == .125):
                        finger.link_length_list = [
                            finger.link_length_list[0],
                            finger.link_length_list[1], 1.0, x, 1.0, y
                        ]
                    elif (w == .125):
                        finger.link_length_list = [
                            finger.link_length_list[0],
                            finger.link_length_list[1], 1.0, x, 1.0, y, 1.0, z
                        ]
                    else:
                        finger.link_length_list = [
                            finger.link_length_list[0],
                            finger.link_length_list[1], 1.0, x, 1.0, y, 1.0, z,
                            1.0, w
                        ]
                    finger.joint_range_list = finger.joint_range_list[
                        0:2] * len(finger.link_length_list)
                    finger.joint_default_speed_list = [
                        finger.joint_default_speed_list[0]
                    ] * len(finger.link_length_list)
                    hand.fingers[0] = finger
                    print("%d: " % count)
                    print hand.fingers[0].link_length_list
                    count += 1
                    delete_robot(interface)
    print "All tests run fine."
Пример #9
0
def continue_experiment(num_ga_iters=50,
                        num_atr_iters=5,
                        trials_per_task=5,
                        experiment_name='default'):

    task_prototype = eigenhand_db_objects.Task(task_type_id=4, task_time=60)
    em = experiment_manager.ExperimentManager(num_ga_iters,
                                              num_atr_iters,
                                              task_models.small_model_dict,
                                              task_prototype,
                                              trials_per_task,
                                              ate.weighted_threshold_ATE_hand,
                                              [],
                                              experiment_name=experiment_name)

    #em.kill_existing()
    em.db_interface = eigenhand_db_interface.EGHandDBaseInterface()
    print 'killed existing \n'
    em.restore_all()
    print 'restored grasps \n'
    em.run_experiment()
    print 'ran experiment \n '
    em.restore_all()
Пример #10
0
def test_load():
    interface = eigenhand_db_interface.EGHandDBaseInterface("eigenhanddb_test")
    interface.cursor.execute("delete from fake_finger;")
    d = dict()
    d['fake_finger'] = "/data/backups_fake_finger"
    interface.incremental_restore(d)
Пример #11
0
def test_backup():
    interface = eigenhand_db_interface.EGHandDBaseInterface("eigenhanddb_test")

    interface.incremental_backup("/data/backups", ['fake_finger'])
 def restore_to_new_dbase(self):
     self.db_interface.prepare_empty_db(self.experiment_name)
     self.db_interface = eigenhand_db_interface.EGHandDBaseInterface(self.experiment_name)
     self.restore_all()
def qlist():
    interface = eigenhand_db_interface.EGHandDBaseInterface()
    return interface.load_hands_for_generation(0), interface