From fac8cb7e947e4617815030902d970bd8a19a9d76 Mon Sep 17 00:00:00 2001 From: MagDish <2717360869@qq.com> Date: Tue, 19 Nov 2024 21:26:11 +0800 Subject: [PATCH] new best --- scripts/gyms/Sprint.py | 12 ++++++------ scripts/gyms/sprint_demo.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/gyms/Sprint.py b/scripts/gyms/Sprint.py index 139a89f..54642b8 100644 --- a/scripts/gyms/Sprint.py +++ b/scripts/gyms/Sprint.py @@ -285,12 +285,12 @@ class sprint(gym.Env): def generate_random_target(self, position): while True: angle = np.random.uniform(0, 2 * np.pi) - X = position[0] * 10 * np.cos(angle) - Y = position[1] * 10 * np.sin(angle) - if -13 <= X <= 13 and -8 <= Y <= 8: + x = position[0] + 10 * np.cos(angle) + y = position[1] + 10 * np.sin(angle) + if -13 <= x <= 13 and -8 <= y <= 8: break - self.walk_target = np.array([X, Y]) + self.walk_target = np.array([x, y]) def step(self, action): @@ -362,9 +362,9 @@ class Train(Train_Base): def train(self, args): # --------------------------------------- Learning parameters - n_envs = min(10, os.cpu_count()) + n_envs = min(12, os.cpu_count()) n_steps_per_env = 1024 # RolloutBuffer is of size (n_steps_per_env * n_envs) - minibatch_size = 256 # should be a factor of (n_steps_per_env * n_envs) + minibatch_size = 64 # should be a factor of (n_steps_per_env * n_envs) total_steps = 50000000 learning_rate = 3e-4 folder_name = f'Sprint_R{self.robot_type}' diff --git a/scripts/gyms/sprint_demo.py b/scripts/gyms/sprint_demo.py index 9c2c293..20975de 100644 --- a/scripts/gyms/sprint_demo.py +++ b/scripts/gyms/sprint_demo.py @@ -292,7 +292,7 @@ class sprint(gym.Env): self.walk_rel_orientation = M.vector_angle(self.walk_rel_target) * 0.3 # exponential moving average - self.act = 0.8 * self.act + 0.2 * action * action_mult * 0.7 + self.act = 0.6 * self.act + 0.4 * action # execute Step behavior to extract the target positions of each leg (we will override these targets) lfy, lfz, rfy, rfz = self.step_generator.get_target_positions(self.step_counter == 0, self.STEP_DUR,