Beispiel #1
0
async def run():
    """
    The main coroutine, which is started below.
    """
    # Parse command line / file input arguments
    settings = parser.parse_args()

    # Load a robot from yaml
    robot = revolve_bot.RevolveBot()
    robot.load_file("experiments/examples/yaml/spider.yaml")

    # Connect to the simulator and pause
    world = await World.create(settings)
    await world.pause(True)

    # Insert the robot in the simulator
    robot_manager = await world.insert_robot(robot, Vector3(0, 0, 0.05))

    # Resume simulation
    await world.pause(False)

    # Start a run loop to do some stuff
    while True:
        # Print robot fitness every second
        print("Robot fitness is {fitness}".format(
            fitness=robot_manager.fitness()))
        await asyncio.sleep(1.0)
Beispiel #2
0
async def run():
    """
    The main coroutine, which is started below.
    """
    # Parse command line / file input arguments
    settings = parser.parse_args()

    # Load a robot from yaml
    robot = revolve_bot.RevolveBot()
    if settings.robot_yaml is None:
        robot.load_file("experiments/bo_learner/yaml/spider.yaml")
    else:
        robot.load_file(settings.robot_yaml)
    robot.update_substrate()

    # Connect to the simulator and pause
    world = await World.create(settings)
    await world.pause(True)

    await world.delete_model(robot.id)
    await asyncio.sleep(2.5)

    # Insert the robot in the simulator
    robot_manager = await world.insert_robot(robot, Vector3(0, 0, 0.025))

    # Resume simulation
    await world.pause(False)

    # Start a run loop to do some stuff
    while True:
        await asyncio.sleep(5.0)
Beispiel #3
0
async def run():
    """
    The main coroutine, which is started below.
    """
    robot_file_path = "experiments/examples/yaml/spider.yaml"

    # Parse command line / file input arguments
    settings = parser.parse_args()

    # Start Simulator
    if settings.simulator_cmd != 'debug':
        simulator_supervisor = DynamicSimSupervisor(
            world_file=settings.world,
            simulator_cmd=settings.simulator_cmd,
            simulator_args=["--verbose"],
            plugins_dir_path=os.path.join('.', 'build', 'lib'),
            models_dir_path=os.path.join('.', 'models'),
            simulator_name='gazebo')
        await simulator_supervisor.launch_simulator(port=settings.port_start)
        await asyncio.sleep(0.1)

    # Load a robot from yaml
    robot = revolve_bot.RevolveBot()
    robot.load_file(robot_file_path)
    robot.update_substrate()
    # robot._brain = BrainRLPowerSplines()

    # Connect to the simulator and pause
    connection = await World.create(settings,
                                    world_address=('127.0.0.1',
                                                   settings.port_start))
    await asyncio.sleep(1)

    # Starts the simulation
    await connection.pause(False)

    # Insert the robot in the simulator
    robot_manager = await connection.insert_robot(
        robot, Vector3(0, 0, settings.z_start))

    # Start a run loop to do some stuff
    while True:
        # Print robot fitness every second
        status = 'dead' if robot_manager.dead else 'alive'
        print(
            f"Robot fitness ({status}) is \n"
            f" OLD:     {fitness.online_old_revolve(robot_manager)}\n"
            f" DISPLAC: {fitness.displacement(robot_manager, robot)}\n"
            f" DIS_VEL: {fitness.displacement_velocity(robot_manager, robot)}")
        await asyncio.sleep(1.0)
Beispiel #4
0
async def run():
    """
    The main coroutine, which is started below.
    """

    arguments = parser.parse_args()

    if arguments.robot_name is not None:
        # this split will give errors on windows
        robot_file_path = "experiments/bodies/" + arguments.robot_name + ".yaml"

    if arguments.iterations is not None:
        # this split will give errors on windows
        iterations = int(arguments.iterations)

    #robot_file_path = "experiments/examples/yaml/spider.yaml"

    # Parse command line / file input arguments
    settings = parser.parse_args()

    # Start Simulator
    if settings.simulator_cmd != 'debug':
        simulator_supervisor = DynamicSimSupervisor(
            world_file=settings.world,
            simulator_cmd=settings.simulator_cmd,
            simulator_args=["--verbose"],
            plugins_dir_path=os.path.join('.', 'build', 'lib'),
            models_dir_path=os.path.join('.', 'models'),
            simulator_name='gazebo')
        await simulator_supervisor.launch_simulator(port=settings.port_start)
        await asyncio.sleep(0.1)

    # Load a robot from yaml
    robot = revolve_bot.RevolveBot()
    robot.load_file(robot_file_path)
    robot.update_substrate()
    # robot._brain = BrainRLPowerSplines()

    # Connect to the simulator and pause
    connection = await World.create(settings,
                                    world_address=('127.0.0.1',
                                                   settings.port_start))
    await asyncio.sleep(1)

    # Starts the simulation
    await connection.pause(False)

    # Insert the robot in the simulator
    #life_timeout = Fixed time a robot stays in the simulator
    robot_manager = await connection.insert_robot(
        robot, Vector3(0, 0, settings.z_start))

    robot_fitness = []
    for x in range(1, iterations):
        # Print robot fitness every second
        robot_fitness.append(
            fitness.displacement_velocity(robot_manager, robot))
        await asyncio.sleep(0.1)

    print("**The Robot Fitness is: ",
          str(sum(robot_fitness) / len(robot_fitness)))