Ejemplo n.º 1
0
def main():
    '''
    Main thread:
    '''
    train = True
    environment = FetchReachEnv()
    param_file = "./her_bit_env"
    ddpg_loop(train=train, environment=environment)
Ejemplo n.º 2
0
 def build_env(self, env_type, reward_type):
     if env_type == 'FetchReach-v1':
         return FetchReachEnv(reward_type=reward_type)
     elif env_type == 'FetchPush-v1':
         return FetchPushEnv(reward_type=reward_type)
     elif env_type == 'FetchPickAndPlace-v1':
         return FetchPickAndPlaceEnv(reward_type=reward_type)
     else:
         raise NotImplementedError
Ejemplo n.º 3
0
from gym.envs.robotics.fetch.push import FetchPushEnv
from gym.envs.robotics.fetch.reach import FetchReachEnv
from gym.envs.robotics import fetch_env
import argparse
import collections

import sklearn.pipeline
import sklearn.preprocessing
from sklearn.kernel_approximation import RBFSampler

tf.enable_eager_execution()
# env = gym.make('FetchReach-v1')
# env.reward_type = 'dense'
# env.target_offset=1.0
# _max_episode_steps = 100
env = FetchReachEnv(reward_type='dense')
env.max_episode_steps = 100
observation_examples = np.array(
    [env.reset()['observation'] for _ in range(10000)])
scaler = sklearn.preprocessing.StandardScaler()
scaler.fit(observation_examples)

# Used to converte a state to a featurizes represenation.
# We use RBF kernels with different variances to cover different parts of the space
featurizer = sklearn.pipeline.FeatureUnion([
    ("rbf1", RBFSampler(gamma=5.0, n_components=100)),
    ("rbf2", RBFSampler(gamma=2.0, n_components=100)),
    ("rbf3", RBFSampler(gamma=1.0, n_components=100)),
    ("rbf4", RBFSampler(gamma=0.5, n_components=100))
])
Ejemplo n.º 4
0
def env_fn():
    env = FetchReachEnv(reward_type='dense')
    return EnvWrapper(env)
Ejemplo n.º 5
0
import sys
sys.path.insert(0, "../../gym")
sys.path.insert(0, "../../gym/envs/robotics")
import gym
from gym.envs.robotics.fetch.reach import FetchReachEnv
#from fetch.reach import FetchReachEnv

print(gym)
#env = FetchPickAndPlaceEnv()
env = FetchReachEnv()
env.reset()
#for _ in range(10000):
env.render()
#print(f"action:{env.action_space.sample()}")
#    action = env.action_space.sample() # take a random action
#    observation, reward, done, info = env.step(action)

#env.close()
Ejemplo n.º 6
0
import sys
sys.path.insert(0,"../../gym")
sys.path.insert(0,"../../gym/envs/robotics")
import gym

from stable_baselines.common.env_checker import check_env
from gym.envs.robotics.fetch.reach import FetchReachEnv
# It will check your custom environment and output additional warnings if needed
print(gym)
env=FetchReachEnv()
#env=gym.make()
print(isinstance(env, gym.GoalEnv))
check_env(env)
Ejemplo n.º 7
0
                        action='store_true',
                        help="Render environment while training")
    parser.add_argument('--nb_episodes',
                        type=int,
                        default=5000,
                        help="Number of training episodes")
    parser.add_argument('--eval_model', type=str, default='')
    parser.add_argument('--eval_random',
                        action='store_true',
                        help='evaluate random performance on env')
    args = parser.parse_args()

    consec_frames = 4
    # Continuous Environments Wrapp
    # er
    # env = gym.make('FetchReach-v1')
    env = FetchReachEnv(reward_type='sparse')
    env.reset()

    state_dim = env.reset()['observation'].shape
    action_space = FetchReachEnv().action_space
    action_dim = action_space.high.shape[0]
    act_range = action_space.high

    algo = DDPG(action_dim, state_dim, act_range, consec_frames)
    if args.eval_model != '':
        print(algo.eval(env, model_name=args.eval_model, render=args.render))
    elif args.eval_random:
        print(algo.eval(env, random=True, render=args.render))
    else:
        algo.train(env, args)