GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Genesis/examples/drone/hover_train.py at main · OIEIEIO/Genesis Expand file tree/ Copy pathhover_train.pyMore file actions 166 lines (144 loc) · 4.68 KB / Copy pathhover_train.pyFile metadata and controls166 lines (144 loc) · 4.68 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 import argparse import os import pickle import shutil from importlib import metadata try: if int(metadata.version("rsl-rl-lib").split(".")[0]) < 5: raise ImportError except (metadata.PackageNotFoundError, ImportError) as e: raise ImportError("Please install 'rsl-rl-lib>=5.0.0'.") from e from rsl_rl.runners import OnPolicyRunner import genesis as gs from hover_env import HoverEnv def get_train_cfg(exp_name): train_cfg_dict = { "algorithm": { "class_name": "PPO", "clip_param": 0.2, "desired_kl": 0.01, "entropy_coef": 0.004, "gamma": 0.99, "lam": 0.95, "learning_rate": 0.0003, "max_grad_norm": 1.0, "num_learning_epochs": 5, "num_mini_batches": 4, "schedule": "adaptive", "use_clipped_value_loss": True, "value_loss_coef": 1.0, }, "actor": { "class_name": "MLPModel", "hidden_dims": [128, 128], "activation": "tanh", "distribution_cfg": { "class_name": "GaussianDistribution", "init_std": 1.0, "std_type": "scalar", }, }, "critic": { "class_name": "MLPModel", "hidden_dims": [128, 128], "activation": "tanh", }, "obs_groups": { "actor": ["policy"], "critic": ["policy"], }, "num_steps_per_env": 100, "save_interval": 100, "run_name": exp_name, "logger": "tensorboard", } return train_cfg_dict def get_cfgs(): env_cfg = { "num_actions": 4, # termination "termination_if_roll_greater_than": 180, # degree "termination_if_pitch_greater_than": 180, "termination_if_close_to_ground": 0.1, "termination_if_x_greater_than": 3.0, "termination_if_y_greater_than": 3.0, "termination_if_z_greater_than": 2.0, # base pose "base_init_pos": [0.0, 0.0, 1.0], "base_init_quat": [1.0, 0.0, 0.0, 0.0], "episode_length_s": 15.0, "at_target_threshold": 0.1, "resampling_time_s": 3.0, "simulate_action_latency": True, "clip_actions": 1.0, # visualization "visualize_target": False, "visualize_camera": False, "max_visualize_FPS": 60, } obs_cfg = { "obs_scales": { "rel_pos": 1 / 3.0, "lin_vel": 1 / 3.0, "ang_vel": 1 / 3.14159, }, } reward_cfg = { "yaw_lambda": -10.0, "reward_scales": { "target": 10.0, "smooth": -1e-4, "yaw": 0.01, "angular": -2e-4, "crash": -10.0, }, } command_cfg = { "num_commands": 3, "pos_x_range": [-1.0, 1.0], "pos_y_range": [-1.0, 1.0], "pos_z_range": [1.0, 1.0], } return env_cfg, obs_cfg, reward_cfg, command_cfg def main(): parser = argparse.ArgumentParser() parser.add_argument( "-e", "--exp-name", type=str, default="drone-hovering", help="Experiment name; also the log directory under logs/", ) parser.add_argument("-v", "--vis", action="store_true", help="Show visualization GUI") parser.add_argument("-b", "--num-envs", type=int, default=8192, help="Number of parallel environments") parser.add_argument("--max-iterations", type=int, default=301, help="Number of learning iterations") parser.add_argument("--seed", type=int, default=1, help="Random seed") args = parser.parse_args() # Training throughput comes from the 8192 parallel environments, which need a GPU. gs.init(backend=gs.gpu, precision="32", logging_level="warning", seed=args.seed, performance_mode=True) log_dir = f"logs/{args.exp_name}" env_cfg, obs_cfg, reward_cfg, command_cfg = get_cfgs() train_cfg = get_train_cfg(args.exp_name) if os.path.exists(log_dir): shutil.rmtree(log_dir) os.makedirs(log_dir, exist_ok=True) if args.vis: env_cfg["visualize_target"] = True with open(f"{log_dir}/cfgs.pkl", "wb") as f: pickle.dump([env_cfg, obs_cfg, reward_cfg, command_cfg, train_cfg], f) env = HoverEnv( num_envs=args.num_envs, env_cfg=env_cfg, obs_cfg=obs_cfg, reward_cfg=reward_cfg, command_cfg=command_cfg, show_viewer=args.vis, ) runner = OnPolicyRunner(env, train_cfg, log_dir, device=gs.device) runner.learn(num_learning_iterations=args.max_iterations, init_at_random_ep_len=True) if __name__ == "__main__": main() """ # training python examples/drone/hover_train.py """ |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |