Beispiel #1
0
                                        test_env.AGGR_PHY_STEPS),
                    num_drones=1)
    obs = test_env.reset()
    start = time.time()
    for i in range(
            6 * int(test_env.SIM_FREQ / test_env.AGGR_PHY_STEPS)):  # Up to 6''
        action, _states = model.predict(
            obs,
            deterministic=True  # OPTIONAL 'deterministic=False'
        )
        obs, reward, done, info = test_env.step(action)
        test_env.render()
        if OBS == ObservationType.KIN:
            logger.log(drone=0,
                       timestamp=i / test_env.SIM_FREQ,
                       state=np.hstack(
                           [obs[0:3], obs[3:15],
                            np.resize(action, (4))]),
                       control=np.zeros(12))
        sync(np.floor(i * test_env.AGGR_PHY_STEPS), start, test_env.TIMESTEP)
        # if done: obs = test_env.reset() # OPTIONAL EPISODE HALT
    test_env.close()
    logger.save_as_csv("sa")  # Optional CSV save
    logger.plot()

    # with np.load(ARGS.exp+'/evaluations.npz') as data:
    #     print(data.files)
    #     print(data['timesteps'])
    #     print(data['results'])
    #     print(data['ep_lengths'])
Beispiel #2
0
            )

            #### Go to the next way point and loop #####################
            wp_counter = wp_counter + 1 if wp_counter < (NUM_WP - 1) else 0

        #### Log the simulation ####################################
        logger.log(drone=0,
                   timestamp=i / env.SIM_FREQ,
                   state=obs["0"]["state"],
                   control=np.hstack([TARGET_POS[wp_counter, :],
                                      np.zeros(9)]))

        #### Printout ##############################################
        if i % env.SIM_FREQ == 0:
            env.render()

        #### Sync the simulation ###################################
        if ARGS.gui:
            sync(i, START, env.TIMESTEP)

    #### Close the environment #################################
    env.close()

    #### Save the simulation results ###########################
    logger.save()
    logger.save_as_csv("gnd")  # Optional CSV save

    #### Plot the simulation results ###########################
    if ARGS.plot:
        logger.plot()