示例#1
0
    if args.mp:
        num_processes = min([hp.nb_directions, max_processes])
        print('processes: ', num_processes)
        processes = []
        childPipes = []
        parentPipes = []

        for pr in range(num_processes):
            parentPipe, childPipe = Pipe()
            parentPipes.append(parentPipe)
            childPipes.append(childPipe)

        for rank in range(num_processes):
            p = mp.Process(target=ExploreWorker,
                           args=(rank, childPipes[rank], hp.env_name, args))
            p.start()
            processes.append(p)

    # env = stoch2_gym_env.StochBulletEnv(render = False, gait = 'trot')
    nb_inputs = env.observation_space.sample().shape[0]
    nb_outputs = env.action_space.sample().shape[0] * 2
    policy = Policy(nb_inputs, nb_outputs, hp.env_name, hp.normal, args)
    hp.nb_directions = int(policy.theta.shape[0] * policy.theta.shape[1])
    hp.nb_best_directions = int(hp.nb_directions / 2)
    normalizer = Normalizer(nb_inputs)

    print("start training")
    train(env, policy, normalizer, hp, parentPipes, args)

    if args.mp:
        for parentPipe in parentPipes:
示例#2
0
# Author: Sida Liu 2020 ([email protected])
# This is a demo of using wrappers

import pybullet as p

# This tricky import brings back the IntelliSense if this repo exists as a subfolder of a workspace.
if __name__ == '__main__':
    from pybullet_wrapper.base import BaseWrapperPyBullet
    from pybullet_wrapper.handy import HandyPyBullet
else:
    from .pybullet_wrapper.base import BaseWrapperPyBullet
    from .pybullet_wrapper.handy import HandyPyBullet

p = BaseWrapperPyBullet(p)
p = HandyPyBullet(p)
p.start(withPanels=True)
while True:
    p.stepSimulation()
    p.sleep()