new
This commit is contained in:
parent
c9f2ff9272
commit
d7ca7b6b99
@ -283,14 +283,13 @@ class sprint(gym.Env):
|
||||
self.player.terminate()
|
||||
|
||||
|
||||
def generate_random_target(self, x_range=(-12, 12), y_range=(-9, 9)):
|
||||
def generate_random_target(self, x_range=(-15, 15), y_range=(-10, 10)):
|
||||
r = self.player.world.robot
|
||||
while True:
|
||||
x = np.random.uniform(x_range[0], x_range[1])
|
||||
y = np.random.uniform(y_range[0], y_range[1])
|
||||
|
||||
if np.linalg.norm(np.array([x, y]) - self.Gen_player_pos[:2]) >= 10:
|
||||
if abs(x) > 15 or abs(y) > 10:
|
||||
continue
|
||||
if np.linalg.norm(np.array([x, y]) - r.loc_head_position[:2]) >= 15:
|
||||
break
|
||||
|
||||
self.walk_target = np.array([x, y])
|
||||
@ -300,14 +299,18 @@ class sprint(gym.Env):
|
||||
player.world.robot)
|
||||
|
||||
w = self.player.world
|
||||
|
||||
internal_dist = np.linalg.norm(self.internal_target)
|
||||
action_mult = 1 if internal_dist > 0.2 else (0.7 / 0.2) * internal_dist + 0.3
|
||||
self.walk_rel_target = M.rotate_2d_vec(
|
||||
(self.walk_target[0] - r.loc_head_position[0], self.walk_target[1] - r.loc_head_position[1]), -r.imu_torso_orientation)
|
||||
self.walk_distance = np.linalg.norm(self.walk_target[:2] - self.Gen_player_pos[:2])
|
||||
self.walk_distance = np.linalg.norm(self.walk_target[:2] - r.loc_head_position[:2])
|
||||
if self.walk_distance < 0.5:
|
||||
self.generate_random_target()
|
||||
self.walk_rel_target = M.rotate_2d_vec(
|
||||
(self.walk_target[0] - r.loc_head_position[0], self.walk_target[1] - r.loc_head_position[1]),
|
||||
-r.imu_torso_orientation)
|
||||
self.walk_distance = np.linalg.norm(self.walk_target[:2] - r.loc_head_position[:2])
|
||||
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
|
||||
|
||||
@ -339,17 +342,16 @@ class sprint(gym.Env):
|
||||
self.sync()
|
||||
self.step_counter += 1
|
||||
obs = self.observe()
|
||||
robot_speed = r.loc_torso_velocity[0]
|
||||
robot_speed = np.linalg.norm(r.loc_torso_velocity[:2])
|
||||
direction_error = abs(self.walk_rel_orientation)
|
||||
direction_error = min(direction_error, 10)
|
||||
reward = robot_speed * (1.5 - direction_error / 10)
|
||||
if self.walk_distance < 0.5:
|
||||
direction_error = min(direction_error, 20)
|
||||
reward = robot_speed * (1 - direction_error / 20)
|
||||
if self.walk_distance < 0.8:
|
||||
reward += 10
|
||||
self.generate_random_target()
|
||||
|
||||
if self.player.behavior.is_ready("Get_Up"):
|
||||
self.terminal = True
|
||||
elif w.time_local_ms - self.reset_time > 100000:
|
||||
elif w.time_local_ms - self.reset_time > 300000:
|
||||
self.terminal = True
|
||||
else:
|
||||
self.terminal = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user