示例#1
0
def test_can_step(env_ids):
    """Test Bullet environments can step"""

    for env_id in env_ids:
        # extract id string
        env_id = env_id.replace('- ', '')
        if env_id == 'KukaCamBulletEnv-v0':
            # Kuka environments calls py_bullet.resetSimulation() in reset()
            # unconditionally, which globally resets other simulations. So
            # only one Kuka environment is tested.
            continue
        if env_id in _get_unsupported_env_list():
            pytest.skip('Skip unsupported Bullet environments')
        env = BulletEnv(env_name=env_id)
        ob_space = env.observation_space
        act_space = env.action_space
        env.reset()

        ob = ob_space.sample()
        assert ob_space.contains(ob)
        a = act_space.sample()
        assert act_space.contains(a)
        # Skip rendering because it causes TravisCI to run out of memory
        step_env(env, render=False)
        env.close()
示例#2
0
def test_pickleable(env_ids):
    """Test Bullet environments are pickle-able"""
    for env_id in env_ids:
        # extract id string
        env_id = env_id.replace('- ', '')
        env = BulletEnv(env_name=env_id)
        round_trip = pickle.loads(pickle.dumps(env))
        assert round_trip
        env.close()
示例#3
0
def test_pickleable(env_ids):
    """Test Bullet environments are pickle-able"""
    for env_id in env_ids:
        # extract id string
        env_id = env_id.replace('- ', '')
        if env_id in _get_unsupported_env_list():
            pytest.skip('Skip unsupported Bullet environments')
        env = BulletEnv(env_name=env_id)
        round_trip = pickle.loads(pickle.dumps(env))
        assert round_trip
        env.close()
示例#4
0
def test_can_step(env_ids):
    """Test Bullet environments can step"""

    for env_id in env_ids:
        # extract id string
        env_id = env_id.replace('- ', '')
        if env_id in ('KukaCamBulletEnv-v0', 'KukaDiverseObjectGrasping-v0'):
            # Kuka environments calls pybullet.resetSimulation() in reset()
            # unconditionally, which globally resets other simulations. So
            # only one Kuka environment is tested.
            continue
        env = BulletEnv(env_id)
        ob_space = env.observation_space
        act_space = env.action_space
        env.reset()

        ob = ob_space.sample()
        assert ob_space.contains(ob)
        a = act_space.sample()
        assert act_space.contains(a)
        # Skip rendering because it causes TravisCI to run out of memory
        step_env(env, visualize=False)
        env.close()