home_path = task_path + "/../../../.." #argument test_mode = sys.argv[1] == 'True' # config cfg = YAML().load(open(task_path + "/cfg.yaml", 'r')) curriculum_start = cfg['environment']['curriculum']['curriculum_start'] # create environment from the configuration file if test_mode: cfg_tmp = cfg cfg_tmp['environment']['num_envs'] = 1 env = VecEnv( rsg_anymal.RaisimGymEnv( task_path + "/anymal", dump(cfg_tmp['environment'], Dumper=RoundTripDumper)), cfg['environment']) else: env = VecEnv( rsg_anymal.RaisimGymEnv( task_path + "/anymal", dump(cfg['environment'], Dumper=RoundTripDumper)), cfg['environment']) # shortcuts ob_dim = env.num_obs act_dim = env.num_acts # save the configuration and other files saver = ConfigurationSaver(log_dir=home_path + "/data",
type=str, default='') args = parser.parse_args() # directories task_path = os.path.dirname(os.path.realpath(__file__)) home_path = task_path + "/../../../../.." # config cfg = YAML().load(open(task_path + "/cfg.yaml", 'r')) # create environment from the configuration file cfg['environment']['num_envs'] = 1 env = VecEnv( rsg_anymal.RaisimGymEnv(home_path + "/rsc", dump(cfg['environment'], Dumper=RoundTripDumper)), cfg['environment']) # shortcuts ob_dim = env.num_obs act_dim = env.num_acts weight_path = args.weight iteration_number = weight_path.rsplit('/', 1)[1].split('_', 1)[1].rsplit('.', 1)[0] weight_dir = weight_path.rsplit('/', 1)[0] + '/' if weight_path == "": print( "Can't find trained weight, please provide a trained weight with --weight switch\n" )
type=str, default='') args = parser.parse_args() # directories task_path = os.path.dirname(os.path.realpath(__file__)) home_path = task_path + "/../../../../.." # config cfg = YAML().load(open(task_path + "/cfg.yaml", 'r')) # create environment from the configuration file cfg['environment']['num_envs'] = 1 env = VecEnv( rsg_anymal.RaisimGymEnv(home_path + "/rsc", dump(cfg['environment'], Dumper=RoundTripDumper)), cfg['environment']) # shortcuts ob_dim = env.num_obs act_dim = env.num_acts weight_path = args.weight if weight_path == "": print( "Can't find trained weight, please provide a trained weight with --weight switch\n" ) else: print("Loaded weight from {}\n".format(weight_path)) start = time.time() env.reset()
mode = args.mode weight_path = args.weight # check if gpu is available device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # directories task_path = os.path.dirname(os.path.realpath(__file__)) home_path = task_path + "/../../../../.." # config cfg = YAML().load(open(task_path + "/cfg.yaml", 'r')) # create environment from the configuration file env = VecEnv( rsg_anymal.RaisimGymEnv(home_path + "/rsc", dump(cfg['environment'], Dumper=RoundTripDumper)), cfg['environment']) # shortcuts ob_dim = env.num_obs act_dim = env.num_acts # Training n_steps = math.floor(cfg['environment']['max_time'] / cfg['environment']['control_dt']) total_steps = n_steps * env.num_envs avg_rewards = [] actor = ppo_module.Actor( ppo_module.MLP(cfg['architecture']['policy_net'], nn.LeakyReLU, ob_dim,