def close_session(simulator, *epucks):
    simulator.close()
    for e in epucks:
        e.close()
        del e
    del simulator
    sleep(0.1)
    close_all_connections()
Example #2
0
def main():
    x_home = [0.060175, -0.0049936, 0.31573]
    q_home = [0, 0, 0, 0, 0]

    robot = from_vrep(scene = '../model_1/luxo_1_kinematic.ttt',
        config = '../model_1/config_luxo_1.json'
    )
    robot.stop_simulation()
    robot._controllers[0].io.call_remote_api('simxCloseScene')
    close_all_connections()

    # robot = {
    #     "motors":{
    #         "foot":{
    #             "id":12,
    #             "orientation":"direct",
    #             "type":"AX-12",
    #             "offset":0.0
    #         },
    #         "body_bottom":{
    #             "id":13,
    #             "orientation":"direct",
    #             "type":"AX-12",
    #             "angle_limit":[-90.0, 90.0],
    #             "offset":0.0
    #         },
    #         "body_middle":{
    #             "id":14,
    #             "orientation":"direct",
    #             "type":"AX-12",
    #             "angle_limit":[-130.0, 130.0],
    #             "offset":0.0
    #         },
    #         "body_top":{
    #             "id":15,
    #             "orientation":"direct",
    #             "type":"AX-12",
    #             "angle_limit":[-130.0, 130.0],
    #             "offset":0.0
    #         },
    #         "head":{
    #             "id":16,
    #             "orientation":"direct",
    #             "type":"AX-12",
    #             "offset":0.0
    #         }
    #     }
    # }

    f = VrepDirectFunctionWoPypot(robot)
    g = PolynomialModel(3,5,4,q_home)
    trainer = GoalBabblingTrainer(g,f,q_home,x_home, '../model_1/luxo_1_data_20_5.json')
    trainer.train(200,4,0.05)
def get_session(n_epucks=1, use_proximeters=[2, 3], old_simulator=None, old_epuck=None):
    if old_simulator is not None:
        old_simulator.stop()
        old_simulator.io.close()
        del old_simulator
    if old_epuck is not None:
        old_epuck.stop()
        old_epuck.io.close()
        del old_epuck
    sleep(0.1)
    close_all_connections()
    sleep(0.1)
    close_all_connections()
    sleep(0.1)
    simulator = Simulator()
    simulator.io.restart_simulation()
    epucks = [simulator.get_epuck(use_proximeters=use_proximeters) for _ in range(n_epucks)]
    if n_epucks == 1:
        return simulator, epucks[0]
    else:
        return [simulator] + epucks
def close():
    close_all_connections()